diff --git a/charts/islandis/values.dev.yaml b/charts/islandis/values.dev.yaml index c8fbd907f529..4f46bb923ad3 100644 --- a/charts/islandis/values.dev.yaml +++ b/charts/islandis/values.dev.yaml @@ -368,7 +368,7 @@ api: XROAD_ICELAND_UNIVERSITY_OF_THE_ARTS_PATH: 'IS-DEV/EDU/10049/LHI-Protected/brautskraning-v1' XROAD_INNA_PATH: 'IS-DEV/GOV/10066/MMS-Protected/inna-v1' XROAD_INTELLECTUAL_PROPERTIES_PATH: 'IS-DEV/GOV/10030/WebAPI-Public/HUG-webAPI/' - XROAD_MMS_FRIGG_PATH: 'IS-DEV/GOV/10066/MMS-Protected/frigg-api' + XROAD_MMS_FRIGG_PATH: 'IS-DEV/GOV/10066/MMS-Protected/frigg-form-service' XROAD_MMS_GRADE_SERVICE_ID: 'IS-DEV/GOV/10066/MMS-Protected/grade-api-v1' XROAD_MMS_LICENSE_SERVICE_ID: 'IS-DEV/GOV/10066/MMS-Protected/license-api-v1' XROAD_NATIONAL_REGISTRY_REDIS_NODES: '["clustercfg.general-redis-cluster-group.5fzau3.euw1.cache.amazonaws.com:6379"]' @@ -647,7 +647,7 @@ application-system-api: XROAD_HOLAR_UNIVERSITY_PATH: 'IS-DEV/EDU/10055/Holar-Protected/brautskraning-v1' XROAD_ICELAND_UNIVERSITY_OF_THE_ARTS_PATH: 'IS-DEV/EDU/10049/LHI-Protected/brautskraning-v1' XROAD_INNA_PATH: 'IS-DEV/GOV/10066/MMS-Protected/inna-v1' - XROAD_MMS_FRIGG_PATH: 'IS-DEV/GOV/10066/MMS-Protected/frigg-api' + XROAD_MMS_FRIGG_PATH: 'IS-DEV/GOV/10066/MMS-Protected/frigg-form-service' XROAD_NATIONAL_REGISTRY_REDIS_NODES: '["clustercfg.general-redis-cluster-group.5fzau3.euw1.cache.amazonaws.com:6379"]' XROAD_NATIONAL_REGISTRY_SERVICE_PATH: 'IS-DEV/GOV/10001/SKRA-Protected/Einstaklingar-v1' XROAD_OFFICIAL_JOURNAL_APPLICATION_PATH: 'IS-DEV/GOV/10014/DMR-Protected/official-journal-application' diff --git a/charts/islandis/values.prod.yaml b/charts/islandis/values.prod.yaml index 92b9250b3f09..b10ee2b0f6cb 100644 --- a/charts/islandis/values.prod.yaml +++ b/charts/islandis/values.prod.yaml @@ -358,7 +358,7 @@ api: XROAD_ICELAND_UNIVERSITY_OF_THE_ARTS_PATH: 'IS/EDU/4210984099/LHI-Protected/brautskraning-v1' XROAD_INNA_PATH: 'IS/GOV/6601241280/MMS-Protected/inna-v1' XROAD_INTELLECTUAL_PROPERTIES_PATH: 'IS/GOV/6501912189/WebAPI-Public/HUG-webAPI/' - XROAD_MMS_FRIGG_PATH: 'IS/GOV/10066/MMS-Protected/frigg-api' + XROAD_MMS_FRIGG_PATH: 'IS/GOV/10066/MMS-Protected/frigg-form-service' XROAD_MMS_GRADE_SERVICE_ID: 'IS/GOV/6601241280/MMS-Protected/grade-api-v1' XROAD_MMS_LICENSE_SERVICE_ID: 'IS/GOV/6601241280/MMS-Protected/license-api-v1' XROAD_NATIONAL_REGISTRY_REDIS_NODES: '["clustercfg.general-redis-cluster-group.whakos.euw1.cache.amazonaws.com:6379"]' @@ -637,7 +637,7 @@ application-system-api: XROAD_HOLAR_UNIVERSITY_PATH: 'IS/EDU/5001694359/Holar-Protected/brautskraning-v1' XROAD_ICELAND_UNIVERSITY_OF_THE_ARTS_PATH: 'IS/EDU/4210984099/LHI-Protected/brautskraning-v1' XROAD_INNA_PATH: 'IS/GOV/6601241280/MMS-Protected/inna-v1' - XROAD_MMS_FRIGG_PATH: 'IS/GOV/10066/MMS-Protected/frigg-api' + XROAD_MMS_FRIGG_PATH: 'IS/GOV/10066/MMS-Protected/frigg-form-service' XROAD_NATIONAL_REGISTRY_REDIS_NODES: '["clustercfg.general-redis-cluster-group.whakos.euw1.cache.amazonaws.com:6379"]' XROAD_NATIONAL_REGISTRY_SERVICE_PATH: 'IS/GOV/6503760649/SKRA-Protected/Einstaklingar-v1' XROAD_OFFICIAL_JOURNAL_APPLICATION_PATH: 'IS/GOV/10014/DMR-Protected/official-journal-application' diff --git a/charts/islandis/values.staging.yaml b/charts/islandis/values.staging.yaml index 5fbb15a89a49..bedaecf18031 100644 --- a/charts/islandis/values.staging.yaml +++ b/charts/islandis/values.staging.yaml @@ -368,7 +368,7 @@ api: XROAD_ICELAND_UNIVERSITY_OF_THE_ARTS_PATH: 'IS-TEST/EDU/10049/LHI-Protected/brautskraning-v1' XROAD_INNA_PATH: 'IS-TEST/GOV/6601241280/MMS-Protected/inna-v1' XROAD_INTELLECTUAL_PROPERTIES_PATH: 'IS-TEST/GOV/6501912189/WebAPI-Public/HUG-webAPI/' - XROAD_MMS_FRIGG_PATH: 'IS-TEST/GOV/10066/MMS-Protected/frigg-api' + XROAD_MMS_FRIGG_PATH: 'IS-TEST/GOV/10066/MMS-Protected/frigg-form-service' XROAD_MMS_GRADE_SERVICE_ID: 'IS-TEST/GOV/6601241280/MMS-Protected/grade-api-v1' XROAD_MMS_LICENSE_SERVICE_ID: 'IS-TEST/GOV/6601241280/MMS-Protected/license-api-v1' XROAD_NATIONAL_REGISTRY_REDIS_NODES: '["clustercfg.general-redis-cluster-group.ab9ckb.euw1.cache.amazonaws.com:6379"]' @@ -645,7 +645,7 @@ application-system-api: XROAD_HOLAR_UNIVERSITY_PATH: 'IS-TEST/EDU/10055/Holar-Protected/brautskraning-v1' XROAD_ICELAND_UNIVERSITY_OF_THE_ARTS_PATH: 'IS-TEST/EDU/10049/LHI-Protected/brautskraning-v1' XROAD_INNA_PATH: 'IS-TEST/GOV/6601241280/MMS-Protected/inna-v1' - XROAD_MMS_FRIGG_PATH: 'IS-TEST/GOV/10066/MMS-Protected/frigg-api' + XROAD_MMS_FRIGG_PATH: 'IS-TEST/GOV/10066/MMS-Protected/frigg-form-service' XROAD_NATIONAL_REGISTRY_REDIS_NODES: '["clustercfg.general-redis-cluster-group.ab9ckb.euw1.cache.amazonaws.com:6379"]' XROAD_NATIONAL_REGISTRY_SERVICE_PATH: 'IS-TEST/GOV/6503760649/SKRA-Protected/Einstaklingar-v1' XROAD_OFFICIAL_JOURNAL_APPLICATION_PATH: 'IS-TEST/GOV/10014/DMR-Protected/official-journal-application' diff --git a/infra/src/dsl/xroad.ts b/infra/src/dsl/xroad.ts index 0dc7df744772..3c765b72055f 100644 --- a/infra/src/dsl/xroad.ts +++ b/infra/src/dsl/xroad.ts @@ -884,9 +884,9 @@ export const OfficialJournalOfIcelandApplication = new XroadConf({ export const Frigg = new XroadConf({ env: { XROAD_MMS_FRIGG_PATH: { - dev: 'IS-DEV/GOV/10066/MMS-Protected/frigg-api', - staging: 'IS-TEST/GOV/10066/MMS-Protected/frigg-api', - prod: 'IS/GOV/10066/MMS-Protected/frigg-api', + dev: 'IS-DEV/GOV/10066/MMS-Protected/frigg-form-service', + staging: 'IS-TEST/GOV/10066/MMS-Protected/frigg-form-service', + prod: 'IS/GOV/10066/MMS-Protected/frigg-form-service', }, }, }) diff --git a/libs/api/domains/education/src/lib/graphql/frigg.resolver.ts b/libs/api/domains/education/src/lib/graphql/frigg.resolver.ts index 5a009eac74d1..6a9fb851d3b8 100644 --- a/libs/api/domains/education/src/lib/graphql/frigg.resolver.ts +++ b/libs/api/domains/education/src/lib/graphql/frigg.resolver.ts @@ -1,20 +1,22 @@ -import { Args, Query, Resolver } from '@nestjs/graphql' - -import { UseGuards } from '@nestjs/common' - +import type { User } from '@island.is/auth-nest-tools' import { CurrentUser, IdsUserGuard, Scopes, ScopesGuard, } from '@island.is/auth-nest-tools' - -import type { User } from '@island.is/auth-nest-tools' import { ApiScope } from '@island.is/auth/scopes' -import { FriggClientService, KeyOption } from '@island.is/clients/mms/frigg' +import { + FriggClientService, + KeyOption, + OrganizationModel, +} from '@island.is/clients/mms/frigg' +import { UseGuards } from '@nestjs/common' +import { Args, Query, Resolver } from '@nestjs/graphql' import { KeyOptionModel } from './frigg/keyOption.model' import { FriggOptionListInput } from './frigg/optionList.input' +import { FriggOrganizationModel } from './frigg/organization.model' @UseGuards(IdsUserGuard, ScopesGuard) @Scopes(ApiScope.internal) @@ -30,4 +32,11 @@ export class FriggResolver { ): Promise { return this.friggClientService.getAllKeyOptions(user, input.type) } + + @Query(() => [FriggOrganizationModel], { nullable: true }) + friggSchoolsByMunicipality( + @CurrentUser() user: User, + ): Promise { + return this.friggClientService.getAllSchoolsByMunicipality(user) + } } diff --git a/libs/api/domains/education/src/lib/graphql/frigg/organization.model.ts b/libs/api/domains/education/src/lib/graphql/frigg/organization.model.ts new file mode 100644 index 000000000000..649737b3fa6e --- /dev/null +++ b/libs/api/domains/education/src/lib/graphql/frigg/organization.model.ts @@ -0,0 +1,32 @@ +import { Field, ObjectType, registerEnumType } from '@nestjs/graphql' + +export enum OrganizationModelTypeEnum { + Municipality = 'municipality', + National = 'national', + School = 'school', +} + +registerEnumType(OrganizationModelTypeEnum, { + name: 'OrganizationModelTypeEnum', +}) + +@ObjectType('EducationFriggOrganizationModel') +export class FriggOrganizationModel { + @Field() + id!: string + + @Field() + nationalId!: string + + @Field() + name!: string + + @Field(() => OrganizationModelTypeEnum) + type!: OrganizationModelTypeEnum + + @Field(() => [String], { nullable: true }) + gradeLevels?: string[] + + @Field(() => [FriggOrganizationModel], { nullable: true }) + children?: FriggOrganizationModel[] +} diff --git a/libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.service.ts b/libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.service.ts index efec706e766d..c09cb23ad888 100644 --- a/libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.service.ts +++ b/libs/application/template-api-modules/src/lib/modules/templates/new-primary-school/new-primary-school.service.ts @@ -1,28 +1,90 @@ -import { Inject, Injectable } from '@nestjs/common' +import { NationalRegistryXRoadService } from '@island.is/api/domains/national-registry-x-road' +import { + errorMessages, + getApplicationAnswers, +} from '@island.is/application/templates/new-primary-school' import { ApplicationTypes } from '@island.is/application/types' -import { BaseTemplateApiService } from '../../base-template-api.service' import { FriggClientService } from '@island.is/clients/mms/frigg' import { LOGGER_PROVIDER } from '@island.is/logging' +import { TemplateApiError } from '@island.is/nest/problem' +import { Inject, Injectable } from '@nestjs/common' +import * as kennitala from 'kennitala' import { TemplateApiModuleActionProps } from '../../../types' +import { BaseTemplateApiService } from '../../base-template-api.service' +import { isRunningOnEnvironment } from '@island.is/shared/utils' @Injectable() export class NewPrimarySchoolService extends BaseTemplateApiService { constructor( @Inject(LOGGER_PROVIDER) private logger: Logger, private readonly friggClientService: FriggClientService, + private readonly nationalRegistryService: NationalRegistryXRoadService, ) { super(ApplicationTypes.NEW_PRIMARY_SCHOOL) } - async getTypes({ auth }: TemplateApiModuleActionProps) { - return await this.friggClientService.getTypes(auth) + async getKeyOptionsTypes({ auth }: TemplateApiModuleActionProps) { + return await this.friggClientService.getKeyOptionsTypes(auth) } async getAllKeyOptions({ auth }: TemplateApiModuleActionProps) { - return await this.friggClientService.getAllKeyOptions(auth, '') + return await this.friggClientService.getAllKeyOptions(auth, undefined) + } + + async getChildInformation({ + auth, + application, + }: TemplateApiModuleActionProps) { + const { childNationalId } = getApplicationAnswers(application.answers) + + return await this.friggClientService.getUserById(auth, childNationalId) } - async getHealth({ auth }: TemplateApiModuleActionProps) { - return await this.friggClientService.getHealth(auth) + async getChildren({ auth }: TemplateApiModuleActionProps) { + const children = + await this.nationalRegistryService.getChildrenCustodyInformation(auth) + + const currentYear = new Date().getFullYear() + const maxYear = currentYear - 7 // 2nd grade + const minYear = currentYear - 16 // 10th grade + + // Check if the child is at primary school age and lives with the applicant + const filteredChildren = children.filter((child) => { + // Allow children to pass through + const validChildren = [ + '1111111119', + '2222222229', + '5555555559', + '6666666669', + ] + if ( + isRunningOnEnvironment('local') && + validChildren.includes(child.nationalId) + ) { + return true + } + + const yearOfBirth = kennitala + .info(child.nationalId) + .birthday.getFullYear() + + return ( + child.livesWithApplicant && + yearOfBirth >= minYear && + yearOfBirth <= maxYear + ) + }) + + if (filteredChildren.length === 0) { + throw new TemplateApiError( + { + title: errorMessages.noChildrenFoundTitle, + summary: errorMessages.noChildrenFoundMessage, + }, + 400, + ) + } + + return filteredChildren } } diff --git a/libs/application/templates/new-primary-school/src/dataProviders/index.ts b/libs/application/templates/new-primary-school/src/dataProviders/index.ts index 634d71350a1b..b36fb2d72f90 100644 --- a/libs/application/templates/new-primary-school/src/dataProviders/index.ts +++ b/libs/application/templates/new-primary-school/src/dataProviders/index.ts @@ -3,14 +3,20 @@ import { defineTemplateApi, } from '@island.is/application/types' -export const GetTypesApi = defineTemplateApi({ - action: 'getTypes', - externalDataId: 'types', +export const GetKeyOptionsTypesApi = defineTemplateApi({ + action: 'getKeyOptionsTypes', + externalDataId: 'keyOptionsTypes', namespace: ApplicationTypes.NEW_PRIMARY_SCHOOL, }) -export const GetHealthApi = defineTemplateApi({ - action: 'getHealth', - externalDataId: 'health', +export const OptionsApi = defineTemplateApi({ + action: 'getAllKeyOptions', + externalDataId: 'KeyOptions', + namespace: ApplicationTypes.NEW_PRIMARY_SCHOOL, +}) + +export const ChildrenApi = defineTemplateApi({ + action: 'getChildren', + externalDataId: 'children', namespace: ApplicationTypes.NEW_PRIMARY_SCHOOL, }) diff --git a/libs/application/templates/new-primary-school/src/fields/FriggOptionsAsyncSelectField/index.tsx b/libs/application/templates/new-primary-school/src/fields/FriggOptionsAsyncSelectField/index.tsx new file mode 100644 index 000000000000..eae477a04fa9 --- /dev/null +++ b/libs/application/templates/new-primary-school/src/fields/FriggOptionsAsyncSelectField/index.tsx @@ -0,0 +1,84 @@ +import { coreErrorMessages } from '@island.is/application/core' +import { + FieldBaseProps, + FieldComponents, + FieldTypes, + FormText, +} from '@island.is/application/types' +import { AsyncSelectFormField } from '@island.is/application/ui-fields' +import { useLocale } from '@island.is/localization' +import React, { FC } from 'react' +import { OptionsType } from '../../lib/constants' +import { friggOptionsQuery } from '../../graphql/queries' +import { + FriggOptionsQuery, + FriggOptionsQueryVariables, +} from '../../types/schema' + +type FriggOptionsAsyncSelectFieldProps = { + field: { + props: { + optionsType: OptionsType + placeholder: FormText + isMulti?: boolean + } + } +} + +const FriggOptionsAsyncSelectField: FC< + React.PropsWithChildren +> = ({ error, field, application }) => { + const { lang } = useLocale() + const { title, props, defaultValue, id } = field + const { isMulti = true, optionsType, placeholder } = props + + return ( + { + const { data } = await apolloClient.query< + FriggOptionsQuery, + FriggOptionsQueryVariables + >({ + query: friggOptionsQuery, + variables: { + type: { + type: optionsType, + }, + }, + }) + + return ( + data?.friggOptions?.flatMap(({ options }) => + options.flatMap(({ value, key }) => { + let content = value.find( + ({ language }) => language === lang, + )?.content + if (!content) { + content = value.find( + ({ language }) => language === 'is', + )?.content + } + return { value: key ?? '', label: content ?? '' } + }), + ) ?? [] + ) + }, + isMulti, + backgroundColor: 'blue', + }} + /> + ) +} + +export default FriggOptionsAsyncSelectField diff --git a/libs/application/templates/new-primary-school/src/fields/RelativesTableRepeater/index.tsx b/libs/application/templates/new-primary-school/src/fields/RelativesTableRepeater/index.tsx new file mode 100644 index 000000000000..63c314c1b1d5 --- /dev/null +++ b/libs/application/templates/new-primary-school/src/fields/RelativesTableRepeater/index.tsx @@ -0,0 +1,102 @@ +import { + FieldBaseProps, + FieldComponents, + FieldTypes, +} from '@island.is/application/types' +import { + formatPhoneNumber, + removeCountryCode, +} from '@island.is/application/ui-components' +import { TableRepeaterFormField } from '@island.is/application/ui-fields' +import { format as formatKennitala } from 'kennitala' +import React, { FC } from 'react' +import { useFriggOptions } from '../../hooks/useFriggOptions' +import { OptionsType } from '../../lib/constants' +import { newPrimarySchoolMessages } from '../../lib/messages' +import { getSelectedOptionLabel } from '../../lib/newPrimarySchoolUtils' + +const RelativesTableRepeater: FC> = ({ + error, + field, + application, +}) => { + const { id, title } = field + + const relationFriggOptions = useFriggOptions(OptionsType.RELATION) + + return ( + + formatPhoneNumber(removeCountryCode(value ?? '')), + nationalId: (value) => formatKennitala(value), + relation: (value) => + getSelectedOptionLabel(relationFriggOptions, value) ?? '', + }, + header: [ + newPrimarySchoolMessages.shared.fullName, + newPrimarySchoolMessages.shared.phoneNumber, + newPrimarySchoolMessages.shared.nationalId, + newPrimarySchoolMessages.shared.relation, + ], + }, + }} + /> + ) +} + +export default RelativesTableRepeater diff --git a/libs/application/templates/new-primary-school/src/fields/Review/index.tsx b/libs/application/templates/new-primary-school/src/fields/Review/index.tsx index 4599570d8d9e..babded3a9ea1 100644 --- a/libs/application/templates/new-primary-school/src/fields/Review/index.tsx +++ b/libs/application/templates/new-primary-school/src/fields/Review/index.tsx @@ -16,11 +16,9 @@ import { ReasonForApplicationOptions, States } from '../../lib/constants' import { newPrimarySchoolMessages } from '../../lib/messages' import { getApplicationAnswers } from '../../lib/newPrimarySchoolUtils' -import { AllergiesAndIntolerances } from './review-groups/AllergiesAndIntolerances' import { Child } from './review-groups/Child' import { Languages } from './review-groups/Languages' import { Parents } from './review-groups/Parents' -import { Photography } from './review-groups/Photography' import { ReasonForApplication } from './review-groups/ReasonForApplication' import { Relatives } from './review-groups/Relatives' import { Siblings } from './review-groups/Siblings' @@ -167,9 +165,7 @@ export const Review: FC = ({ )} - - )} diff --git a/libs/application/templates/new-primary-school/src/fields/Review/review-groups/AllergiesAndIntolerances.tsx b/libs/application/templates/new-primary-school/src/fields/Review/review-groups/AllergiesAndIntolerances.tsx deleted file mode 100644 index 1b034ee09e9e..000000000000 --- a/libs/application/templates/new-primary-school/src/fields/Review/review-groups/AllergiesAndIntolerances.tsx +++ /dev/null @@ -1,86 +0,0 @@ -import { YES } from '@island.is/application/core' -import { DataValue, ReviewGroup } from '@island.is/application/ui-components' -import { GridColumn, GridRow, Stack } from '@island.is/island-ui/core' -import { useLocale } from '@island.is/localization' -import { newPrimarySchoolMessages } from '../../../lib/messages' -import { - getApplicationAnswers, - getFoodAllergiesOptionsLabel, - getFoodIntolerancesOptionsLabel, -} from '../../../lib/newPrimarySchoolUtils' -import { ReviewGroupProps } from './props' - -export const AllergiesAndIntolerances = ({ - application, - editable, - goToScreen, -}: ReviewGroupProps) => { - const { formatMessage } = useLocale() - const { - hasFoodAllergies, - hasFoodIntolerances, - isUsingEpiPen, - foodAllergies, - foodIntolerances, - } = getApplicationAnswers(application.answers) - - return ( - goToScreen?.('allergiesAndIntolerances')} - > - - {hasFoodAllergies.includes(YES) && ( - - - { - return formatMessage( - getFoodAllergiesOptionsLabel(allergies), - ) - }) - .join(', ')} - /> - - - )} - {hasFoodIntolerances.includes(YES) && ( - - - { - return formatMessage( - getFoodIntolerancesOptionsLabel(intolerances), - ) - }) - .join(', ')} - /> - - - )} - - - - - - - - ) -} diff --git a/libs/application/templates/new-primary-school/src/fields/Review/review-groups/Child.tsx b/libs/application/templates/new-primary-school/src/fields/Review/review-groups/Child.tsx index 3ff01b20e68d..df7ed000027e 100644 --- a/libs/application/templates/new-primary-school/src/fields/Review/review-groups/Child.tsx +++ b/libs/application/templates/new-primary-school/src/fields/Review/review-groups/Child.tsx @@ -6,9 +6,11 @@ import { format as formatKennitala } from 'kennitala' import { newPrimarySchoolMessages } from '../../../lib/messages' import { getApplicationAnswers, - getGenderOptionLabel, + getSelectedOptionLabel, } from '../../../lib/newPrimarySchoolUtils' import { ReviewGroupProps } from './props' +import { useFriggOptions } from '../../../hooks/useFriggOptions' +import { OptionsType } from '../../../lib/constants' export const Child = ({ application, @@ -20,10 +22,12 @@ export const Child = ({ application.answers, ) + const pronounOptions = useFriggOptions(OptionsType.PRONOUN) + return ( goToScreen?.('childrenMultiField')} + editAction={() => goToScreen?.('childInfo')} > @@ -63,28 +67,32 @@ export const Child = ({ /> - {(childInfo.gender || - childInfo.chosenName || + {(childInfo.preferredName || + childInfo.pronouns?.length > 0 || differentPlaceOfResidence === YES) && ( - {childInfo.chosenName && ( + {childInfo.preferredName && ( )} - {childInfo.gender && ( - + {childInfo.pronouns?.length > 0 && ( + + getSelectedOptionLabel(pronounOptions, pronoun), + ) + .join(', ')} /> )} diff --git a/libs/application/templates/new-primary-school/src/fields/Review/review-groups/Photography.tsx b/libs/application/templates/new-primary-school/src/fields/Review/review-groups/Photography.tsx deleted file mode 100644 index 1fc4c6ad8e1d..000000000000 --- a/libs/application/templates/new-primary-school/src/fields/Review/review-groups/Photography.tsx +++ /dev/null @@ -1,64 +0,0 @@ -import { YES } from '@island.is/application/core' -import { RadioValue, ReviewGroup } from '@island.is/application/ui-components' -import { GridColumn, GridRow, Stack } from '@island.is/island-ui/core' -import { useLocale } from '@island.is/localization' -import { newPrimarySchoolMessages } from '../../../lib/messages' -import { getApplicationAnswers } from '../../../lib/newPrimarySchoolUtils' -import { ReviewGroupProps } from './props' - -export const Photography = ({ - application, - editable, - goToScreen, -}: ReviewGroupProps) => { - const { formatMessage } = useLocale() - const { photographyConsent, photoSchoolPublication, photoMediaPublication } = - getApplicationAnswers(application.answers) - - return ( - goToScreen?.('photography')} - isLast={true} - > - - - - - - - {photographyConsent === YES && ( - <> - - - - - - - - - - - - )} - - - ) -} diff --git a/libs/application/templates/new-primary-school/src/fields/Review/review-groups/Relatives.tsx b/libs/application/templates/new-primary-school/src/fields/Review/review-groups/Relatives.tsx index 7e2073e7967e..9377bdd34b49 100644 --- a/libs/application/templates/new-primary-school/src/fields/Review/review-groups/Relatives.tsx +++ b/libs/application/templates/new-primary-school/src/fields/Review/review-groups/Relatives.tsx @@ -1,4 +1,4 @@ -import { FieldComponents, FieldTypes, YES } from '@island.is/application/types' +import { FieldComponents, FieldTypes } from '@island.is/application/types' import { Label, ReviewGroup, @@ -9,10 +9,12 @@ import { StaticTableFormField } from '@island.is/application/ui-fields' import { Box, GridColumn, GridRow } from '@island.is/island-ui/core' import { useLocale } from '@island.is/localization' import { format as formatKennitala } from 'kennitala' +import { useFriggOptions } from '../../../hooks/useFriggOptions' +import { OptionsType } from '../../../lib/constants' import { newPrimarySchoolMessages } from '../../../lib/messages' import { getApplicationAnswers, - getRelationOptionLabel, + getSelectedOptionLabel, } from '../../../lib/newPrimarySchoolUtils' import { ReviewGroupProps } from './props' @@ -24,15 +26,14 @@ export const Relatives = ({ const { formatMessage } = useLocale() const { relatives } = getApplicationAnswers(application.answers) + const relationFriggOptions = useFriggOptions(OptionsType.RELATION) + const rows = relatives.map((r) => { return [ r.fullName, formatPhoneNumber(removeCountryCode(r.phoneNumber ?? '')), formatKennitala(r.nationalId), - getRelationOptionLabel(r.relation), - r.canPickUpChild?.includes(YES) - ? newPrimarySchoolMessages.shared.yes - : newPrimarySchoolMessages.shared.no, + getSelectedOptionLabel(relationFriggOptions, r.relation) ?? '', ] }) @@ -64,8 +65,6 @@ export const Relatives = ({ newPrimarySchoolMessages.shared.phoneNumber, newPrimarySchoolMessages.shared.nationalId, newPrimarySchoolMessages.shared.relation, - newPrimarySchoolMessages.childrenNParents - .relativesCanPickUpChildTableHeader, ], rows, }} diff --git a/libs/application/templates/new-primary-school/src/fields/Review/review-groups/School.tsx b/libs/application/templates/new-primary-school/src/fields/Review/review-groups/School.tsx index d42cbdc63c5f..49ffef4364f9 100644 --- a/libs/application/templates/new-primary-school/src/fields/Review/review-groups/School.tsx +++ b/libs/application/templates/new-primary-school/src/fields/Review/review-groups/School.tsx @@ -2,7 +2,11 @@ import { DataValue, ReviewGroup } from '@island.is/application/ui-components' import { GridColumn, GridRow, Stack, Text } from '@island.is/island-ui/core' import { useLocale } from '@island.is/localization' import { newPrimarySchoolMessages } from '../../../lib/messages' -import { getApplicationAnswers } from '../../../lib/newPrimarySchoolUtils' +import { + formatGrade, + getApplicationAnswers, + getApplicationExternalData, +} from '../../../lib/newPrimarySchoolUtils' import { ReviewGroupProps } from './props' export const School = ({ @@ -10,10 +14,13 @@ export const School = ({ editable, goToScreen, }: ReviewGroupProps) => { - const { formatMessage, formatDate } = useLocale() + const { formatMessage, formatDate, lang } = useLocale() const { startDate, selectedSchool } = getApplicationAnswers( application.answers, ) + const { childGradeLevel } = getApplicationExternalData( + application.externalData, + ) return ( + {/* TODO: Bæta við núverandi skóla */} diff --git a/libs/application/templates/new-primary-school/src/fields/Review/review-groups/Support.tsx b/libs/application/templates/new-primary-school/src/fields/Review/review-groups/Support.tsx index ec27b12a2c5a..32d079f5a28a 100644 --- a/libs/application/templates/new-primary-school/src/fields/Review/review-groups/Support.tsx +++ b/libs/application/templates/new-primary-school/src/fields/Review/review-groups/Support.tsx @@ -18,6 +18,7 @@ export const Support = ({ goToScreen?.('support')} + isLast={true} > diff --git a/libs/application/templates/new-primary-school/src/fields/index.ts b/libs/application/templates/new-primary-school/src/fields/index.ts index 0e2d8dbbffd1..671bdef85414 100644 --- a/libs/application/templates/new-primary-school/src/fields/index.ts +++ b/libs/application/templates/new-primary-school/src/fields/index.ts @@ -1 +1,3 @@ +export { default as FriggOptionsAsyncSelectField } from './FriggOptionsAsyncSelectField' +export { default as RelativesTableRepeater } from './RelativesTableRepeater' export { Review } from './Review' diff --git a/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/childInfoSubSection.ts b/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/childInfoSubSection.ts index 8cfefc41ef9c..1e272d868fd0 100644 --- a/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/childInfoSubSection.ts +++ b/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/childInfoSubSection.ts @@ -1,19 +1,17 @@ import { + buildCustomField, buildMultiField, buildRadioField, - buildSelectField, buildSubSection, buildTextField, } from '@island.is/application/core' import { Application, NO, YES } from '@island.is/application/types' import { newPrimarySchoolMessages } from '../../../lib/messages' import { - formatGender, getApplicationAnswers, getApplicationExternalData, - getGenderOptions, - getSelectedChild, } from '../../../lib/newPrimarySchoolUtils' +import { OptionsType } from '../../../lib/constants' export const childInfoSubSection = buildSubSection({ id: 'childInfoSubSection', @@ -30,7 +28,8 @@ export const childInfoSubSection = buildSubSection({ title: newPrimarySchoolMessages.shared.fullName, disabled: true, defaultValue: (application: Application) => - getSelectedChild(application)?.fullName, + getApplicationExternalData(application.externalData) + .childInformation.name, }), buildTextField({ id: 'childInfo.nationalId', @@ -39,15 +38,14 @@ export const childInfoSubSection = buildSubSection({ format: '######-####', disabled: true, defaultValue: (application: Application) => - getSelectedChild(application)?.nationalId, + getApplicationExternalData(application.externalData) + .childInformation.nationalId, }), buildTextField({ id: 'childInfo.address.streetAddress', title: newPrimarySchoolMessages.shared.address, width: 'half', disabled: true, - // TODO: Nota gögn frá Júní - // TODO: Hægt að nota heimilisfang innskráðs foreldris? (foreldri getur ekki sótt um nema barn sé með sama lögheimili) defaultValue: (application: Application) => getApplicationExternalData(application.externalData) .applicantAddress, @@ -57,8 +55,6 @@ export const childInfoSubSection = buildSubSection({ title: newPrimarySchoolMessages.shared.postalCode, width: 'half', disabled: true, - // TODO: Nota gögn frá Júní - // TODO: Hægt að nota heimilisfang innskráðs foreldris? (foreldri getur ekki sótt um nema barn sé með sama lögheimili) defaultValue: (application: Application) => getApplicationExternalData(application.externalData) .applicantPostalCode, @@ -68,28 +64,33 @@ export const childInfoSubSection = buildSubSection({ title: newPrimarySchoolMessages.shared.municipality, width: 'half', disabled: true, - // TODO: Nota gögn frá Júní - // TODO: Hægt að nota heimilisfang innskráðs foreldris? (foreldri getur ekki sótt um nema barn sé með sama lögheimili) defaultValue: (application: Application) => getApplicationExternalData(application.externalData).applicantCity, }), buildTextField({ - id: 'childInfo.chosenName', - title: newPrimarySchoolMessages.childrenNParents.childInfoChosenName, - width: 'half', - }), - buildSelectField({ - id: 'childInfo.gender', - title: newPrimarySchoolMessages.childrenNParents.childInfoGender, - placeholder: - newPrimarySchoolMessages.childrenNParents - .childInfoGenderPlaceholder, - width: 'half', - // TODO: Nota gögn fá Júní - options: getGenderOptions(), + id: 'childInfo.preferredName', + title: + newPrimarySchoolMessages.childrenNParents.childInfoPreferredName, defaultValue: (application: Application) => - formatGender(getSelectedChild(application)?.genderCode), + getApplicationExternalData(application.externalData) + .childInformation.preferredName ?? undefined, }), + buildCustomField( + { + id: 'childInfo.pronouns', + title: newPrimarySchoolMessages.childrenNParents.childInfoPronouns, + component: 'FriggOptionsAsyncSelectField', + defaultValue: (application: Application) => + getApplicationExternalData(application.externalData) + .childInformation.pronouns, + }, + { + optionsType: OptionsType.PRONOUN, + placeholder: + newPrimarySchoolMessages.childrenNParents + .childInfoPronounsPlaceholder, + }, + ), buildRadioField({ id: 'childInfo.differentPlaceOfResidence', title: diff --git a/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/childrenSubSection.ts b/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/childrenSubSection.ts deleted file mode 100644 index 3a4ddf4ae7f0..000000000000 --- a/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/childrenSubSection.ts +++ /dev/null @@ -1,46 +0,0 @@ -import { - buildMultiField, - buildRadioField, - buildSubSection, -} from '@island.is/application/core' -import { format as formatKennitala } from 'kennitala' -import { newPrimarySchoolMessages } from '../../../lib/messages' -import { - canApply, - getApplicationExternalData, -} from '../../../lib/newPrimarySchoolUtils' - -export const childrenSubSection = buildSubSection({ - id: 'childrenSubSection', - title: newPrimarySchoolMessages.childrenNParents.childrenSubSectionTitle, - children: [ - buildMultiField({ - id: 'childrenMultiField', - title: newPrimarySchoolMessages.childrenNParents.childrenSubSectionTitle, - description: - newPrimarySchoolMessages.childrenNParents.childrenDescription, - children: [ - buildRadioField({ - id: 'childNationalId', - title: newPrimarySchoolMessages.childrenNParents.childrenRadioTitle, - options: (application) => { - const { children } = getApplicationExternalData( - application.externalData, - ) - - return children - .filter((child) => canApply(child)) - .map((child) => { - return { - value: child.nationalId, - label: child.fullName, - subLabel: formatKennitala(child.nationalId), - } - }) - }, - required: true, - }), - ], - }), - ], -}) diff --git a/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/index.ts b/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/index.ts index 9779b607c08c..023e05a1e723 100644 --- a/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/index.ts +++ b/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/index.ts @@ -1,17 +1,11 @@ import { buildSection } from '@island.is/application/core' import { newPrimarySchoolMessages } from '../../../lib/messages' import { childInfoSubSection } from './childInfoSubSection' -import { childrenSubSection } from './childrenSubSection' import { parentsSubSection } from './parentsSubSection' import { relativesSubSection } from './relativesSubSection' export const childrenNParentsSection = buildSection({ id: 'childrenNParentsSection', title: newPrimarySchoolMessages.childrenNParents.sectionTitle, - children: [ - childrenSubSection, - childInfoSubSection, - parentsSubSection, - relativesSubSection, - ], + children: [childInfoSubSection, parentsSubSection, relativesSubSection], }) diff --git a/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/parentsSubSection.ts b/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/parentsSubSection.ts index 3a54030ac709..ec2812b7db09 100644 --- a/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/parentsSubSection.ts +++ b/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/parentsSubSection.ts @@ -161,7 +161,7 @@ export const parentsSubSection = buildSubSection({ condition: (answers, externalData) => hasOtherParent(answers, externalData), defaultValue: (application: Application) => - getOtherParent(application)?.address.streetAddress, + getOtherParent(application)?.address.streetName, }), buildTextField({ id: 'parents.parent2.address.postalCode', diff --git a/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/relativesSubSection.ts b/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/relativesSubSection.ts index 5fe016271a70..f3a96abeeae9 100644 --- a/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/relativesSubSection.ts +++ b/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/childrenNParentsSection/relativesSubSection.ts @@ -1,20 +1,9 @@ import { + buildCustomField, buildMultiField, buildSubSection, - buildTableRepeaterField, } from '@island.is/application/core' -import { YES } from '@island.is/application/types' -import { - formatPhoneNumber, - removeCountryCode, -} from '@island.is/application/ui-components' -import { format as formatKennitala } from 'kennitala' -import { RelationOptions } from '../../../lib/constants' import { newPrimarySchoolMessages } from '../../../lib/messages' -import { - getRelationOptionLabel, - getRelationOptions, -} from '../../../lib/newPrimarySchoolUtils' export const relativesSubSection = buildSubSection({ id: 'relativesSubSection', @@ -26,91 +15,10 @@ export const relativesSubSection = buildSubSection({ description: newPrimarySchoolMessages.childrenNParents.relativesDescription, children: [ - buildTableRepeaterField({ + buildCustomField({ id: 'relatives', title: '', - formTitle: - newPrimarySchoolMessages.childrenNParents - .relativesRegistrationTitle, - addItemButtonText: - newPrimarySchoolMessages.childrenNParents.relativesAddRelative, - saveItemButtonText: - newPrimarySchoolMessages.childrenNParents.relativesRegisterRelative, - removeButtonTooltipText: - newPrimarySchoolMessages.childrenNParents.relativesDeleteRelative, - marginTop: 0, - maxRows: 6, - fields: { - fullName: { - component: 'input', - label: newPrimarySchoolMessages.shared.fullName, - width: 'half', - type: 'text', - dataTestId: 'relative-full-name', - }, - phoneNumber: { - component: 'input', - label: newPrimarySchoolMessages.shared.phoneNumber, - width: 'half', - type: 'tel', - format: '###-####', - placeholder: '000-0000', - dataTestId: 'relative-phone-number', - }, - nationalId: { - component: 'input', - label: newPrimarySchoolMessages.shared.nationalId, - width: 'half', - type: 'text', - format: '######-####', - placeholder: '000000-0000', - dataTestId: 'relative-national-id', - }, - relation: { - component: 'select', - label: newPrimarySchoolMessages.shared.relation, - width: 'half', - placeholder: newPrimarySchoolMessages.shared.relationPlaceholder, - // TODO: Nota gögn fá Júní - options: getRelationOptions(), - dataTestId: 'relative-relation', - }, - canPickUpChild: { - component: 'checkbox', - width: 'full', - large: true, - options: [ - { - label: - newPrimarySchoolMessages.childrenNParents - .relativesCanPickUpChild, - value: YES, - }, - ], - dataTestId: 'relative-can-pick-up-child', - }, - }, - table: { - format: { - phoneNumber: (value) => - formatPhoneNumber(removeCountryCode(value ?? '')), - nationalId: (value) => formatKennitala(value), - relation: (value) => - getRelationOptionLabel(value as RelationOptions), - canPickUpChild: (value) => - value?.includes(YES) - ? newPrimarySchoolMessages.shared.yes - : newPrimarySchoolMessages.shared.no, - }, - header: [ - newPrimarySchoolMessages.shared.fullName, - newPrimarySchoolMessages.shared.phoneNumber, - newPrimarySchoolMessages.shared.nationalId, - newPrimarySchoolMessages.shared.relation, - newPrimarySchoolMessages.childrenNParents - .relativesCanPickUpChildTableHeader, - ], - }, + component: 'RelativesTableRepeater', }), ], }), diff --git a/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/differentNeedsSection/allergiesAndIntolerancesSubSection.ts b/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/differentNeedsSection/allergiesAndIntolerancesSubSection.ts deleted file mode 100644 index 050db767ee53..000000000000 --- a/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/differentNeedsSection/allergiesAndIntolerancesSubSection.ts +++ /dev/null @@ -1,142 +0,0 @@ -import { - buildAlertMessageField, - buildAsyncSelectField, - buildCheckboxField, - buildDescriptionField, - buildMultiField, - buildSubSection, -} from '@island.is/application/core' -import { YES } from '@island.is/application/types' -import { newPrimarySchoolMessages } from '../../../lib/messages' -import { - getApplicationAnswers, - getFoodAllergiesOptions, - getFoodIntolerancesOptions, -} from '../../../lib/newPrimarySchoolUtils' - -export const allergiesAndIntolerancesSubSection = buildSubSection({ - id: 'allergiesAndIntolerancesSubSection', - title: - newPrimarySchoolMessages.differentNeeds - .allergiesAndIntolerancesSubSectionTitle, - children: [ - buildMultiField({ - id: 'allergiesAndIntolerances', - title: - newPrimarySchoolMessages.differentNeeds - .foodAllergiesAndIntolerancesTitle, - description: - newPrimarySchoolMessages.differentNeeds - .foodAllergiesAndIntolerancesDescription, - children: [ - buildCheckboxField({ - id: 'allergiesAndIntolerances.hasFoodAllergies', - title: '', - spacing: 0, - options: [ - { - value: YES, - label: - newPrimarySchoolMessages.differentNeeds.childHasFoodAllergies, - }, - ], - }), - buildAsyncSelectField({ - id: 'allergiesAndIntolerances.foodAllergies', - title: newPrimarySchoolMessages.differentNeeds.typeOfAllergies, - dataTestId: 'food-allergies', - placeholder: - newPrimarySchoolMessages.differentNeeds.typeOfAllergiesPlaceholder, - // TODO: Nota gögn fá Júní - loadOptions: async ({ apolloClient }) => { - /* return await getOptionsListByType( - apolloClient, - OptionsType.ALLERGRY, - )*/ - - return getFoodAllergiesOptions() - }, - isMulti: true, - condition: (answers) => { - const { hasFoodAllergies } = getApplicationAnswers(answers) - - return hasFoodAllergies?.includes(YES) - }, - }), - buildAlertMessageField({ - id: 'allergiesAndIntolerances.info', - title: newPrimarySchoolMessages.shared.alertTitle, - message: - newPrimarySchoolMessages.differentNeeds - .confirmFoodAllergiesAlertMessage, - doesNotRequireAnswer: true, - alertType: 'info', - marginBottom: 4, - condition: (answers) => { - const { hasFoodAllergies } = getApplicationAnswers(answers) - - return hasFoodAllergies?.includes(YES) - }, - }), - buildCheckboxField({ - id: 'allergiesAndIntolerances.hasFoodIntolerances', - title: '', - spacing: 0, - options: [ - { - value: YES, - label: - newPrimarySchoolMessages.differentNeeds - .childHasFoodIntolerances, - }, - ], - }), - buildAsyncSelectField({ - id: 'allergiesAndIntolerances.foodIntolerances', - title: newPrimarySchoolMessages.differentNeeds.typeOfIntolerances, - dataTestId: 'food-intolerances', - placeholder: - newPrimarySchoolMessages.differentNeeds - .typeOfIntolerancesPlaceholder, - // TODO: Nota gögn fá Júní - loadOptions: async ({ apolloClient }) => { - /*return await getOptionsListByType( - apolloClient, - OptionsType.INTELERENCE, - )*/ - - return getFoodIntolerancesOptions() - }, - isMulti: true, - condition: (answers) => { - const { hasFoodIntolerances } = getApplicationAnswers(answers) - - return hasFoodIntolerances?.includes(YES) - }, - }), - buildDescriptionField({ - // Needed to add space - id: 'allergiesAndIntolerances.divider', - title: '', - marginBottom: 4, - condition: (answers) => { - const { hasFoodIntolerances } = getApplicationAnswers(answers) - - return hasFoodIntolerances?.includes(YES) - }, - }), - buildCheckboxField({ - id: 'allergiesAndIntolerances.isUsingEpiPen', - title: '', - spacing: 0, - options: [ - { - value: YES, - label: newPrimarySchoolMessages.differentNeeds.usesEpinephrinePen, - }, - ], - }), - ], - }), - ], -}) diff --git a/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/differentNeedsSection/index.ts b/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/differentNeedsSection/index.ts index 4df41b1c2790..1c26f46f6c96 100644 --- a/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/differentNeedsSection/index.ts +++ b/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/differentNeedsSection/index.ts @@ -2,10 +2,8 @@ import { buildSection } from '@island.is/application/core' import { ReasonForApplicationOptions } from '../../../lib/constants' import { newPrimarySchoolMessages } from '../../../lib/messages' import { getApplicationAnswers } from '../../../lib/newPrimarySchoolUtils' -import { allergiesAndIntolerancesSubSection } from './allergiesAndIntolerancesSubSection' import { languageSubSection } from './languageSubSection' import { supportSubSection } from './supportSubSection' -import { useOfFootageSubSection } from './useOfFootageSubSection' export const differentNeedsSection = buildSection({ id: 'differentNeedsSection', @@ -15,10 +13,5 @@ export const differentNeedsSection = buildSection({ const { reasonForApplication } = getApplicationAnswers(answers) return reasonForApplication !== ReasonForApplicationOptions.MOVING_ABROAD }, - children: [ - languageSubSection, - allergiesAndIntolerancesSubSection, - supportSubSection, - useOfFootageSubSection, - ], + children: [languageSubSection, supportSubSection], }) diff --git a/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/differentNeedsSection/useOfFootageSubSection.ts b/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/differentNeedsSection/useOfFootageSubSection.ts deleted file mode 100644 index 995dfbcf5552..000000000000 --- a/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/differentNeedsSection/useOfFootageSubSection.ts +++ /dev/null @@ -1,91 +0,0 @@ -import { - buildAlertMessageField, - buildMultiField, - buildRadioField, - buildSubSection, -} from '@island.is/application/core' -import { NO, YES } from '@island.is/application/types' -import { newPrimarySchoolMessages } from '../../../lib/messages' -import { getApplicationAnswers } from '../../../lib/newPrimarySchoolUtils' - -export const useOfFootageSubSection = buildSubSection({ - id: 'useOfFootageSubSection', - title: newPrimarySchoolMessages.differentNeeds.useOfFootageSubSectionTitle, - children: [ - buildMultiField({ - id: 'photography', - title: newPrimarySchoolMessages.differentNeeds.photography, - description: - newPrimarySchoolMessages.differentNeeds.photographyDescription, - children: [ - buildRadioField({ - id: 'photography.photographyConsent', - title: newPrimarySchoolMessages.differentNeeds.photographyConsent, - width: 'half', - required: true, - options: [ - { - label: newPrimarySchoolMessages.shared.yes, - dataTestId: 'yes-option', - value: YES, - }, - { - label: newPrimarySchoolMessages.shared.no, - dataTestId: 'no-option', - value: NO, - }, - ], - }), - buildRadioField({ - id: 'photography.photoSchoolPublication', - condition: (answers) => { - const { photographyConsent } = getApplicationAnswers(answers) - return photographyConsent === YES - }, - title: newPrimarySchoolMessages.differentNeeds.photoSchoolPublication, - width: 'half', - options: [ - { - label: newPrimarySchoolMessages.shared.yes, - dataTestId: 'yes-option', - value: YES, - }, - { - label: newPrimarySchoolMessages.shared.no, - dataTestId: 'no-option', - value: NO, - }, - ], - }), - buildRadioField({ - id: 'photography.photoMediaPublication', - condition: (answers) => { - const { photographyConsent } = getApplicationAnswers(answers) - return photographyConsent === YES - }, - title: newPrimarySchoolMessages.differentNeeds.photoMediaPublication, - width: 'half', - options: [ - { - label: newPrimarySchoolMessages.shared.yes, - dataTestId: 'yes-option', - value: YES, - }, - { - label: newPrimarySchoolMessages.shared.no, - dataTestId: 'no-option', - value: NO, - }, - ], - }), - buildAlertMessageField({ - id: 'differentNeeds.photographyInfo', - title: newPrimarySchoolMessages.shared.alertTitle, - message: newPrimarySchoolMessages.differentNeeds.photographyInfo, - doesNotRequireAnswer: true, - alertType: 'info', - }), - ], - }), - ], -}) diff --git a/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/primarySchoolSection/newSchoolSubSection.ts b/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/primarySchoolSection/newSchoolSubSection.ts index 4abd6c056210..aaf68f1bee55 100644 --- a/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/primarySchoolSection/newSchoolSubSection.ts +++ b/libs/application/templates/new-primary-school/src/forms/NewPrimarySchoolForm/primarySchoolSection/newSchoolSubSection.ts @@ -1,11 +1,18 @@ import { buildAsyncSelectField, + buildHiddenInputWithWatchedValue, buildMultiField, buildSubSection, + coreErrorMessages, } from '@island.is/application/core' import { ReasonForApplicationOptions } from '../../../lib/constants' import { newPrimarySchoolMessages } from '../../../lib/messages' -import { getApplicationAnswers } from '../../../lib/newPrimarySchoolUtils' +import { + getApplicationAnswers, + getApplicationExternalData, +} from '../../../lib/newPrimarySchoolUtils' +import { FriggSchoolsByMunicipalityQuery } from '../../../types/schema' +import { friggSchoolsByMunicipalityQuery } from '../../../graphql/queries' export const newSchoolSubSection = buildSubSection({ id: 'newSchoolSubSection', @@ -23,47 +30,68 @@ export const newSchoolSubSection = buildSubSection({ buildAsyncSelectField({ id: 'schools.newSchool.municipality', title: newPrimarySchoolMessages.shared.municipality, - // TODO: get data from Juni + placeholder: newPrimarySchoolMessages.shared.municipalityPlaceholder, + loadingError: coreErrorMessages.failedDataProvider, + dataTestId: 'new-school-municipality', loadOptions: async ({ apolloClient }) => { - return [{ value: 'Reykjavík', label: 'Reykjavík' }] - /*const { municipalities } = getApplicationExternalData( - application.externalData, - ) + const { data } = + await apolloClient.query({ + query: friggSchoolsByMunicipalityQuery, + }) - return municipalities.map( - (municipality: NationalRegistryMunicipality) => ({ - value: municipality?.code || '', - label: municipality.name || '', - }), - )*/ + return ( + data?.friggSchoolsByMunicipality?.map((municipality) => ({ + value: municipality.name, + label: municipality.name, + })) ?? [] + ) }, - - placeholder: newPrimarySchoolMessages.shared.municipalityPlaceholder, - dataTestId: 'new-school-municipality', }), - buildAsyncSelectField({ id: 'schools.newSchool.school', title: newPrimarySchoolMessages.shared.school, - condition: (answers) => { - const { schoolMunicipality } = getApplicationAnswers(answers) - return !!schoolMunicipality - }, - // TODO: get data from Juni - loadOptions: async ({ apolloClient }) => { - return [ - { - value: 'Ártúnsskóli', - label: 'Ártúnsskóli', - }, - { - value: 'Árbæjarskóli', - label: 'Árbæjarskóli', - }, - ] - }, placeholder: newPrimarySchoolMessages.shared.schoolPlaceholder, + loadingError: coreErrorMessages.failedDataProvider, dataTestId: 'new-school-school', + loadOptions: async ({ application, apolloClient }) => { + const { schoolMunicipality } = getApplicationAnswers( + application.answers, + ) + const { childGradeLevel } = getApplicationExternalData( + application.externalData, + ) + + const { data } = + await apolloClient.query({ + query: friggSchoolsByMunicipalityQuery, + }) + + return ( + data?.friggSchoolsByMunicipality + ?.find(({ name }) => name === schoolMunicipality) + ?.children?.filter((school) => + school.gradeLevels?.includes(childGradeLevel), + ) + ?.map((school) => ({ + value: school.name, + label: school.name, + })) ?? [] + ) + }, + condition: (answers) => { + const { schoolMunicipality, newSchoolHiddenInput } = + getApplicationAnswers(answers) + + return ( + !!schoolMunicipality && + schoolMunicipality === newSchoolHiddenInput + ) + }, + }), + buildHiddenInputWithWatchedValue({ + // Needed to trigger an update on loadOptions in the async select above + id: 'schools.newSchool.hiddenInput', + watchValue: 'schools.newSchool.municipality', }), ], }), diff --git a/libs/application/templates/new-primary-school/src/forms/Prerequisites.ts b/libs/application/templates/new-primary-school/src/forms/Prerequisites.ts deleted file mode 100644 index ede49c5d1d6f..000000000000 --- a/libs/application/templates/new-primary-school/src/forms/Prerequisites.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { - buildDataProviderItem, - buildExternalDataProvider, - buildForm, - buildSection, - buildSubmitField, -} from '@island.is/application/core' -import { - ChildrenCustodyInformationApi, - DefaultEvents, - Form, - FormModes, - NationalRegistryUserApi, - UserProfileApi, -} from '@island.is/application/types' -import { newPrimarySchoolMessages } from '../lib/messages' - -export const Prerequisites: Form = buildForm({ - id: 'newPrimarySchoolPrerequisites', - title: newPrimarySchoolMessages.shared.formTitle, - mode: FormModes.NOT_STARTED, - renderLastScreenButton: true, - children: [ - buildSection({ - id: 'prerequisites', - title: newPrimarySchoolMessages.pre.externalDataSection, - children: [ - buildExternalDataProvider({ - id: 'approveExternalData', - title: newPrimarySchoolMessages.pre.externalDataSection, - subTitle: newPrimarySchoolMessages.pre.externalDataDescription, - checkboxLabel: newPrimarySchoolMessages.pre.checkboxProvider, - submitField: buildSubmitField({ - id: 'submit', - placement: 'footer', - title: '', - refetchApplicationAfterSubmit: true, - actions: [ - { - event: DefaultEvents.SUBMIT, - name: newPrimarySchoolMessages.pre.startApplication, - type: 'primary', - }, - ], - }), - dataProviders: [ - buildDataProviderItem({ - provider: NationalRegistryUserApi, - title: - newPrimarySchoolMessages.pre.nationalRegistryInformationTitle, - subTitle: - newPrimarySchoolMessages.pre - .nationalRegistryInformationSubTitle, - }), - buildDataProviderItem({ - provider: ChildrenCustodyInformationApi, - title: '', - subTitle: '', - }), - buildDataProviderItem({ - provider: UserProfileApi, - title: newPrimarySchoolMessages.pre.userProfileInformationTitle, - subTitle: - newPrimarySchoolMessages.pre.userProfileInformationSubTitle, - }), - ], - }), - ], - }), - ], -}) diff --git a/libs/application/templates/new-primary-school/src/forms/Prerequisites/childrenSubSection.ts b/libs/application/templates/new-primary-school/src/forms/Prerequisites/childrenSubSection.ts new file mode 100644 index 000000000000..25989a1c2999 --- /dev/null +++ b/libs/application/templates/new-primary-school/src/forms/Prerequisites/childrenSubSection.ts @@ -0,0 +1,55 @@ +import { + buildMultiField, + buildRadioField, + buildSubSection, + buildSubmitField, +} from '@island.is/application/core' +import { DefaultEvents } from '@island.is/application/types' +import { format as formatKennitala } from 'kennitala' +import { newPrimarySchoolMessages } from '../../lib/messages' +import { getApplicationExternalData } from '../../lib/newPrimarySchoolUtils' + +export const childrenSubSection = buildSubSection({ + id: 'childrenSubSection', + title: newPrimarySchoolMessages.pre.childrenSubSectionTitle, + children: [ + buildMultiField({ + id: 'childrenMultiField', + title: newPrimarySchoolMessages.pre.childrenSubSectionTitle, + description: newPrimarySchoolMessages.pre.childrenDescription, + children: [ + buildRadioField({ + id: 'childNationalId', + title: newPrimarySchoolMessages.pre.childrenRadioTitle, + options: (application) => { + const { children } = getApplicationExternalData( + application.externalData, + ) + + return children.map((child) => { + return { + value: child.nationalId, + label: child.fullName, + subLabel: formatKennitala(child.nationalId), + } + }) + }, + required: true, + }), + buildSubmitField({ + id: 'submit', + placement: 'footer', + title: '', + refetchApplicationAfterSubmit: true, + actions: [ + { + event: DefaultEvents.SUBMIT, + name: newPrimarySchoolMessages.pre.startApplication, + type: 'primary', + }, + ], + }), + ], + }), + ], +}) diff --git a/libs/application/templates/new-primary-school/src/forms/Prerequisites/externalDataSubSection.ts b/libs/application/templates/new-primary-school/src/forms/Prerequisites/externalDataSubSection.ts new file mode 100644 index 000000000000..46a2135c0703 --- /dev/null +++ b/libs/application/templates/new-primary-school/src/forms/Prerequisites/externalDataSubSection.ts @@ -0,0 +1,54 @@ +import { + buildDataProviderItem, + buildExternalDataProvider, + buildSubSection, +} from '@island.is/application/core' +import { + NationalRegistryUserApi, + UserProfileApi, +} from '@island.is/application/types' +import { + ChildrenApi, + GetKeyOptionsTypesApi, + OptionsApi, +} from '../../dataProviders' +import { newPrimarySchoolMessages } from '../../lib/messages' + +export const externalDataSubSection = buildSubSection({ + id: 'externalDataSubSection', + title: newPrimarySchoolMessages.pre.externalDataSubSection, + children: [ + buildExternalDataProvider({ + id: 'approveExternalData', + title: newPrimarySchoolMessages.pre.externalDataSubSection, + subTitle: newPrimarySchoolMessages.pre.externalDataDescription, + checkboxLabel: newPrimarySchoolMessages.pre.checkboxProvider, + dataProviders: [ + buildDataProviderItem({ + provider: NationalRegistryUserApi, + title: newPrimarySchoolMessages.pre.nationalRegistryInformationTitle, + subTitle: + newPrimarySchoolMessages.pre.nationalRegistryInformationSubTitle, + }), + buildDataProviderItem({ + provider: ChildrenApi, + title: '', + subTitle: '', + }), + buildDataProviderItem({ + provider: UserProfileApi, + title: newPrimarySchoolMessages.pre.userProfileInformationTitle, + subTitle: newPrimarySchoolMessages.pre.userProfileInformationSubTitle, + }), + buildDataProviderItem({ + provider: GetKeyOptionsTypesApi, + title: 'KeyOptionsTypes', + }), + buildDataProviderItem({ + provider: OptionsApi, + title: 'Options', + }), + ], + }), + ], +}) diff --git a/libs/application/templates/new-primary-school/src/forms/Prerequisites/index.ts b/libs/application/templates/new-primary-school/src/forms/Prerequisites/index.ts new file mode 100644 index 000000000000..2ea1457ce5f4 --- /dev/null +++ b/libs/application/templates/new-primary-school/src/forms/Prerequisites/index.ts @@ -0,0 +1,20 @@ +import { buildForm, buildSection } from '@island.is/application/core' +import { Form, FormModes } from '@island.is/application/types' +import { newPrimarySchoolMessages } from '../../lib/messages' +import { childrenSubSection } from './childrenSubSection' +import { externalDataSubSection } from './externalDataSubSection' + +export const Prerequisites: Form = buildForm({ + id: 'newPrimarySchoolPrerequisites', + title: newPrimarySchoolMessages.shared.formTitle, + mode: FormModes.NOT_STARTED, + renderLastScreenButton: true, + renderLastScreenBackButton: true, + children: [ + buildSection({ + id: 'prerequisites', + title: newPrimarySchoolMessages.pre.externalDataSection, + children: [externalDataSubSection, childrenSubSection], + }), + ], +}) diff --git a/libs/application/templates/new-primary-school/src/graphql/queries.ts b/libs/application/templates/new-primary-school/src/graphql/queries.ts index 0cbfc1ac8157..f27c705e30a7 100644 --- a/libs/application/templates/new-primary-school/src/graphql/queries.ts +++ b/libs/application/templates/new-primary-school/src/graphql/queries.ts @@ -15,3 +15,21 @@ export const friggOptionsQuery = gql` } } ` + +export const friggSchoolsByMunicipalityQuery = gql` + query FriggSchoolsByMunicipality { + friggSchoolsByMunicipality { + id + nationalId + name + type + children { + id + nationalId + name + type + gradeLevels + } + } + } +` diff --git a/libs/application/templates/new-primary-school/src/hooks/useFriggOptions.ts b/libs/application/templates/new-primary-school/src/hooks/useFriggOptions.ts new file mode 100644 index 000000000000..0b277a9054f2 --- /dev/null +++ b/libs/application/templates/new-primary-school/src/hooks/useFriggOptions.ts @@ -0,0 +1,28 @@ +import { useQuery } from '@apollo/client' +import { useLocale } from '@island.is/localization' +import { friggOptionsQuery } from '../graphql/queries' +import { OptionsType } from '../lib/constants' +import { FriggOptionsQuery } from '../types/schema' + +export const useFriggOptions = (type?: OptionsType) => { + const { lang } = useLocale() + const { data } = useQuery(friggOptionsQuery, { + variables: { + type: { + type, + }, + }, + }) + + return ( + data?.friggOptions?.flatMap(({ options }) => + options.flatMap(({ value, key }) => { + let content = value.find(({ language }) => language === lang)?.content + if (!content) { + content = value.find(({ language }) => language === 'is')?.content + } + return { value: key ?? '', label: content ?? '' } + }), + ) ?? [] + ) +} diff --git a/libs/application/templates/new-primary-school/src/lib/NewPrimarySchoolTemplate.ts b/libs/application/templates/new-primary-school/src/lib/NewPrimarySchoolTemplate.ts index ead983048ca9..25f5094d37a1 100644 --- a/libs/application/templates/new-primary-school/src/lib/NewPrimarySchoolTemplate.ts +++ b/libs/application/templates/new-primary-school/src/lib/NewPrimarySchoolTemplate.ts @@ -12,15 +12,26 @@ import { ApplicationStateSchema, ApplicationTemplate, ApplicationTypes, - ChildrenCustodyInformationApi, DefaultEvents, NationalRegistryUserApi, UserProfileApi, + defineTemplateApi, } from '@island.is/application/types' import { Features } from '@island.is/feature-flags' import unset from 'lodash/unset' import { assign } from 'xstate' -import { Events, ReasonForApplicationOptions, Roles, States } from './constants' +import { + ChildrenApi, + GetKeyOptionsTypesApi, + OptionsApi, +} from '../dataProviders' +import { + ApiModuleActions, + Events, + ReasonForApplicationOptions, + Roles, + States, +} from './constants' import { dataSchema } from './dataSchema' import { newPrimarySchoolMessages, statesMessages } from './messages' import { getApplicationAnswers } from './newPrimarySchoolUtils' @@ -51,11 +62,16 @@ const NewPrimarySchoolTemplate: ApplicationTemplate< displayStatus: 'success', }, }, + onExit: defineTemplateApi({ + action: ApiModuleActions.getChildInformation, + externalDataId: 'childInformation', + throwOnError: true, + }), roles: [ { id: Roles.APPLICANT, formLoader: () => - import('../forms/Prerequisites').then((val) => + import('../forms/Prerequisites/index').then((val) => Promise.resolve(val.Prerequisites), ), actions: [ @@ -68,9 +84,11 @@ const NewPrimarySchoolTemplate: ApplicationTemplate< write: 'all', delete: true, api: [ - ChildrenCustodyInformationApi, NationalRegistryUserApi, UserProfileApi, + GetKeyOptionsTypesApi, + OptionsApi, + ChildrenApi, ], }, ], @@ -85,7 +103,6 @@ const NewPrimarySchoolTemplate: ApplicationTemplate< 'clearPlaceOfResidence', 'clearLanguages', 'clearAllergiesAndIntolerances', - 'clearPublication', ], meta: { name: States.DRAFT, @@ -166,8 +183,6 @@ const NewPrimarySchoolTemplate: ApplicationTemplate< unset(application.answers, 'siblings') unset(application.answers, 'languages') unset(application.answers, 'startDate') - unset(application.answers, 'photography') - unset(application.answers, 'allergiesAndIntolerances') } else { // Clear movingAbroad if "Moving abroad" is not selected as reason for application unset(application.answers, 'reasonForApplication.movingAbroad') @@ -214,38 +229,6 @@ const NewPrimarySchoolTemplate: ApplicationTemplate< } return context }), - /** - * If the user changes his answers, - * clear selected food allergies and intolerances. - */ - clearAllergiesAndIntolerances: assign((context) => { - const { application } = context - const { hasFoodAllergies, hasFoodIntolerances } = getApplicationAnswers( - application.answers, - ) - - if (hasFoodAllergies?.length === 0) { - unset(application.answers, 'allergiesAndIntolerances.foodAllergies') - } - if (hasFoodIntolerances?.length === 0) { - unset( - application.answers, - 'allergiesAndIntolerances.foodIntolerances', - ) - } - return context - }), - clearPublication: assign((context) => { - const { application } = context - const { photographyConsent } = getApplicationAnswers( - application.answers, - ) - if (photographyConsent === NO) { - unset(application.answers, 'photography.photoSchoolPublication') - unset(application.answers, 'photography.photoMediaPublication') - } - return context - }), }, }, diff --git a/libs/application/templates/new-primary-school/src/lib/constants.ts b/libs/application/templates/new-primary-school/src/lib/constants.ts index ab0132cfb1c4..efb5dea44ee6 100644 --- a/libs/application/templates/new-primary-school/src/lib/constants.ts +++ b/libs/application/templates/new-primary-school/src/lib/constants.ts @@ -16,21 +16,12 @@ export type Events = | { type: DefaultEvents.ASSIGN } | { type: DefaultEvents.EDIT } -export enum Roles { - APPLICANT = 'applicant', -} - -export type Option = { - value: string - label: string +export enum ApiModuleActions { + getChildInformation = 'getChildInformation', } -export enum RelationOptions { - GRANDPARENT = 'grandparent', - SIBLING = 'sibling', - STEPPARENT = 'stepparent', - RELATIVE = 'relative', - FRIEND_OR_OTHER = 'friendOrOther', +export enum Roles { + APPLICANT = 'applicant', } export enum ReasonForApplicationOptions { @@ -52,30 +43,27 @@ export enum SiblingRelationOptions { STEP_SIBLING = 'stepSibling', } -export enum FoodAllergiesOptions { - EGG_ALLERGY = 'eggAllergy', - FISH_ALLERGY = 'fishAllergy', - PENUT_ALLERGY = 'peanutAllergy', - WHEAT_ALLERGY = 'wheatAllergy', - MILK_ALLERGY = 'milkAllergy', - OTHER = 'other', -} - -export enum FoodIntolerancesOptions { - LACTOSE_INTOLERANCE = 'lactoseIntolerance', - GLUTEN_INTOLERANCE = 'glutenIntolerance', - MSG_INTOLERANCE = 'msgIntolerance', - OTHER = 'other', +export enum OptionsType { + PRONOUN = 'pronoun', + GENDER = 'gender', + INTOLERANCE = 'intolerence', + REASON = 'rejectionReason', + RELATION = 'relation', + ALLERGY = 'allergy', } -export enum Gender { - FEMALE = 'FEMALE', - MALE = 'MALE', - OTHER = 'OTHER', +export enum MembershipRole { + Admin = 'admin', + Guardian = 'guardian', + Parent = 'parent', + Principal = 'principal', + Relative = 'relative', + Student = 'student', + Teacher = 'teacher', } -export enum OptionsType { - ALLERGRY = 'allergy', - INTOLERANCE = 'intolerence', - REASON = 'rejectionReason', +export enum MembershipOrganizationType { + Municipality = 'municipality', + National = 'national', + School = 'school', } diff --git a/libs/application/templates/new-primary-school/src/lib/dataSchema.ts b/libs/application/templates/new-primary-school/src/lib/dataSchema.ts index 7c38dc235935..54f61828ba0e 100644 --- a/libs/application/templates/new-primary-school/src/lib/dataSchema.ts +++ b/libs/application/templates/new-primary-school/src/lib/dataSchema.ts @@ -3,12 +3,8 @@ import * as kennitala from 'kennitala' import { parsePhoneNumberFromString } from 'libphonenumber-js' import { z } from 'zod' import { - FoodAllergiesOptions, - FoodIntolerancesOptions, ReasonForApplicationOptions, - RelationOptions, SiblingRelationOptions, - Gender, } from './constants' import { errorMessages } from './messages' @@ -28,7 +24,8 @@ export const dataSchema = z.object({ childNationalId: z.string().min(1), childInfo: z .object({ - gender: z.nativeEnum(Gender).optional(), + preferredName: z.string().optional(), + pronouns: z.array(z.string()).optional(), differentPlaceOfResidence: z.enum([YES, NO]), placeOfResidence: z .object({ @@ -71,7 +68,7 @@ export const dataSchema = z.object({ nationalId: z.string().refine((n) => kennitala.isValid(n), { params: errorMessages.nationalId, }), - relation: z.nativeEnum(RelationOptions), + relation: z.string(), }), ) .refine((r) => r === undefined || r.length > 0, { @@ -123,6 +120,7 @@ export const dataSchema = z.object({ ), schools: z.object({ newSchool: z.object({ + municipality: z.string(), school: z.string(), }), }), @@ -156,61 +154,11 @@ export const dataSchema = z.object({ params: errorMessages.languagesRequired, }, ), - allergiesAndIntolerances: z - .object({ - hasFoodAllergies: z.array(z.string()), - hasFoodIntolerances: z.array(z.string()), - foodAllergies: z.array(z.nativeEnum(FoodAllergiesOptions)).optional(), - foodIntolerances: z - .array(z.nativeEnum(FoodIntolerancesOptions)) - .optional(), - isUsingEpiPen: z.array(z.string()), - }) - .refine( - ({ hasFoodAllergies, foodAllergies }) => - hasFoodAllergies.includes(YES) - ? !!foodAllergies && foodAllergies.length > 0 - : true, - { - path: ['foodAllergies'], - params: errorMessages.foodAllergyRequired, - }, - ) - .refine( - ({ hasFoodIntolerances, foodIntolerances }) => - hasFoodIntolerances.includes(YES) - ? !!foodIntolerances && foodIntolerances.length > 0 - : true, - { - path: ['foodIntolerances'], - params: errorMessages.foodIntoleranceRequired, - }, - ), support: z.object({ developmentalAssessment: z.enum([YES, NO]), specialSupport: z.enum([YES, NO]), requestMeeting: z.array(z.enum([YES, NO])).optional(), }), - photography: z - .object({ - photographyConsent: z.enum([YES, NO]), - photoSchoolPublication: z.enum([YES, NO]).optional(), - photoMediaPublication: z.enum([YES, NO]).optional(), - }) - .refine( - ({ photographyConsent, photoSchoolPublication }) => - photographyConsent === YES ? !!photoSchoolPublication : true, - { - path: ['photoSchoolPublication'], - }, - ) - .refine( - ({ photographyConsent, photoMediaPublication }) => - photographyConsent === YES ? !!photoMediaPublication : true, - { - path: ['photoMediaPublication'], - }, - ), }) export type SchemaFormValues = z.infer diff --git a/libs/application/templates/new-primary-school/src/lib/messages.ts b/libs/application/templates/new-primary-school/src/lib/messages.ts index 904236f680a5..a58e62619e0e 100644 --- a/libs/application/templates/new-primary-school/src/lib/messages.ts +++ b/libs/application/templates/new-primary-school/src/lib/messages.ts @@ -105,26 +105,16 @@ export const newPrimarySchoolMessages: MessageDir = { defaultMessage: 'Veldu skóla', description: 'Select school', }, - male: { - id: 'dess.nps.application:gender.male', - defaultMessage: 'Karlkyns', - description: 'Male', - }, - female: { - id: 'dess.nps.application:gender.female', - defaultMessage: 'Kvenkyns', - description: 'Female', - }, - otherGender: { - id: 'dess.nps.application:gender.other', - defaultMessage: 'Kynsegin/Annað', - description: 'non-binary/Other', - }, }), pre: defineMessages({ externalDataSection: { id: 'dess.nps.application:external.data.section', + defaultMessage: 'Forsendur', + description: 'Prerequisites', + }, + externalDataSubSection: { + id: 'dess.nps.application:external.data.sub.section', defaultMessage: 'Gagnaöflun', description: 'Data collection', }, @@ -167,31 +157,31 @@ export const newPrimarySchoolMessages: MessageDir = { defaultMessage: 'Hefja umsókn', description: 'Start application', }, - }), - - childrenNParents: defineMessages({ - sectionTitle: { - id: 'dess.nps.application:childrenNParents.section.title', - defaultMessage: 'Börn og foreldrar', - description: 'Children and parents', - }, // Children childrenSubSectionTitle: { - id: 'dess.nps.application:childrenNParents.children.sub.section.title', + id: 'dess.nps.application:prerequisites.children.sub.section.title', defaultMessage: 'Börn', description: 'Children', }, childrenDescription: { - id: 'dess.nps.application:childrenNParents.childrenDescription#markdown', + id: 'dess.nps.application:prerequisites.childrenDescription#markdown', defaultMessage: `Samkvæmt uppflettingu í Þjóðskrá hefur þú forsjá með eftirfarandi barni/börnum. Ef þú sérð ekki barnið þitt hér, þá bendum við þér að hafa samband við Þjóðskrá. \n\nAthugaðu að einungis er hægt að sækja um fyrir eitt barn í einu. Ef skrá á tvö börn svo sem tvíbura er hægt að fara beint í að skrá annað barn þegar búið er að skrá það fyrra.`, description: `According to the Registers Iceland database you have the following children. If you do not see your child in this process, please contact the Registers Iceland. \n\nPlease note that you can only apply for one child at a time. If you have two children, such as twins, you can proceed to register the second child directly after completing the registration for the first one.`, }, childrenRadioTitle: { - id: 'dess.nps.application:childrenNParents.childrenRadioTitle', + id: 'dess.nps.application:prerequisites.childrenRadioTitle', defaultMessage: 'Veldu barn fyrir umsóknina', description: 'Select child for the application', }, + }), + + childrenNParents: defineMessages({ + sectionTitle: { + id: 'dess.nps.application:childrenNParents.section.title', + defaultMessage: 'Börn og foreldrar', + description: 'Children and parents', + }, // Child information childInfoSubSectionTitle: { @@ -210,20 +200,20 @@ export const newPrimarySchoolMessages: MessageDir = { 'Athugaðu hvort upplýsingarnar séu réttar áður en þú heldur áfram.', description: 'Check that the information is correct before proceeding.', }, - childInfoChosenName: { - id: 'dess.nps.application:childrenNParents.child.info.chosen.name', + childInfoPreferredName: { + id: 'dess.nps.application:childrenNParents.child.info.preferred.name', defaultMessage: 'Valið nafn', description: 'Preferred name', }, - childInfoGender: { - id: 'dess.nps.application:childrenNParents.child.info.gender', - defaultMessage: 'Kyn', - description: 'Gender', + childInfoPronouns: { + id: 'dess.nps.application:childrenNParents.child.info.pronouns', + defaultMessage: 'Fornafn', + description: 'Pronoun', }, - childInfoGenderPlaceholder: { - id: 'dess.nps.application:childrenNParents.child.info.gender.placeholder', - defaultMessage: 'Veldu kyn', - description: 'Select gender', + childInfoPronounsPlaceholder: { + id: 'dess.nps.application:childrenNParents.child.info.pronouns.placeholder', + defaultMessage: 'Veldu fornafn', + description: 'Select pronoun', }, differentPlaceOfResidence: { id: 'dess.nps.application:childrenNParents.child.info.different.place.of.residence', @@ -299,41 +289,6 @@ export const newPrimarySchoolMessages: MessageDir = { defaultMessage: 'Eyða aðstandanda', description: 'Remove relative', }, - relativesRelationGrandparent: { - id: 'dess.nps.application:childrenNParents.relatives.relation.grandparent', - defaultMessage: 'Afi/amma', - description: 'Grandparent', - }, - relativesRelationSibling: { - id: 'dess.nps.application:childrenNParents.relatives.relation.sibling', - defaultMessage: 'Systkini', - description: 'Sibling', - }, - relativesRelationStepparent: { - id: 'dess.nps.application:childrenNParents.relatives.relation.stepparent', - defaultMessage: 'Stjúpforeldri', - description: 'Stepparent', - }, - relativesRelationRelative: { - id: 'dess.nps.application:childrenNParents.relatives.relation.relative', - defaultMessage: 'Frændfólk', - description: 'Relative', - }, - relativesRelationFriendOrOther: { - id: 'dess.nps.application:childrenNParents.relatives.relation.friend.or.other', - defaultMessage: 'Vinafólk/annað', - description: 'Friend/other', - }, - relativesCanPickUpChild: { - id: 'dess.nps.application:childrenNParents.relatives.can.pick.up.child', - defaultMessage: 'Má sækja barn í skólann', - description: 'Can pick up the child from school', - }, - relativesCanPickUpChildTableHeader: { - id: 'dess.nps.application:childrenNParents.relatives.can.pick.up.child.table.header', - defaultMessage: 'Má sækja barn', - description: 'Can pick up the child', - }, }), primarySchool: defineMessages({ @@ -546,112 +501,6 @@ export const newPrimarySchoolMessages: MessageDir = { "Icelandic is not spoken in the child's immediate environment", }, - // Allergies and intolerances - allergiesAndIntolerancesSubSectionTitle: { - id: 'dess.nps.application:different.needs.allergies.and.intolerances.sub.section.title', - defaultMessage: 'Ofnæmi og óþol', - description: 'Allergies and intolerances', - }, - foodAllergiesAndIntolerancesTitle: { - id: 'dess.nps.application:different.needs.food.allergies.and.intolerances.title', - defaultMessage: 'Fæðuofnæmi og -óþol', - description: 'Food allergies and intolerances', - }, - foodAllergiesAndIntolerancesDescription: { - id: 'dess.nps.application:different.needs.food.allergies.and.intolerances.description', - defaultMessage: - 'Er barnið með fæðuofnæmi eða -óþol sem starfsfólk skóla þarf að vera meðvitað um?', - description: - 'Does the child have food allergies or intolerances that the school staff need to be aware of?', - }, - childHasFoodAllergies: { - id: 'dess.nps.application:different.needs.child.has.food.allergies', - defaultMessage: 'Barnið er með fæðuofnæmi', - description: 'Child has food allergies', - }, - typeOfAllergies: { - id: 'dess.nps.application:different.needs.type.of.allergies', - defaultMessage: 'Tegund ofnæmis', - description: 'Type of allergies', - }, - typeOfAllergiesPlaceholder: { - id: 'dess.nps.application:different.needs.type.of.allergies.placeholder', - defaultMessage: 'Veldu tegund ofnæmis', - description: 'Select type of allergies', - }, - confirmFoodAllergiesAlertMessage: { - id: 'dess.nps.application:different.needs.confirm.food.allergies.alert.message', - defaultMessage: - 'Athugið að skóli mun krefjast vottorðs frá lækni til staðfestingar á fæðuofnæmi.', - description: - "Please note that the school will require a doctor's certificate to confirm food allergies.", - }, - childHasFoodIntolerances: { - id: 'dess.nps.application:different.needs.child.has.food.intolerances', - defaultMessage: 'Barnið er með fæðuóþol', - description: 'Child has food intolerances', - }, - typeOfIntolerances: { - id: 'dess.nps.application:different.needs.type.of.intolerances', - defaultMessage: 'Tegund óþols', - description: 'Type of intolerances', - }, - typeOfIntolerancesPlaceholder: { - id: 'dess.nps.application:different.needs.type.of.intolerances.placeholder', - defaultMessage: 'Veldu tegund óþols', - description: 'Select type of intolerances', - }, - usesEpinephrinePen: { - id: 'dess.nps.application:different.needs.uses.epinephrine.pen', - defaultMessage: 'Notar adrenalínpenna', - description: 'Uses epinephrine pen', - }, - eggAllergy: { - id: 'dess.nps.application:different.needs.egg.allergy', - defaultMessage: 'Eggjaofnæmi', - description: 'Egg allergy', - }, - fishAllergy: { - id: 'dess.nps.application:different.needs.fish.allergy', - defaultMessage: 'Fiskiofnæmi', - description: 'Fish allergy', - }, - nutAllergy: { - id: 'dess.nps.application:different.needs.nut.allergy', - defaultMessage: 'Hnetuofnæmi', - description: 'Nut allergy', - }, - wheatAllergy: { - id: 'dess.nps.application:different.needs.wheat.allergy', - defaultMessage: 'Hveitiofnæmi', - description: 'Wheat allergy', - }, - milkAllergy: { - id: 'dess.nps.application:different.needs.milk.allergy', - defaultMessage: 'Mjólkurofnæmi', - description: 'Milk allergy', - }, - other: { - id: 'dess.nps.application:different.needs.other', - defaultMessage: 'Annað', - description: 'Other', - }, - lactoseIntolerance: { - id: 'dess.nps.application:different.needs.lactose.intolerance', - defaultMessage: 'Mjólkursykuróþol', - description: 'Lactose intolerance', - }, - glutenIntolerance: { - id: 'dess.nps.application:different.needs.gluten.intolerance', - defaultMessage: 'Glútenóþol', - description: 'Gluten intolerance', - }, - msgIntolerance: { - id: 'dess.nps.application:different.needs.msg.intolerance', - defaultMessage: 'MSG-óþol', - description: 'MSG intolerance', - }, - // Support supportSubSectionTitle: { id: 'dess.nps.application:different.needs.support.sub.section.title', @@ -696,55 +545,6 @@ export const newPrimarySchoolMessages: MessageDir = { defaultMessage: 'Óska eftir samtali við skóla', description: 'Request meeting with the school', }, - - // Use of footage - useOfFootageSubSectionTitle: { - id: 'dess.nps.application:different.needs.use.of.footage.sub.section.title', - defaultMessage: 'Notkun myndefnis', - description: 'Use of footage', - }, - photography: { - id: 'dess.nps.application:different.needs.photography', - defaultMessage: - 'Samþykki vegna myndatöku, myndbandsupptöku og birtingu myndefnis grunnskóla', - description: - 'Consent for photography, video recording and publication of elementary school footage', - }, - photographyDescription: { - id: 'dess.nps.application:different.needs.photography.description', - defaultMessage: - 'Þegar kemur að myndatöku og myndbirtingu skal virða sjálfsákvörðunarrétt barna og ungmenna og taka tillit til skoðana og viðhorfa þeirra í samræmi við aldur og þroska.', - description: - 'When it comes to taking pictures and publishing pictures, the right of self-determination of children and young people must be respected and their views and attitudes taken into account in accordance with their age and maturity.', - }, - photographyConsent: { - id: 'dess.nps.application:different.needs.photography.consent', - defaultMessage: - 'Er heimilt að taka ljósmyndir/myndbönd af barni þínu í daglegu skólastarfi?', - description: - 'Is it allowed to take photos/videos of your child during daily school activities?', - }, - photoSchoolPublication: { - id: 'dess.nps.application:different.needs.photo.school.publication', - defaultMessage: - 'Má birta myndefni á vettvangi skólans svo sem á vefsíðu hans, í fréttabréfi, samfélagsmiðlum og kynningarefni?', - description: - "Can footage be published on the school's website, in the newsletter, social media and promotional materials?", - }, - photoMediaPublication: { - id: 'dess.nps.application:different.needs.photo.media.publication', - defaultMessage: - 'Má birta myndefni hjá þriðja aðila svo sem í fjölmiðlum?', - description: - 'Can footage be published by third parties such as in the media?', - }, - photographyInfo: { - id: 'dess.nps.application:different.needs.photography.info', - defaultMessage: - 'Ekki er heimilt að nota myndefni í öðrum tilgangi en samþykki nær til.\n\nEf myndefni er notað í öðrum tilgangi, eða myndataka er fyrirhuguð í öðrum tilgangi en samþykki nær til, verða foreldrar upplýstir sérstaklega og sérstaks samþykkis aflað, af viðkomandi skóla.\n\nForeldri getur afturkallað samþykki sitt með því að hafa samband við skóla. Afturköllun hefur þó ekki áhrif á lögmæti þeirrar myndatöku og myndbirtingar sem fram hefur farið fram að þeim tíma.\n\nHver og einn skóli er ábyrgðaraðili vegna persónuupplýsinga sem þar eru unnar. Frekari leiðbeiningar og fræðsla um mynda- og myndbandstökur sem og myndbirtingar má finna á vef viðkomandi sveitarfélags.', - description: - 'It is not allowed to use visual material for any purpose other than what has been approved.\n\nIf visual material is used for a purpose other than what has been approved, or if photography is intended for a purpose other than what has been approved, parents will be informed specifically and a separate consent will be obtained from the relevant school.\n\nA parent can revoke their consent by contacting the school. However, revocation does not affect the legality of any photography or publication that has already taken place up to that time.\n\nEach school is responsible for the personal information processed there. Further guidance and education on photography and publication, as well as image processing, can be found on the website of the relevant municipality.', - }, }), overview: defineMessages({ @@ -754,7 +554,7 @@ export const newPrimarySchoolMessages: MessageDir = { description: 'Overview', }, overviewTitle: { - id: 'dess.nps.application:confirmation.overview.title', + id: 'dess.nps.application:overview.title', defaultMessage: 'Yfirlit', description: 'Overview', }, @@ -794,40 +594,30 @@ export const newPrimarySchoolMessages: MessageDir = { defaultMessage: 'Íslenska er töluð í nærumhverfi barnsins', description: "Icelandic is spoken in the child's immediate environment", }, - foodAllergies: { - id: 'dess.nps.application:overview.food.allergies', - defaultMessage: 'Fæðuofnæmi', - description: 'Food allergies', - }, - foodIntolerances: { - id: 'dess.nps.application:overview.food.intolerances', - defaultMessage: 'Fæðuóþol', - description: 'Food intolerances', - }, - usesEpinephrinePen: { - id: 'dess.nps.application:overview.uses.epinephrine.pen', - defaultMessage: 'Notar adrenalínpenna', - description: 'Uses an epinephrine pen', - }, schoolTitle: { - id: 'dess.nps.application:review.school.title', + id: 'dess.nps.application:overview.school.title', defaultMessage: 'Upplýsingar um skóla', description: 'Information about school', }, currentSchool: { - id: 'dess.nps.application:confirm.current.school', + id: 'dess.nps.application:overview.current.school', defaultMessage: 'Núverandi skóli', description: 'Current school', }, selectedSchool: { - id: 'dess.nps.application:confirm.selected.school', + id: 'dess.nps.application:overview.selected.school', defaultMessage: 'Valinn skóli', description: 'Selected school', }, - class: { - id: 'dess.nps.application:confirm.class', + grade: { + id: 'dess.nps.application:overview.grade', defaultMessage: 'Bekkur', - description: 'Class', + description: 'Grade', + }, + currentGrade: { + id: 'dess.nps.application:overview.current.grade', + defaultMessage: '{grade}. bekkur', + description: '{grade} grade', }, }), @@ -899,14 +689,17 @@ export const errorMessages = defineMessages({ defaultMessage: 'Það þarf að velja a.m.k eitt tungumál', description: 'At least one language must be selected', }, - foodAllergyRequired: { - id: 'dess.nps.application:error.food.allergy.required', - defaultMessage: 'Það þarf að velja a.m.k eitt fæðuofnæmi', - description: 'At least one food allergy must be selected', + noChildrenFoundTitle: { + id: 'dess.nps.application:error.no.children.found.title', + defaultMessage: 'Því miður ert þú ekki með skráð barn á grunnskólaaldri', + description: + 'Unfortunately, you do not have a child registered at primary school age', }, - foodIntoleranceRequired: { - id: 'dess.nps.application:error.food.intolerance.required', - defaultMessage: 'Það þarf að velja a.m.k eitt fæðuóþol', - description: 'At least one food intolerance must be selected', + noChildrenFoundMessage: { + id: 'dess.nps.application:error.no.children.found.message#markdown', + defaultMessage: + 'Eingöngu sá sem er með lögheimilisforsjá hefur heimild til að sækja um fyrir barn. \n\nÞjóðskrá skráir hver eða hverjir teljast foreldrar barns og hver fari með forsjárskyldur þess. Upplýsingar um skráningu forsjár og lögheimilisforeldris má nálgast hér: [Foreldrar og forsjá | Þjóðskrá (skra.is)](https://www.skra.is/folk/skraning-barns/foreldrar-og-forsja/)\n\nUpplýsingum um tengsl á milli barna og foreldra auk forsjáraðila eru einnig aðgengilegar á [Mínum síðum á Ísland.is](https://island.is/minarsidur)', + description: + 'Only the person who has legal custody has the authority to apply for a child.\n\nThe National Registry records who or which individuals are considered to be the parents of a child and who has custody responsibilities. Information on registering custody and legal guardianship can be found here: [Parents and Custody | National Registry (skra.is)](https://www.skra.is/folk/skraning-barns/foreldrar-og-forsja/)\n\nInformation about the relationship between children and parents, as well as custody authorities, is also available on [My Pages on Ísland.is](https://island.is/minarsidur)', }, }) diff --git a/libs/application/templates/new-primary-school/src/lib/newPrimarySchoolUtils.spec.ts b/libs/application/templates/new-primary-school/src/lib/newPrimarySchoolUtils.spec.ts index 123ba82b26c6..a6ba6347e256 100644 --- a/libs/application/templates/new-primary-school/src/lib/newPrimarySchoolUtils.spec.ts +++ b/libs/application/templates/new-primary-school/src/lib/newPrimarySchoolUtils.spec.ts @@ -1,58 +1,11 @@ import { ExternalData } from '@island.is/application/types' -import { Child } from '../types' -import { canApply, hasOtherParent } from './newPrimarySchoolUtils' -import * as kennitala from 'kennitala' - -describe('canApply', () => { - const getNationalId = (years: number) => { - const currentDate = new Date() - const fithteenYearsAgo = new Date( - currentDate.getFullYear() - years, - currentDate.getMonth(), - currentDate.getDate(), - ) - - return kennitala.generatePerson(fithteenYearsAgo) - } - - it('should return true if child is between 5 and 15 years old and lives with applicant', () => { - const child = { - nationalId: getNationalId(15), - livesWithApplicant: true, - } as Child - expect(canApply(child)).toBe(true) - }) - - it('should return false if child is younger than 5 years old', () => { - const child = { - nationalId: getNationalId(4), - livesWithApplicant: true, - } as Child - expect(canApply(child)).toBe(false) - }) - - it('should return false if child is older than 15 years old', () => { - const child = { - nationalId: getNationalId(16), - livesWithApplicant: true, - } as Child - expect(canApply(child)).toBe(false) - }) - - it('should return false if child does not live with applicant', () => { - const child = { - nationalId: getNationalId(8), - livesWithApplicant: false, - } as Child - expect(canApply(child)).toBe(false) - }) -}) +import { hasOtherParent } from './newPrimarySchoolUtils' describe('hasOtherParent', () => { it('should return true if otherParent exists in externalData', () => { const answers = {} const externalData = { - childrenCustodyInformation: { + children: { data: [ { fullName: 'Stúfur Maack ', @@ -71,7 +24,7 @@ describe('hasOtherParent', () => { it('should return false if otherParent does not exist in externalData', () => { const answers = {} const externalData = { - childrenCustodyInformation: { + children: { data: [ { fullName: 'Stúfur Maack ', diff --git a/libs/application/templates/new-primary-school/src/lib/newPrimarySchoolUtils.ts b/libs/application/templates/new-primary-school/src/lib/newPrimarySchoolUtils.ts index c627c828c780..c8f5887734ad 100644 --- a/libs/application/templates/new-primary-school/src/lib/newPrimarySchoolUtils.ts +++ b/libs/application/templates/new-primary-school/src/lib/newPrimarySchoolUtils.ts @@ -5,29 +5,23 @@ import { FormValue, YesOrNo, } from '@island.is/application/types' -import * as kennitala from 'kennitala' +import { Locale } from '@island.is/shared/types' import { Child, ChildInformation, + FriggChildInformation, Parents, Person, RelativesRow, + SelectOption, SiblingsRow, } from '../types' import { - FoodAllergiesOptions, - FoodIntolerancesOptions, - Gender, ReasonForApplicationOptions, - RelationOptions, SiblingRelationOptions, } from './constants' import { newPrimarySchoolMessages } from './messages' -import { ApolloClient } from '@apollo/client' -import { friggOptionsQuery } from '../graphql/queries' -import { FriggOptionsQuery, FriggOptionsQueryVariables } from '../types/schema' - export const getApplicationAnswers = (answers: Application['answers']) => { const childNationalId = getValueViaPath(answers, 'childNationalId') as string @@ -84,31 +78,6 @@ export const getApplicationAnswers = (answers: Application['answers']) => { 'languages.icelandicNotSpokenAroundChild', ) as string[] - const hasFoodAllergies = getValueViaPath( - answers, - 'allergiesAndIntolerances.hasFoodAllergies', - ) as string[] - - const foodAllergies = getValueViaPath( - answers, - 'allergiesAndIntolerances.foodAllergies', - ) as FoodAllergiesOptions[] - - const hasFoodIntolerances = getValueViaPath( - answers, - 'allergiesAndIntolerances.hasFoodIntolerances', - ) as string[] - - const foodIntolerances = getValueViaPath( - answers, - 'allergiesAndIntolerances.foodIntolerances', - ) as FoodIntolerancesOptions[] - - const isUsingEpiPen = getValueViaPath( - answers, - 'allergiesAndIntolerances.isUsingEpiPen', - ) as YesOrNo - const developmentalAssessment = getValueViaPath( answers, 'support.developmentalAssessment', @@ -137,20 +106,10 @@ export const getApplicationAnswers = (answers: Application['answers']) => { 'schools.newSchool.school', ) as string - const photographyConsent = getValueViaPath( + const newSchoolHiddenInput = getValueViaPath( answers, - 'photography.photographyConsent', - ) as YesOrNo - - const photoSchoolPublication = getValueViaPath( - answers, - 'photography.photoSchoolPublication', - ) as YesOrNo - - const photoMediaPublication = getValueViaPath( - answers, - 'photography.photoMediaPublication', - ) as YesOrNo + 'schools.newSchool.hiddenInput', + ) as string return { childNationalId, @@ -167,32 +126,20 @@ export const getApplicationAnswers = (answers: Application['answers']) => { otherLanguagesSpokenDaily, otherLanguages, icelandicNotSpokenAroundChild, - hasFoodAllergies, - foodAllergies, - hasFoodIntolerances, - foodIntolerances, - isUsingEpiPen, developmentalAssessment, specialSupport, requestMeeting, - photographyConsent, - photoSchoolPublication, - photoMediaPublication, - startDate, schoolMunicipality, selectedSchool, + newSchoolHiddenInput, } } export const getApplicationExternalData = ( externalData: Application['externalData'], ) => { - const children = getValueViaPath( - externalData, - 'childrenCustodyInformation.data', - [], - ) as Child[] + const children = getValueViaPath(externalData, 'children.data', []) as Child[] const applicantName = getValueViaPath( externalData, @@ -221,7 +168,17 @@ export const getApplicationExternalData = ( const otherParentName = getValueViaPath( externalData, - 'childrenCustodyInformation.data.otherParent.fullName', + 'children.data.otherParent.fullName', + ) as string + + const childInformation = getValueViaPath( + externalData, + 'childInformation.data', + ) as FriggChildInformation + + const childGradeLevel = getValueViaPath( + externalData, + 'childInformation.data.gradeLevel', ) as string return { @@ -232,22 +189,11 @@ export const getApplicationExternalData = ( applicantPostalCode, applicantCity, otherParentName, + childInformation, + childGradeLevel, } } -export const canApply = (child: Child): boolean => { - // Check if the child is at primary school age and lives with the applicant - if ( - kennitala.info(child.nationalId).age >= 5 && - kennitala.info(child.nationalId).age <= 15 && - child.livesWithApplicant - ) { - return true - } - - return false -} - export const getSelectedChild = (application: Application) => { const { childNationalId } = getApplicationAnswers(application.answers) const { children } = getApplicationExternalData(application.externalData) @@ -275,37 +221,6 @@ export const hasOtherParent = ( return !!otherParent } -export const getRelationOptions = () => [ - { - value: RelationOptions.GRANDPARENT, - label: - newPrimarySchoolMessages.childrenNParents.relativesRelationGrandparent, - }, - { - value: RelationOptions.SIBLING, - label: newPrimarySchoolMessages.childrenNParents.relativesRelationSibling, - }, - { - value: RelationOptions.STEPPARENT, - label: - newPrimarySchoolMessages.childrenNParents.relativesRelationStepparent, - }, - { - value: RelationOptions.RELATIVE, - label: newPrimarySchoolMessages.childrenNParents.relativesRelationRelative, - }, - { - value: RelationOptions.FRIEND_OR_OTHER, - label: - newPrimarySchoolMessages.childrenNParents.relativesRelationFriendOrOther, - }, -] - -export const getRelationOptionLabel = (value: RelationOptions) => { - const relationOptions = getRelationOptions() - return relationOptions.find((option) => option.value === value)?.label ?? '' -} - export const getReasonForApplicationOptions = () => [ { value: ReasonForApplicationOptions.TRANSFER_OF_LEGAL_DOMICILE, @@ -382,127 +297,30 @@ export const getSiblingRelationOptionLabel = ( return relationOptions.find((option) => option.value === value)?.label ?? '' } -export const getGenderOptions = () => [ - { - value: Gender.MALE, - label: newPrimarySchoolMessages.shared.male, - }, - { - value: Gender.FEMALE, - label: newPrimarySchoolMessages.shared.female, - }, - { - value: Gender.OTHER, - label: newPrimarySchoolMessages.shared.otherGender, - }, -] +export const getSelectedOptionLabel = ( + options: SelectOption[], + key?: string, +) => { + if (key === undefined) { + return undefined + } + + return options.find((option) => option.value === key)?.label +} -export const formatGender = (genderCode?: string): Gender | undefined => { - switch (genderCode) { +export const formatGrade = (gradeLevel: string, lang: Locale) => { + let grade = gradeLevel + if (gradeLevel[0] === '0') { + grade = gradeLevel[1] + } + switch (grade) { case '1': - case '3': - return Gender.MALE + return lang === 'en' ? `${grade}st` : grade case '2': - case '4': - return Gender.FEMALE - case '7': - case '8': - return Gender.OTHER + return lang === 'en' ? `${grade}nd` : grade + case '3': + return lang === 'en' ? `${grade}rd` : grade default: - return undefined + return lang === 'en' ? `${grade}th` : grade } } - -export const getGenderOptionLabel = (value: Gender) => { - const genderOptions = getGenderOptions() - return genderOptions.find((option) => option.value === value)?.label ?? '' -} - -export const getFoodAllergiesOptions = () => [ - { - value: FoodAllergiesOptions.EGG_ALLERGY, - label: newPrimarySchoolMessages.differentNeeds.eggAllergy, - }, - { - value: FoodAllergiesOptions.FISH_ALLERGY, - label: newPrimarySchoolMessages.differentNeeds.fishAllergy, - }, - { - value: FoodAllergiesOptions.PENUT_ALLERGY, - label: newPrimarySchoolMessages.differentNeeds.nutAllergy, - }, - { - value: FoodAllergiesOptions.WHEAT_ALLERGY, - label: newPrimarySchoolMessages.differentNeeds.wheatAllergy, - }, - { - value: FoodAllergiesOptions.MILK_ALLERGY, - label: newPrimarySchoolMessages.differentNeeds.milkAllergy, - }, - { - value: FoodAllergiesOptions.OTHER, - label: newPrimarySchoolMessages.differentNeeds.other, - }, -] - -export const getFoodAllergiesOptionsLabel = (value: FoodAllergiesOptions) => { - const foodAllergiesOptions = getFoodAllergiesOptions() - return ( - foodAllergiesOptions.find((option) => option.value === value)?.label ?? '' - ) -} - -export const getFoodIntolerancesOptions = () => [ - { - value: FoodIntolerancesOptions.LACTOSE_INTOLERANCE, - label: newPrimarySchoolMessages.differentNeeds.lactoseIntolerance, - }, - { - value: FoodIntolerancesOptions.GLUTEN_INTOLERANCE, - label: newPrimarySchoolMessages.differentNeeds.glutenIntolerance, - }, - { - value: FoodIntolerancesOptions.MSG_INTOLERANCE, - label: newPrimarySchoolMessages.differentNeeds.msgIntolerance, - }, - { - value: FoodIntolerancesOptions.OTHER, - label: newPrimarySchoolMessages.differentNeeds.other, - }, -] - -export const getFoodIntolerancesOptionsLabel = ( - value: FoodIntolerancesOptions, -) => { - const foodIntolerancesOptions = getFoodIntolerancesOptions() - return ( - foodIntolerancesOptions.find((option) => option.value === value)?.label ?? - '' - ) -} - -export const getOptionsListByType = async ( - apolloClient: ApolloClient, - type: string, -) => { - const { data } = await apolloClient.query< - FriggOptionsQuery, - FriggOptionsQueryVariables - >({ - query: friggOptionsQuery, - variables: { - type: { - type, - }, - }, - }) - - return ( - data?.friggOptions?.flatMap(({ options }) => - options.flatMap(({ value, id }) => { - const content = value.find(({ language }) => language === 'is')?.content - return { value: id ?? '', label: content ?? '' } - }), - ) ?? [] - ) -} diff --git a/libs/application/templates/new-primary-school/src/types.ts b/libs/application/templates/new-primary-school/src/types.ts index a81c26db3575..630f1fd9a6c8 100644 --- a/libs/application/templates/new-primary-school/src/types.ts +++ b/libs/application/templates/new-primary-school/src/types.ts @@ -1,6 +1,6 @@ import { - Gender, - RelationOptions, + MembershipOrganizationType, + MembershipRole, SiblingRelationOptions, } from './lib/constants' @@ -8,8 +8,7 @@ export interface RelativesRow { fullName: string phoneNumber: string nationalId: string - relation: RelationOptions - canPickUpChild: string[] + relation: string } export interface SiblingsRow { @@ -23,7 +22,6 @@ export type Child = { nationalId: string otherParent: object livesWithApplicant: boolean - domicileInIceland: boolean livesWithBothParents: boolean genderCode: string } @@ -36,8 +34,8 @@ export type ChildInformation = { postalCode: string city: string } - gender: Gender - chosenName: string + preferredName: string + pronouns: string[] differentPlaceOfResidence: string placeOfResidence?: { streetAddress: string @@ -52,6 +50,7 @@ export type Person = { phoneNumber: string address: { streetAddress: string + streetName?: string postalCode: string city: string } @@ -61,3 +60,52 @@ export type Parents = { parent1: Person parent2: Person } + +export type SelectOption = { + label: string + value: string +} + +export type Agent = { + id: string + name: string + role: string + email: string + phone: string + nationalId: string +} + +export type Membership = { + id: string + role: MembershipRole + beginDate: Date + endDate: Date | null + organization?: MembershipOrganization +} + +export type MembershipOrganization = { + id: string + nationalId: string + name: string + type: MembershipOrganizationType +} + +export type FriggChildInformation = { + id: string + name: string + email: string + agents: Agent[] + pronouns: string[] + nationalId: string + gradeLevel: string + memberships: Membership[] + primaryOrgId: object + preferredName: object | null + address?: { + id: string + street: string + municipality?: object + zip: string + country?: object + } +} diff --git a/libs/clients/mms/frigg/project.json b/libs/clients/mms/frigg/project.json index 333343cfaecd..d67cd8a8c925 100644 --- a/libs/clients/mms/frigg/project.json +++ b/libs/clients/mms/frigg/project.json @@ -22,7 +22,7 @@ "executor": "nx:run-commands", "options": { "commands": [ - "curl -H \"X-Road-Client: IS-DEV/GOV/10000/island-is-client\" http://localhost:8081/r1/IS-DEV/GOV/10066/MMS-Protected/getOpenAPI?serviceCode=frigg-api > src/clientConfig.json", + "curl -H \"X-Road-Client: IS-DEV/GOV/10000/island-is-client\" http://localhost:8081/r1/IS-DEV/GOV/10066/MMS-Protected/getOpenAPI?serviceCode=frigg-form-service > src/clientConfig.json", "prettier --write src/clientConfig.json" ], "parallel": false, diff --git a/libs/clients/mms/frigg/src/clientConfig.json b/libs/clients/mms/frigg/src/clientConfig.json index f671fc3c7bf7..1eb150763fb1 100644 --- a/libs/clients/mms/frigg/src/clientConfig.json +++ b/libs/clients/mms/frigg/src/clientConfig.json @@ -1,7 +1,88 @@ { "openapi": "3.0.0", "paths": { - "/keyOptions": { + "/forms": { + "post": { + "operationId": "submitForm", + "parameters": [], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/FormDto" } + } + } + }, + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/FormSubmitSuccessModel" + } + } + } + } + }, + "tags": ["Frigg"], + "security": [{ "bearer": [] }] + } + }, + "/forms/types": { + "get": { + "operationId": "getFormTypes", + "summary": "Get list of types of forms", + "description": "Get types.", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { "type": "array", "items": { "type": "string" } } + } + } + } + }, + "tags": ["Frigg"], + "security": [{ "bearer": [] }] + } + }, + "/forms/reviews/{reviewId}/{action}": { + "post": { + "operationId": "updateReview", + "summary": "Review form", + "description": "Review form.", + "parameters": [ + { + "name": "reviewId", + "required": true, + "in": "path", + "schema": { "type": "string" } + }, + { + "name": "action", + "required": true, + "in": "path", + "schema": { "type": "string" } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/SuccessModel" } + } + } + } + }, + "tags": ["Frigg"], + "security": [{ "bearer": [] }] + } + }, + "/key-options": { "get": { "operationId": "getAllKeyOptions", "summary": "Get all key options.", @@ -28,31 +109,88 @@ } } }, - "tags": ["KeyOptionsManagement"], - "security": [{ "Authorization": [] }] + "tags": ["Frigg"] } }, - "/keyOptions/types": { + "/key-options/types": { "get": { - "operationId": "getTypes", + "operationId": "getKeyOptionsTypes", "summary": "Get list of types of key options", "description": "Get types.", "parameters": [], - "responses": { "200": { "description": "" } }, - "tags": ["KeyOptionsManagement"], - "security": [{ "Authorization": [] }] + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { "type": "array", "items": { "type": "string" } } + } + } + } + }, + "tags": ["Frigg"] } }, "/health": { "get": { "operationId": "health", "parameters": [], - "responses": { "200": { "description": "" } } + "responses": { "200": { "description": "" } }, + "tags": ["Utils"] + } + }, + "/schools": { + "get": { + "operationId": "getAllSchoolsByMunicipality", + "summary": "Get all schools.", + "description": "Returns a paginated collection of schools.", + "parameters": [], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { "$ref": "#/components/schemas/OrganizationModel" } + } + } + } + } + }, + "tags": ["Frigg"] + } + }, + "/students/{nationalId}": { + "get": { + "operationId": "getUserBySourcedId", + "summary": "Get user by nationalId", + "description": "Get user by Id.", + "parameters": [ + { + "name": "nationalId", + "required": true, + "in": "path", + "schema": { "type": "string" } + } + ], + "responses": { + "200": { + "description": "", + "content": { + "application/json": { + "schema": { "$ref": "#/components/schemas/UserModel" } + } + } + } + }, + "tags": ["Frigg"], + "security": [{ "bearer": [] }] } } }, "info": { - "title": "MMS Internal API", + "title": "MMS FORM SERVICE API", "description": "Frigg - student information system", "version": "1", "contact": {} @@ -61,16 +199,144 @@ "servers": [], "components": { "securitySchemes": { - "Authorization": { - "scheme": "Bearer", - "bearerFormat": "Bearer", + "bearer": { + "scheme": "bearer", + "bearerFormat": "JWT", "description": "Please enter token in from IAS", - "name": "Authorization", - "type": "http", - "in": "Header" + "type": "http" } }, "schemas": { + "AddressDto": { + "type": "object", + "properties": { + "address": { "type": "string" }, + "postCode": { "type": "number" } + }, + "required": ["address", "postCode"] + }, + "UserDto": { + "type": "object", + "properties": { + "name": { "type": "string" }, + "nationalId": { "type": "string" }, + "preferredName": { "type": "string" }, + "pronouns": { "type": "array", "items": { "type": "string" } }, + "domicile": { "$ref": "#/components/schemas/AddressDto" }, + "residence": { "$ref": "#/components/schemas/AddressDto" } + }, + "required": ["name", "nationalId"] + }, + "AgentDto": { + "type": "object", + "properties": { + "name": { "type": "string" }, + "nationalId": { "type": "string" }, + "preferredName": { "type": "string" }, + "pronouns": { "type": "array", "items": { "type": "string" } }, + "domicile": { "$ref": "#/components/schemas/AddressDto" }, + "email": { "type": "string", "example": "name@frigg.is" }, + "phone": { "type": "string" }, + "role": { + "type": "string", + "description": "Agents connection to the student, strings can be found under key option type \"relation\"" + } + }, + "required": ["name", "nationalId", "role"] + }, + "RegistrationDto": { + "type": "object", + "properties": { + "preRegisteredId": { + "type": "string", + "description": "If a user has an open ongoing registration, for exaple first year students submit the id here" + }, + "defaultOrg": { + "type": "string", + "description": "The school a student should or does belong to, pre registered school or current school" + }, + "selectedOrg": { + "type": "string", + "description": "The school selected for a student in the application process" + }, + "requestingMeeting": { "type": "boolean", "default": false }, + "expectedStartDate": { "format": "date-time", "type": "string" }, + "reason": { "type": "string" }, + "movingAbroadCountry": { "type": "string" }, + "newDomicile": { "$ref": "#/components/schemas/AddressDto" } + }, + "required": [ + "defaultOrg", + "selectedOrg", + "requestingMeeting", + "expectedStartDate", + "reason" + ] + }, + "HealthDto": { + "type": "object", + "properties": { + "usesEpipen": { "type": "boolean", "default": false }, + "allergies": { "type": "array", "items": { "type": "string" } }, + "intolerances": { "type": "array", "items": { "type": "string" } } + } + }, + "SocialDto": { + "type": "object", + "properties": { + "hasHadSupport": { "type": "boolean", "default": false }, + "hasDiagnoses": { "type": "boolean", "default": false } + } + }, + "LanguageDto": { + "type": "object", + "properties": { + "nativeLanguage": { "type": "string" }, + "noIcelandic": { "type": "boolean" }, + "otherLanguages": { "type": "array", "items": { "type": "string" } } + }, + "required": ["nativeLanguage", "noIcelandic"] + }, + "FormDto": { + "type": "object", + "properties": { + "type": { "type": "string", "enum": ["registration"] }, + "user": { "$ref": "#/components/schemas/UserDto" }, + "agents": { + "type": "array", + "items": { "$ref": "#/components/schemas/AgentDto" } + }, + "registration": { "$ref": "#/components/schemas/RegistrationDto" }, + "health": { "$ref": "#/components/schemas/HealthDto" }, + "social": { "$ref": "#/components/schemas/SocialDto" }, + "language": { "$ref": "#/components/schemas/LanguageDto" } + }, + "required": [ + "type", + "user", + "agents", + "registration", + "health", + "social", + "language" + ] + }, + "FormSubmitSuccessModel": { + "type": "object", + "properties": { + "formId": { "type": "string", "description": "Id of form created" }, + "reviewId": { "type": "string", "description": "Id of review" }, + "status": { "type": "string", "description": "Status of form" } + }, + "required": ["formId", "reviewId", "status"] + }, + "SuccessModel": { + "type": "object", + "properties": { + "success": { "type": "boolean", "description": "Submission response" } + }, + "required": ["success"] + }, "Value": { "type": "object", "properties": { @@ -119,6 +385,168 @@ } }, "required": ["type", "options"] + }, + "AddressModel": { + "type": "object", + "properties": { + "id": { "type": "string" }, + "street": { "type": "string" }, + "municipality": { "type": "object", "nullable": true }, + "zip": { "type": "string" }, + "country": { "type": "object", "nullable": true } + }, + "required": ["id", "street", "municipality", "zip", "country"] + }, + "OrganizationModel": { + "type": "object", + "properties": { + "id": { "type": "string" }, + "nationalId": { "type": "string" }, + "name": { "type": "string" }, + "type": { + "type": "string", + "enum": ["municipality", "national", "school"] + }, + "gradeLevels": { "type": "array", "items": { "type": "string" } }, + "address": { + "nullable": true, + "allOf": [{ "$ref": "#/components/schemas/AddressModel" }] + }, + "parent": { + "nullable": true, + "default": null, + "allOf": [{ "$ref": "#/components/schemas/OrganizationModel" }] + }, + "children": { + "nullable": true, + "default": [], + "type": "array", + "items": { "$ref": "#/components/schemas/OrganizationModel" } + } + }, + "required": [ + "id", + "nationalId", + "name", + "type", + "gradeLevels", + "address", + "parent", + "children" + ] + }, + "MembershipOrganizationModel": { + "type": "object", + "properties": { + "id": { "type": "string" }, + "nationalId": { "type": "string" }, + "name": { "type": "string" }, + "type": { + "type": "string", + "enum": ["municipality", "national", "school"] + } + }, + "required": ["id", "nationalId", "name", "type"] + }, + "MembershipModel": { + "type": "object", + "properties": { + "id": { "type": "string" }, + "role": { + "type": "string", + "enum": [ + "admin", + "guardian", + "parent", + "principal", + "relative", + "student", + "teacher" + ] + }, + "beginDate": { "format": "date-time", "type": "string" }, + "endDate": { + "format": "date-time", + "type": "string", + "nullable": true + }, + "organization": { + "nullable": true, + "allOf": [ + { "$ref": "#/components/schemas/MembershipOrganizationModel" } + ] + } + }, + "required": ["id", "role", "beginDate", "endDate", "organization"] + }, + "AgentModel": { + "type": "object", + "properties": { + "id": { "type": "string" }, + "nationalId": { "type": "string" }, + "name": { "type": "string" }, + "phone": { "type": "string" }, + "email": { "type": "string" }, + "role": { "type": "string" }, + "domicile": { + "nullable": true, + "allOf": [{ "$ref": "#/components/schemas/AddressModel" }] + } + }, + "required": [ + "id", + "nationalId", + "name", + "phone", + "email", + "role", + "domicile" + ] + }, + "UserModel": { + "type": "object", + "properties": { + "id": { "type": "string" }, + "nationalId": { "type": "string" }, + "name": { "type": "string" }, + "preferredName": { "type": "object", "nullable": true }, + "pronouns": { "type": "array", "items": { "type": "string" } }, + "gradeLevel": { "type": "string" }, + "email": { "type": "object", "nullable": true }, + "domicile": { + "nullable": true, + "allOf": [{ "$ref": "#/components/schemas/AddressModel" }] + }, + "residence": { + "nullable": true, + "allOf": [{ "$ref": "#/components/schemas/AddressModel" }] + }, + "primaryOrgId": { "type": "object" }, + "memberships": { + "nullable": true, + "type": "array", + "items": { "$ref": "#/components/schemas/MembershipModel" } + }, + "agents": { + "nullable": true, + "type": "array", + "items": { "$ref": "#/components/schemas/AgentModel" } + } + }, + "required": [ + "id", + "nationalId", + "name", + "preferredName", + "pronouns", + "gradeLevel", + "email", + "domicile", + "residence", + "primaryOrgId", + "memberships", + "agents" + ] } } } diff --git a/libs/clients/mms/frigg/src/lib/apiProvider.ts b/libs/clients/mms/frigg/src/lib/apiProvider.ts index d1f77fd70d0b..e56219d24758 100644 --- a/libs/clients/mms/frigg/src/lib/apiProvider.ts +++ b/libs/clients/mms/frigg/src/lib/apiProvider.ts @@ -4,27 +4,21 @@ import { LazyDuringDevScope, XRoadConfig, } from '@island.is/nest/config' -import { - Configuration, - DefaultApi, - KeyOptionsManagementApi, -} from '../../gen/fetch' +import { Configuration, FriggApi } from '../../gen/fetch' import { ConfigFactory } from './configFactory' import { FriggClientConfig } from './friggClient.config' -export const apiProvider = [KeyOptionsManagementApi, DefaultApi].map( - (apiRecord) => ({ - provide: apiRecord, - scope: LazyDuringDevScope, - useFactory: ( - xRoadConfig: ConfigType, - config: ConfigType, - idsClientConfig: ConfigType, - ) => { - return new apiRecord( - new Configuration(ConfigFactory(xRoadConfig, config, idsClientConfig)), - ) - }, - inject: [XRoadConfig.KEY, FriggClientConfig.KEY, IdsClientConfig.KEY], - }), -) +export const apiProvider = [FriggApi].map((apiRecord) => ({ + provide: apiRecord, + scope: LazyDuringDevScope, + useFactory: ( + xRoadConfig: ConfigType, + config: ConfigType, + idsClientConfig: ConfigType, + ) => { + return new apiRecord( + new Configuration(ConfigFactory(xRoadConfig, config, idsClientConfig)), + ) + }, + inject: [XRoadConfig.KEY, FriggClientConfig.KEY, IdsClientConfig.KEY], +})) diff --git a/libs/clients/mms/frigg/src/lib/friggClient.config.ts b/libs/clients/mms/frigg/src/lib/friggClient.config.ts index 300f2cd6d438..8889c509c261 100644 --- a/libs/clients/mms/frigg/src/lib/friggClient.config.ts +++ b/libs/clients/mms/frigg/src/lib/friggClient.config.ts @@ -13,7 +13,7 @@ export const FriggClientConfig = defineConfig>({ load: (env) => ({ xRoadServicePath: env.required( 'XROAD_MMS_FRIGG_PATH', - 'IS-DEV/GOV/10066/MMS-Protected/frigg-api', + 'IS-DEV/GOV/10066/MMS-Protected/frigg-form-service', ), scope: [MMSScope.frigg], }), diff --git a/libs/clients/mms/frigg/src/lib/friggClient.service.ts b/libs/clients/mms/frigg/src/lib/friggClient.service.ts index 95d7b47117cf..6e0a24bf739b 100644 --- a/libs/clients/mms/frigg/src/lib/friggClient.service.ts +++ b/libs/clients/mms/frigg/src/lib/friggClient.service.ts @@ -1,33 +1,39 @@ -import { Injectable } from '@nestjs/common' import { Auth, AuthMiddleware, type User } from '@island.is/auth-nest-tools' -import { KeyOption, KeyOptionsManagementApi, DefaultApi } from '../../gen/fetch' +import { Injectable } from '@nestjs/common' +import { + FriggApi, + KeyOption, + OrganizationModel, + UserModel, +} from '../../gen/fetch' @Injectable() export class FriggClientService { - constructor( - private readonly keyOptionsManagementApi: KeyOptionsManagementApi, - private readonly defaultApi: DefaultApi, - ) {} + constructor(private readonly friggApi: FriggApi) {} - private keyOptionsManagementApiWithAuth = (user: User) => - this.keyOptionsManagementApi.withMiddleware( - new AuthMiddleware(user as Auth), - ) + private friggApiWithAuth = (user: User) => + this.friggApi.withMiddleware(new AuthMiddleware(user as Auth)) - private defaultApiWithAuth = (user: User) => - this.defaultApi.withMiddleware(new AuthMiddleware(user as Auth)) + async getAllKeyOptions( + user: User, + type: string | undefined, + ): Promise { + return await this.friggApiWithAuth(user).getAllKeyOptions({ + type: type, + }) + } - async getHealth(user: User): Promise { - return this.defaultApiWithAuth(user).health() + async getKeyOptionsTypes(user: User): Promise { + return await this.friggApiWithAuth(user).getKeyOptionsTypes() } - async getAllKeyOptions(user: User, type: string): Promise { - return this.keyOptionsManagementApiWithAuth(user).getAllKeyOptions({ - type, - }) + async getAllSchoolsByMunicipality(user: User): Promise { + return await this.friggApiWithAuth(user).getAllSchoolsByMunicipality() } - async getTypes(user: User): Promise { - return this.keyOptionsManagementApiWithAuth(user).getTypes() + async getUserById(user: User, childNationalId: string): Promise { + return await this.friggApiWithAuth(user).getUserBySourcedId({ + nationalId: childNationalId, + }) } }