Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(new-primary-school): Move child page to prerequisites #15394

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Inject, Injectable } from '@nestjs/common'
import { 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 { Inject, Injectable } from '@nestjs/common'
import { TemplateApiModuleActionProps } from '../../../types'
import { BaseTemplateApiService } from '../../base-template-api.service'

@Injectable()
export class NewPrimarySchoolService extends BaseTemplateApiService {
Expand All @@ -14,19 +15,24 @@ export class NewPrimarySchoolService extends BaseTemplateApiService {
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, undefined)
}

async getUserById({ auth }: TemplateApiModuleActionProps) {
return await this.friggClientService.getUserById(auth)
}

async getAllSchoolsByMunicipality({ auth }: TemplateApiModuleActionProps) {
return await this.friggClientService.getAllSchoolsByMunicipality(auth)
}

async getChildInformation({
auth,
application,
}: TemplateApiModuleActionProps) {
const { childNationalId } = getApplicationAnswers(application.answers)

return await this.friggClientService.getUserById(auth, childNationalId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,9 @@ import {
defineTemplateApi,
} from '@island.is/application/types'

export const GetTypesApi = defineTemplateApi({
action: 'getTypes',
externalDataId: 'types',
namespace: ApplicationTypes.NEW_PRIMARY_SCHOOL,
})

export const GetUserApi = defineTemplateApi({
action: 'getUserById',
externalDataId: 'userInfo',
export const GetKeyOptionsTypesApi = defineTemplateApi({
action: 'getKeyOptionsTypes',
externalDataId: 'keyOptionsTypes',
namespace: ApplicationTypes.NEW_PRIMARY_SCHOOL,
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const AllergiesAndIntolerances = ({
foodIntolerances,
} = getApplicationAnswers(application.answers)

const foodAllergiesFriggOptions = useFriggOptions(OptionsType.ALLERGRY)
const foodAllergiesFriggOptions = useFriggOptions(OptionsType.ALLERGY)
const foodIntolerancesFriggOptions = useFriggOptions(OptionsType.INTOLERANCE)

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const Child = ({
return (
<ReviewGroup
isEditable={editable}
editAction={() => goToScreen?.('childrenMultiField')}
editAction={() => goToScreen?.('childInfo')}
>
<Stack space={2}>
<GridRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,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',
Expand All @@ -39,7 +40,8 @@ export const childInfoSubSection = buildSubSection({
format: '######-####',
disabled: true,
defaultValue: (application: Application) =>
getSelectedChild(application)?.nationalId,
getApplicationExternalData(application.externalData)
.childInformation.nationalId,
}),
buildTextField({
id: 'childInfo.address.streetAddress',
Expand Down Expand Up @@ -77,6 +79,9 @@ export const childInfoSubSection = buildSubSection({
id: 'childInfo.chosenName',
title: newPrimarySchoolMessages.childrenNParents.childInfoChosenName,
width: 'half',
defaultValue: (application: Application) =>
getApplicationExternalData(application.externalData)
.childInformation.preferredName,
}),
buildSelectField({
id: 'childInfo.gender',
Expand Down
Original file line number Diff line number Diff line change
@@ -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],
})
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const allergiesAndIntolerancesSubSection = buildSubSection({
},
},
{
optionsType: OptionsType.ALLERGRY,
optionsType: OptionsType.ALLERGY,
placeholder:
newPrimarySchoolMessages.differentNeeds
.typeOfAllergiesPlaceholder,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,28 @@ 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 { newPrimarySchoolMessages } from '../../lib/messages'
import {
canApply,
getApplicationExternalData,
} from '../../../lib/newPrimarySchoolUtils'
} from '../../lib/newPrimarySchoolUtils'

export const childrenSubSection = buildSubSection({
id: 'childrenSubSection',
title: newPrimarySchoolMessages.childrenNParents.childrenSubSectionTitle,
title: newPrimarySchoolMessages.pre.childrenSubSectionTitle,
children: [
buildMultiField({
id: 'childrenMultiField',
title: newPrimarySchoolMessages.childrenNParents.childrenSubSectionTitle,
description:
newPrimarySchoolMessages.childrenNParents.childrenDescription,
title: newPrimarySchoolMessages.pre.childrenSubSectionTitle,
description: newPrimarySchoolMessages.pre.childrenDescription,
children: [
buildRadioField({
id: 'childNationalId',
title: newPrimarySchoolMessages.childrenNParents.childrenRadioTitle,
title: newPrimarySchoolMessages.pre.childrenRadioTitle,
options: (application) => {
const { children } = getApplicationExternalData(
application.externalData,
Expand All @@ -40,6 +41,19 @@ export const childrenSubSection = buildSubSection({
},
required: true,
}),
buildSubmitField({
id: 'submit',
placement: 'footer',
title: '',
refetchApplicationAfterSubmit: true,
actions: [
{
event: DefaultEvents.SUBMIT,
name: newPrimarySchoolMessages.pre.startApplication,
type: 'primary',
},
],
}),
],
}),
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import {
buildDataProviderItem,
buildExternalDataProvider,
buildSubSection,
} from '@island.is/application/core'
import {
ChildrenCustodyInformationApi,
NationalRegistryUserApi,
UserProfileApi,
} from '@island.is/application/types'
import {
GetKeyOptionsTypesApi,
GetSchoolsApi,
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: ChildrenCustodyInformationApi,
title: '',
subTitle: '',
}),
buildDataProviderItem({
provider: UserProfileApi,
title: newPrimarySchoolMessages.pre.userProfileInformationTitle,
subTitle: newPrimarySchoolMessages.pre.userProfileInformationSubTitle,
}),
buildDataProviderItem({
provider: GetKeyOptionsTypesApi,
title: 'KeyOptionsTypes',
}),
buildDataProviderItem({
provider: OptionsApi,
title: 'Options',
}),
buildDataProviderItem({
provider: GetSchoolsApi,
title: 'Schools',
}),
],
}),
],
})
Original file line number Diff line number Diff line change
@@ -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],
}),
],
})
Loading
Loading