Skip to content

Commit

Permalink
feat(new-primary-school): Child info page
Browse files Browse the repository at this point in the history
Preferred name and pronouns behind checkmark and change 'Dvalarstaður' to 'Aðsetur'
  • Loading branch information
hfhelgason committed Jan 15, 2025
1 parent 006bb01 commit 49df9cb
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 6 deletions.
2 changes: 2 additions & 0 deletions libs/application/core/src/lib/fieldBuilders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ export const buildTextField = (
min,
readOnly,
rightAlign,
tooltip,
onChange,
} = data
return {
Expand All @@ -313,6 +314,7 @@ export const buildTextField = (
rightAlign,
max,
min,
tooltip,
onChange,
type: FieldTypes.TEXT,
component: FieldComponents.TEXT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const transformApplicationToNewPrimarySchoolDTO = (
const {
differentPlaceOfResidence,
childInfo,
usePronounAndPreferredName,
parents,
siblings,
relatives,
Expand Down Expand Up @@ -95,8 +96,12 @@ export const transformApplicationToNewPrimarySchoolDTO = (
user: {
name: childInfo.name,
nationalId: childInfo.nationalId,
preferredName: childInfo.preferredName,
pronouns: childInfo.pronouns,
...(usePronounAndPreferredName?.includes(YES)
? {
preferredName: childInfo.preferredName,
pronouns: childInfo.pronouns,
}
: {}),
domicile: {
address: childInfo.address.streetAddress,
postCode: childInfo.address.postalCode,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
buildActionCardListField,
buildCheckboxField,
buildCustomField,
buildDescriptionField,
buildMultiField,
Expand Down Expand Up @@ -71,8 +72,28 @@ export const childInfoSubSection = buildSubSection({
defaultValue: (application: Application) =>
getApplicationExternalData(application.externalData).applicantCity,
}),
buildCheckboxField({
id: 'childInfo.usePronounAndPreferredName',
title: '',
options: [
{
value: YES,
label:
newPrimarySchoolMessages.childrenNParents
.usePronounAndPreferredName,
},
],
}),
buildTextField({
id: 'childInfo.preferredName',
tooltip:
newPrimarySchoolMessages.childrenNParents.preferredNameTooltip,
condition: (answers) => {
const { usePronounAndPreferredName } =
getApplicationAnswers(answers)

return usePronounAndPreferredName?.includes(YES)
},
title:
newPrimarySchoolMessages.childrenNParents.childInfoPreferredName,
defaultValue: (application: Application) =>
Expand All @@ -83,6 +104,12 @@ export const childInfoSubSection = buildSubSection({
{
id: 'childInfo.pronouns',
title: newPrimarySchoolMessages.childrenNParents.childInfoPronouns,
condition: (answers) => {
const { usePronounAndPreferredName } =
getApplicationAnswers(answers)

return usePronounAndPreferredName?.includes(YES)
},
component: 'FriggOptionsAsyncSelectField',
defaultValue: (application: Application) =>
getApplicationExternalData(application.externalData)
Expand All @@ -100,6 +127,9 @@ export const childInfoSubSection = buildSubSection({
id: 'childInfo.differentPlaceOfResidence',
title:
newPrimarySchoolMessages.childrenNParents.differentPlaceOfResidence,
description:
newPrimarySchoolMessages.childrenNParents
.differentPlaceOfResidenceDescription,
width: 'half',
required: true,
space: 4,
Expand Down
28 changes: 24 additions & 4 deletions libs/application/templates/new-primary-school/src/lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,16 +223,36 @@ export const newPrimarySchoolMessages: MessageDir = {
defaultMessage: 'Veldu fornafn',
description: 'Select pronoun',
},
usePronounAndPreferredName: {
id: 'nps.application:childrenNParents.child.info.use.pronoun.and.preferred.name',
defaultMessage:
'Barnið kýs að vera ávarpað með öðru nafni og/eða persónufornafni en hann eða hún',
description:
'The child prefers to be addressed by a name and/or personal pronoun other than he or she',
},
preferredNameTooltip: {
id: 'nps.application:childrenNParents.child.info.preferred.name.tooltip',
defaultMessage:
'Forsjáraðilar geta óskað eftir breytingu á skráðu kyni og nafni barns hjá Þjóðskrá eða barnið sjálft sé það orðið 15 ára. Ef sú breyting er ótímabært má breyta nafni barnsins hér og skrá það nafn sem barn hefur valið sér.',
description:
"Guardians can request a change to a child's registered gender and name with the National Registry, or the child themselves if they have reached the age of 15. If the change is premature, the child's name can be changed here and the name the child has chosen can be registered.",
},
differentPlaceOfResidence: {
id: 'nps.application:childrenNParents.child.info.different.place.of.residence',
defaultMessage: 'Er dvalarstaður barns annað en skráð lögheimili?',
defaultMessage: 'Er aðsetur barns annað en skráð lögheimili?',
description:
"Is the child's temporary residence different from the registered legal domicile?",
},
differentPlaceOfResidenceDescription: {
id: 'nps.application:childrenNParents.child.info.different.place.of.residence.description',
defaultMessage: 'Aðsetur er tímabundin búseta barns í öðru húsnæði',
description:
"Is the child's place of residence different from the registered legal domicile?",
"Temporary residence is a child's place of residence in another home.",
},
childInfoPlaceOfResidence: {
id: 'nps.application:childrenNParents.child.info.place.of.residence',
defaultMessage: 'Dvalarstaður barns',
description: "Child's place of residence",
defaultMessage: 'Aðsetur barns',
description: "Child's temporary residence",
},

// Parents/guardians
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ export const getApplicationAnswers = (answers: Application['answers']) => {

const childInfo = getValueViaPath(answers, 'childInfo') as ChildInformation

const usePronounAndPreferredName = getValueViaPath(
answers,
'childInfo.usePronounAndPreferredName',
) as string[]

const differentPlaceOfResidence = getValueViaPath(
answers,
'childInfo.differentPlaceOfResidence',
Expand Down Expand Up @@ -146,6 +151,7 @@ export const getApplicationAnswers = (answers: Application['answers']) => {
return {
childNationalId,
childInfo,
usePronounAndPreferredName,
differentPlaceOfResidence,
parents,
relatives,
Expand Down
1 change: 1 addition & 0 deletions libs/application/types/src/lib/Fields.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ export interface TextField extends InputField {
format?: string | FormatInputValueFunction
suffix?: string
rows?: number
tooltip?: FormText
onChange?: (...event: any[]) => void
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const TextFormField: FC<React.PropsWithChildren<Props>> = ({
step,
marginBottom,
marginTop,
tooltip,
onChange = () => undefined,
clearOnChange,
} = field
Expand All @@ -70,6 +71,12 @@ export const TextFormField: FC<React.PropsWithChildren<Props>> = ({

<Box paddingTop={2}>
<InputController
tooltip={formatTextWithLocale(
tooltip || '',
application,
locale as Locale,
formatMessage,
)}
disabled={disabled}
readOnly={readOnly}
id={id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ interface Props {
min?: number
step?: string
clearOnChange?: string[]
tooltip?: string
}

interface ChildParams {
Expand Down Expand Up @@ -98,6 +99,7 @@ export const InputController = forwardRef(
min,
step,
clearOnChange,
tooltip,
} = props
const { setValue } = useFormContext()

Expand Down Expand Up @@ -237,6 +239,7 @@ export const InputController = forwardRef(
return (
<Input
id={id}
tooltip={tooltip}
value={value}
disabled={disabled}
readOnly={readOnly}
Expand Down

0 comments on commit 49df9cb

Please sign in to comment.