Skip to content

Commit

Permalink
feat(new-primary-school): Siblings relation column removal (#17450)
Browse files Browse the repository at this point in the history
* feat(new-primary-school): Siblings relation column removal

* remove unused messages and comment

---------

Co-authored-by: hfhelgason <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jan 14, 2025
1 parent 28d8564 commit 4785092
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 153 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,66 +38,6 @@ export class NewPrimarySchoolService extends BaseTemplateApiService {
}

async getChildren({ auth }: TemplateApiModuleActionProps) {
if (isRunningOnEnvironment('dev')) {
if (auth.nationalId === '0101303019') {
return [
{
nationalId: '1111111119',
fullName: 'Stubbur Maack',
genderCode: '3',
livesWithApplicant: true,
livesWithBothParents: true,
},
]
}
if (auth.nationalId === '0101302989') {
return [
{
nationalId: '2222222229',
fullName: 'Stúfur Maack ',
genderCode: '3',
livesWithApplicant: true,
livesWithBothParents: true,
otherParent: {
nationalId: '0101302399',
fullName: 'Gervimaður Færeyjar',
address: {
streetName: 'Hvassaleiti 5',
postalCode: '103',
city: 'Reykjavík',
municipalityCode: '0000',
},
genderCode: '2',
},
},
{
nationalId: '5555555559',
fullName: 'Bína Maack ',
genderCode: '4',
livesWithApplicant: true,
livesWithBothParents: true,
},
{
nationalId: '6666666669',
fullName: 'Snúður Maack',
genderCode: '3',
livesWithApplicant: true,
livesWithBothParents: true,
},
]
}
if (auth.nationalId === '0101304929') {
return [
{
nationalId: '6666666669',
fullName: 'Snúður Maack',
genderCode: '3',
livesWithApplicant: true,
livesWithBothParents: true,
},
]
}
}
const children =
await this.nationalRegistryService.getChildrenCustodyInformation(auth)

Expand All @@ -115,7 +55,7 @@ export class NewPrimarySchoolService extends BaseTemplateApiService {
'6666666669',
]
if (
isRunningOnEnvironment('local') &&
(isRunningOnEnvironment('local') || isRunningOnEnvironment('dev')) &&
validChildren.includes(child.nationalId)
) {
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ export const transformApplicationToNewPrimarySchoolDTO = (
? siblings.map((sibling) => ({
name: sibling.fullName,
nationalId: sibling.nationalId,
// TODO: Siblings relation options are not in the key-options endpoint => Júní has added "sibling" (We need to make sure that those options do not appear in the dropdown on the relatives page)
// TODO: We are waiting for a reply from MMS if this is important information or if we should remove it
role: sibling.relation,
role: 'sibling',
}))
: []),
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import { Box, GridColumn, GridRow } from '@island.is/island-ui/core'
import { useLocale } from '@island.is/localization'
import { format as formatKennitala } from 'kennitala'
import { newPrimarySchoolMessages } from '../../../lib/messages'
import {
getApplicationAnswers,
getSiblingRelationOptionLabel,
} from '../../../lib/newPrimarySchoolUtils'
import { getApplicationAnswers } from '../../../lib/newPrimarySchoolUtils'
import { ReviewGroupProps } from './props'

export const Siblings = ({
Expand All @@ -20,11 +17,7 @@ export const Siblings = ({
const { siblings } = getApplicationAnswers(application.answers)

const rows = siblings.map((s) => {
return [
s.fullName,
formatKennitala(s.nationalId),
getSiblingRelationOptionLabel(s.relation),
]
return [s.fullName, formatKennitala(s.nationalId)]
})

return (
Expand Down Expand Up @@ -52,7 +45,6 @@ export const Siblings = ({
header: [
newPrimarySchoolMessages.shared.fullName,
newPrimarySchoolMessages.shared.nationalId,
newPrimarySchoolMessages.shared.relation,
],
rows,
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,9 @@ import {
buildTableRepeaterField,
} from '@island.is/application/core'
import { format as formatKennitala } from 'kennitala'
import {
ReasonForApplicationOptions,
SiblingRelationOptions,
} from '../../../lib/constants'
import { ReasonForApplicationOptions } from '../../../lib/constants'
import { newPrimarySchoolMessages } from '../../../lib/messages'
import {
getApplicationAnswers,
getSiblingRelationOptionLabel,
getSiblingRelationOptions,
} from '../../../lib/newPrimarySchoolUtils'
import { getApplicationAnswers } from '../../../lib/newPrimarySchoolUtils'

export const siblingsSubSection = buildSubSection({
id: 'siblingsSubSection',
Expand Down Expand Up @@ -60,25 +53,14 @@ export const siblingsSubSection = buildSubSection({
placeholder: '000000-0000',
dataTestId: 'sibling-national-id',
},
relation: {
component: 'select',
label: newPrimarySchoolMessages.shared.relation,
placeholder: newPrimarySchoolMessages.shared.relationPlaceholder,
// TODO: Nota gögn fá Júní
options: getSiblingRelationOptions(),
dataTestId: 'sibling-relation',
},
},
table: {
format: {
nationalId: (value) => formatKennitala(value),
relation: (value) =>
getSiblingRelationOptionLabel(value as SiblingRelationOptions),
},
header: [
newPrimarySchoolMessages.shared.fullName,
newPrimarySchoolMessages.shared.nationalId,
newPrimarySchoolMessages.shared.relation,
],
},
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ export enum ReasonForApplicationOptions {
SIBLINGS_IN_SAME_SCHOOL = 'SiblingsInSameSchool',
}

export enum SiblingRelationOptions {
SIBLING = 'sibling',
HALF_SIBLING = 'halfSibling',
STEP_SIBLING = 'stepSibling',
}

export enum OptionsType {
PRONOUN = 'pronoun',
GENDER = 'gender',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import { NO, YES } from '@island.is/application/types'
import * as kennitala from 'kennitala'
import { parsePhoneNumberFromString } from 'libphonenumber-js'
import { z } from 'zod'
import {
ReasonForApplicationOptions,
SiblingRelationOptions,
} from './constants'
import { ReasonForApplicationOptions } from './constants'
import { errorMessages } from './messages'

const validatePhoneNumber = (value: string) => {
Expand Down Expand Up @@ -131,7 +128,6 @@ export const dataSchema = z.object({
nationalId: z.string().refine((n) => kennitala.isValid(n), {
params: errorMessages.nationalId,
}),
relation: z.nativeEnum(SiblingRelationOptions),
}),
)
.refine((r) => r === undefined || r.length > 0, {
Expand Down
15 changes: 0 additions & 15 deletions libs/application/templates/new-primary-school/src/lib/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,21 +372,6 @@ export const newPrimarySchoolMessages: MessageDir = {
defaultMessage: 'Eyða systkini',
description: 'Remove sibling',
},
siblingsRelationSibling: {
id: 'nps.application:primary.school.siblings.relation.sibling',
defaultMessage: 'Alsystkini',
description: 'Sibling',
},
halfSiblingsRelationSibling: {
id: 'nps.application:primary.school.siblings.relation.half.sibling',
defaultMessage: 'Hálfsystkini',
description: 'Half sibling',
},
stepSiblingsRelationSibling: {
id: 'nps.application:primary.school.siblings.relation.step.sibling',
defaultMessage: 'Stjúpsystkini',
description: 'Step sibling',
},

// Apply to a new school
newSchoolSubSectionTitle: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,7 @@ import {
SelectOption,
SiblingsRow,
} from '../types'
import {
ReasonForApplicationOptions,
SiblingRelationOptions,
} from './constants'
import { newPrimarySchoolMessages } from './messages'
import { ReasonForApplicationOptions } from './constants'

export const getApplicationAnswers = (answers: Application['answers']) => {
const childNationalId = getValueViaPath(answers, 'childNationalId') as string
Expand Down Expand Up @@ -278,28 +274,6 @@ export const hasOtherParent = (
return !!otherParent
}

export const getSiblingRelationOptions = () => [
{
value: SiblingRelationOptions.SIBLING,
label: newPrimarySchoolMessages.primarySchool.siblingsRelationSibling,
},
{
value: SiblingRelationOptions.HALF_SIBLING,
label: newPrimarySchoolMessages.primarySchool.halfSiblingsRelationSibling,
},
{
value: SiblingRelationOptions.STEP_SIBLING,
label: newPrimarySchoolMessages.primarySchool.stepSiblingsRelationSibling,
},
]

export const getSiblingRelationOptionLabel = (
value: SiblingRelationOptions,
) => {
const relationOptions = getSiblingRelationOptions()
return relationOptions.find((option) => option.value === value)?.label ?? ''
}

export const getSelectedOptionLabel = (
options: SelectOption[],
key?: string,
Expand Down
7 changes: 1 addition & 6 deletions libs/application/templates/new-primary-school/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
MembershipOrganizationType,
MembershipRole,
SiblingRelationOptions,
} from './lib/constants'
import { MembershipOrganizationType, MembershipRole } from './lib/constants'

export interface RelativesRow {
fullName: string
Expand All @@ -14,7 +10,6 @@ export interface RelativesRow {
export interface SiblingsRow {
fullName: string
nationalId: string
relation: SiblingRelationOptions
}

export type Child = {
Expand Down

0 comments on commit 4785092

Please sign in to comment.