Skip to content

Commit

Permalink
feat(new-primary-school): Contacts page (#17466)
Browse files Browse the repository at this point in the history
Co-authored-by: hfhelgason <hfhelgason@deloitte.is>
Co-authored-by: Verónika Sif Sigurðardóttir <vesigurdardottir@deloitte.is>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
4 people authored Jan 16, 2025
1 parent caa3127 commit 6691f54
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const transformApplicationToNewPrimarySchoolDTO = (
childInfo,
parents,
siblings,
relatives,
contacts,
reasonForApplication,
reasonForApplicationCountry,
reasonForApplicationStreetAddress,
Expand Down Expand Up @@ -63,11 +63,11 @@ export const transformApplicationToNewPrimarySchoolDTO = (
},
]
: []),
...relatives.map((relative) => ({
name: relative.fullName,
nationalId: relative.nationalId,
phone: relative.phoneNumber,
role: relative.relation,
...contacts.map((contact) => ({
name: contact.fullName,
nationalId: contact.nationalId,
phone: contact.phoneNumber,
role: contact.relation,
})),
...(reasonForApplication ===
ReasonForApplicationOptions.SIBLINGS_IN_SAME_SCHOOL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { OptionsType } from '../../lib/constants'
import { newPrimarySchoolMessages } from '../../lib/messages'
import { getSelectedOptionLabel } from '../../lib/newPrimarySchoolUtils'

const RelativesTableRepeater: FC<React.PropsWithChildren<FieldBaseProps>> = ({
const ContactsTableRepeater: FC<React.PropsWithChildren<FieldBaseProps>> = ({
error,
field,
application,
Expand All @@ -37,15 +37,15 @@ const RelativesTableRepeater: FC<React.PropsWithChildren<FieldBaseProps>> = ({
id,
title,
formTitle:
newPrimarySchoolMessages.childrenNParents.relativesRegistrationTitle,
newPrimarySchoolMessages.childrenNParents.contactsRegistrationTitle,
addItemButtonText:
newPrimarySchoolMessages.childrenNParents.relativesAddRelative,
newPrimarySchoolMessages.childrenNParents.contactsAddContact,
saveItemButtonText:
newPrimarySchoolMessages.childrenNParents.relativesRegisterRelative,
newPrimarySchoolMessages.childrenNParents.contactsRegisterContact,
removeButtonTooltipText:
newPrimarySchoolMessages.childrenNParents.relativesDeleteRelative,
newPrimarySchoolMessages.childrenNParents.contactsDeleteContact,
marginTop: 0,
maxRows: 6,
maxRows: 4,
fields: {
fullName: {
component: 'input',
Expand Down Expand Up @@ -103,4 +103,4 @@ const RelativesTableRepeater: FC<React.PropsWithChildren<FieldBaseProps>> = ({
)
}

export default RelativesTableRepeater
export default ContactsTableRepeater
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { FreeSchoolMeal } from './review-groups/FreeSchoolMeal'
import { Languages } from './review-groups/Languages'
import { Parents } from './review-groups/Parents'
import { ReasonForApplication } from './review-groups/ReasonForApplication'
import { Relatives } from './review-groups/Relatives'
import { Contacts } from './review-groups/Contacts'
import { School } from './review-groups/School'
import { Siblings } from './review-groups/Siblings'
import { Support } from './review-groups/Support'
Expand Down Expand Up @@ -157,7 +157,7 @@ export const Review: FC<ReviewScreenProps> = ({
)}
<Child {...childProps} />
<Parents {...childProps} />
<Relatives {...childProps} />
<Contacts {...childProps} />
<ReasonForApplication {...childProps} />
{reasonForApplication !== ReasonForApplicationOptions.MOVING_ABROAD && (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@ import {
} from '../../../lib/newPrimarySchoolUtils'
import { ReviewGroupProps } from './props'

export const Relatives = ({
export const Contacts = ({
application,
editable,
goToScreen,
}: ReviewGroupProps) => {
const { formatMessage } = useLocale()
const { relatives } = getApplicationAnswers(application.answers)
const { contacts } = getApplicationAnswers(application.answers)

const {
options: relationFriggOptions,
loading,
error,
} = useFriggOptions(OptionsType.RELATION)

const rows = relatives.map((r) => {
const rows = contacts.map((r) => {
return [
r.fullName,
formatPhoneNumber(removeCountryCode(r.phoneNumber ?? '')),
Expand All @@ -51,7 +51,7 @@ export const Relatives = ({
return (
<ReviewGroup
isEditable={editable}
editAction={() => goToScreen?.('relatives')}
editAction={() => goToScreen?.('contacts')}
>
{loading ? (
<SkeletonLoader height={40} width="80%" borderRadius="large" />
Expand All @@ -61,18 +61,18 @@ export const Relatives = ({
<Label>
{formatMessage(
newPrimarySchoolMessages.childrenNParents
.relativesSubSectionTitle,
.contactsSubSectionTitle,
)}
</Label>
{relatives?.length > 0 && (
{contacts?.length > 0 && (
<Box paddingTop={3}>
<StaticTableFormField
application={application}
field={{
type: FieldTypes.STATIC_TABLE,
component: FieldComponents.STATIC_TABLE,
children: undefined,
id: 'relativesTable',
id: 'contactsTable',
title: '',
header: [
newPrimarySchoolMessages.shared.fullName,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { default as FriggOptionsAsyncSelectField } from './FriggOptionsAsyncSelectField'
export { default as RelativesTableRepeater } from './RelativesTableRepeater'
export { default as ContactsTableRepeater } from './ContactsTableRepeater'
export { Review } from './Review'
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {
buildCustomField,
buildMultiField,
buildSubSection,
} from '@island.is/application/core'
import { newPrimarySchoolMessages } from '../../../lib/messages'

export const contactsSubSection = buildSubSection({
id: 'contactsSubSection',
title: newPrimarySchoolMessages.childrenNParents.contactsSubSectionTitle,
children: [
buildMultiField({
id: 'contacts',
title: newPrimarySchoolMessages.childrenNParents.contactsTitle,
description:
newPrimarySchoolMessages.childrenNParents.contactsDescription,
children: [
buildCustomField({
id: 'contacts',
title: '',
component: 'ContactsTableRepeater',
}),
],
}),
],
})
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { buildSection } from '@island.is/application/core'
import { newPrimarySchoolMessages } from '../../../lib/messages'
import { childInfoSubSection } from './childInfoSubSection'
import { parentsSubSection } from './parentsSubSection'
import { relativesSubSection } from './relativesSubSection'
import { contactsSubSection } from './contactsSubSection'

export const childrenNParentsSection = buildSection({
id: 'childrenNParentsSection',
title: newPrimarySchoolMessages.childrenNParents.sectionTitle,
children: [childInfoSubSection, parentsSubSection, relativesSubSection],
children: [childInfoSubSection, parentsSubSection, contactsSubSection],
})

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const dataSchema = z.object({
})
.optional(),
}),
relatives: z
contacts: z
.array(
z.object({
fullName: z.string().min(1),
Expand All @@ -69,7 +69,7 @@ export const dataSchema = z.object({
}),
)
.refine((r) => r === undefined || r.length > 0, {
params: errorMessages.relativesRequired,
params: errorMessages.contactsRequired,
}),
reasonForApplication: z
.object({
Expand Down
70 changes: 35 additions & 35 deletions libs/application/templates/new-primary-school/src/lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,43 +259,43 @@ export const newPrimarySchoolMessages: MessageDir = {
'Information about parents/guardians is retrieved from Registers Iceland and from My Pages on Ísland.is. Check that phone numbers and email addresses are entered correctly before proceeding.',
},

// Relatives
relativesSubSectionTitle: {
id: 'nps.application:childrenNParents.relatives.sub.section.title',
defaultMessage: 'Aðstandendur',
description: 'Relatives',
},
relativesTitle: {
id: 'nps.application:childrenNParents.relatives.title',
defaultMessage: 'Aðstandendur barnsins',
description: "The child's relatives",
},
relativesDescription: {
id: 'nps.application:childrenNParents.relatives.description',
// Contacts
contactsSubSectionTitle: {
id: 'nps.application:childrenNParents.contacts.sub.section.title',
defaultMessage: 'Tengiliðir',
description: 'Contacts',
},
contactsTitle: {
id: 'nps.application:childrenNParents.contacts.title',
defaultMessage: 'Tengiliðir barns',
description: "The child's contacts",
},
contactsDescription: {
id: 'nps.application:childrenNParents.contacts.description',
defaultMessage:
'Skráðu að minnsta kosti einn tengilið sem má hafa samband við ef ekki næst í foreldra/forsjáraðila barnsins. Þú getur bætt við allt að sex aðstandendum. Vinsamlegast látið aðstandendur vita af skráningunni.',
'Skráðu að minnsta kosti einn tengilið sem má hafa samband við ef ekki næst í forsjáraðila barnsins. Þú getur bætt við allt að fjórum tengiliðum. Vinsamlegast látið tengiliði vita af skráningunni.',
description:
"List at least one contact person who can be contacted if the child's parents/guardian cannot be reached. You can add up to six relatives. Please inform the relatives of the registration.",
"List at least one contact person who can be contacted if the child's guardian cannot be reached. You can add up to four contacts. Please inform the contacts of the registration.",
},
relativesRegistrationTitle: {
id: 'nps.application:childrenNParents.relatives.registration.title',
defaultMessage: 'Skráning aðstandanda',
description: 'Registration of a relative',
contactsRegistrationTitle: {
id: 'nps.application:childrenNParents.contacts.registration.title',
defaultMessage: 'Skráning tengiliðs',
description: 'Registration of a contact',
},
relativesAddRelative: {
id: 'nps.application:childrenNParents.relatives.add.relative',
defaultMessage: 'Bæta við aðstandanda',
description: 'Add a relative',
contactsAddContact: {
id: 'nps.application:childrenNParents.contacts.add.contact',
defaultMessage: 'Bæta við tengilið',
description: 'Add a contact',
},
relativesRegisterRelative: {
id: 'nps.application:childrenNParents.relatives.register.relative',
defaultMessage: 'Skrá aðstandanda',
description: 'Register relative',
contactsRegisterContact: {
id: 'nps.application:childrenNParents.contacts.register.contact',
defaultMessage: 'Skrá tengilið',
description: 'Register contact',
},
relativesDeleteRelative: {
id: 'nps.application:childrenNParents.relatives.delete.relative',
defaultMessage: 'Eyða aðstandanda',
description: 'Remove relative',
contactsDeleteContact: {
id: 'nps.application:childrenNParents.contacts.delete.contact',
defaultMessage: 'Eyða tengilið',
description: 'Remove contact',
},
}),

Expand Down Expand Up @@ -757,10 +757,10 @@ export const errorMessages = defineMessages({
defaultMessage: 'Kennitala þarf að vera gild.',
description: 'National id must be valid',
},
relativesRequired: {
id: 'nps.application:error.relatives.required',
defaultMessage: 'Nauðsynlegt er að bæta við a.m.k einum aðstandenda',
description: 'You must add at least one relative',
contactsRequired: {
id: 'nps.application:error.contacts.required',
defaultMessage: 'Nauðsynlegt er að bæta við a.m.k einum tengilið',
description: 'You must add at least one contact',
},
siblingsRequired: {
id: 'nps.application:error.siblings.required',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
Membership,
Parents,
Person,
RelativesRow,
ContactsRow,
SelectOption,
SiblingsRow,
} from '../types'
Expand All @@ -31,7 +31,7 @@ export const getApplicationAnswers = (answers: Application['answers']) => {

const parents = getValueViaPath(answers, 'parents') as Parents

const relatives = getValueViaPath(answers, 'relatives') as RelativesRow[]
const contacts = getValueViaPath(answers, 'contacts') as ContactsRow[]

const reasonForApplication = getValueViaPath(
answers,
Expand Down Expand Up @@ -163,7 +163,7 @@ export const getApplicationAnswers = (answers: Application['answers']) => {
childInfo,
differentPlaceOfResidence,
parents,
relatives,
contacts,
reasonForApplication,
reasonForApplicationCountry,
reasonForApplicationStreetAddress,
Expand Down
2 changes: 1 addition & 1 deletion libs/application/templates/new-primary-school/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MembershipOrganizationType, MembershipRole } from './lib/constants'

export interface RelativesRow {
export interface ContactsRow {
fullName: string
phoneNumber: string
nationalId: string
Expand Down

0 comments on commit 6691f54

Please sign in to comment.