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

fix(appliaction-estate): Catch if preregistered heirs are foreign citizens #16362

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 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
Expand Up @@ -4,6 +4,3 @@ export const EstateTypes = {
permitForUndividedEstate: 'Seta í óskiptu búi',
divisionOfEstateByHeirs: 'Einkaskipti',
}

export const YES = 'Yes'
export const NO = 'No'
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { NO, YES } from '@island.is/application/core'

export interface Address {
streetAddress: string
postalCode: string
Expand Down Expand Up @@ -35,7 +37,7 @@ type EstateMember = {
relationWithApplicant?: string
dateOfBirth?: string
foreignCitizenship?: string | string[]
noContactInfo?: ('Yes' | 'No')[]
noContactInfo?: (typeof YES | typeof NO)[]
phone?: string
email?: string
advocate?: Advocate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const getFakeEstateInfo = (
share: 100,
},
],
knowledgeOfOtherWills: 'Yes',
knowledgeOfOtherWills: 'yes',
juni-haukur marked this conversation as resolved.
Show resolved Hide resolved
ships: [],
flyers: [],
guns: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { infer as zinfer } from 'zod'
import { UploadData } from '../types'
import { filterEmptyObjects } from './filters'
import { info } from 'kennitala'
import { NO, YES } from '@island.is/application/core'

type EstateSchema = zinfer<typeof estateSchema>
type EstateData = EstateSchema['estate']
Expand All @@ -30,7 +31,7 @@ const estateMemberMapper = (element: EstateMember) => {
phone: element.phone ?? '',
email: element.email ?? '',
relationWithApplicant: '',
noContactInfo: ['No'] as ('Yes' | 'No')[],
noContactInfo: [NO] as (typeof YES | typeof NO)[],
advocate: element.advocate
? {
...element.advocate,
Expand All @@ -40,6 +41,11 @@ const estateMemberMapper = (element: EstateMember) => {
: info(element?.nationalId).age < 18
? { nationalId: '', name: '', phone: '', email: '' }
: undefined,
foreignCitizenship:
juni-haukur marked this conversation as resolved.
Show resolved Hide resolved
element.foreignCitizenship ??
(!element.nationalId || element.nationalId.endsWith('0000')
? [YES]
: [NO]),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ import {
Text,
} from '@island.is/island-ui/core'
import { m } from '../../lib/messages'
import { EstateTypes, YES } from '../../lib/constants'
import { EstateTypes } from '../../lib/constants'
import intervalToDuration from 'date-fns/intervalToDuration'
import { GenericFormField, Application } from '@island.is/application/types'
import { ErrorValue, EstateMember } from '../../types'
import { hasYes } from '@island.is/application/core'
import { hasYes, YES } from '@island.is/application/core'
import { LookupPerson } from '../LookupPerson'
import { useEffect } from 'react'

Expand Down Expand Up @@ -122,7 +122,7 @@ export const AdditionalEstateMember = ({
</Button>
</Box>
</Box>
{foreignCitizenship?.length ? (
{foreignCitizenship?.[0] === YES ? (
<GridRow>
<GridColumn span={['1/1', '1/2']} paddingBottom={2} paddingTop={2}>
<InputController
Expand Down Expand Up @@ -152,6 +152,7 @@ export const AdditionalEstateMember = ({
setValue(dateOfBirthField, d)
}}
error={error?.dateOfBirth ?? undefined}
required
/>
</GridColumn>
</GridRow>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@ import { m } from '../../lib/messages'
import * as kennitala from 'kennitala'
import { Answers, EstateMember } from '../../types'
import { AdditionalEstateMember } from './AdditionalEstateMember'
import { getValueViaPath } from '@island.is/application/core'
import { getValueViaPath, YES } from '@island.is/application/core'
import {
CheckboxController,
DatePickerController,
InputController,
PhoneInputController,
SelectController,
} from '@island.is/shared/form-fields'
import { format as formatNationalId } from 'kennitala'
import {
EstateTypes,
NO,
YES,
heirAgeValidation,
relationWithApplicant,
} from '../../lib/constants'
Expand All @@ -46,7 +45,7 @@ export const EstateMembersRepeater: FC<

const hasEstateMemberUnder18 = values.estate?.estateMembers?.some(
(member: EstateMember) => {
const hasForeignCitizenship = member?.foreignCitizenship?.[0] === 'yes'
const hasForeignCitizenship = member?.foreignCitizenship?.[0] === YES
const birthDate = member?.dateOfBirth
const memberAge =
hasForeignCitizenship && birthDate
Expand Down Expand Up @@ -204,29 +203,78 @@ export const EstateMembersRepeater: FC<
</Box>
</Box>
<GridRow>
<GridColumn span={['1/1', '1/2']} paddingBottom={2}>
<InputController
id={`${id}[${index}].nationalId`}
name={`${id}[${index}].nationalId`}
label={formatMessage(m.inheritanceKtLabel)}
defaultValue={formatNationalId(member.nationalId || '')}
backgroundColor="white"
disabled={!member.enabled}
format={'######-####'}
error={error && error[index] && error[index].nationalId}
/>
</GridColumn>
<GridColumn span={['1/1', '1/2']} paddingBottom={2}>
<InputController
id={`${id}[${index}].name`}
name={`${id}[${index}].name`}
label={formatMessage(m.inheritanceNameLabel)}
readOnly
defaultValue={member.name || ''}
backgroundColor="white"
disabled={!member.enabled}
/>
</GridColumn>
{member.foreignCitizenship?.[0] === YES ? (
juni-haukur marked this conversation as resolved.
Show resolved Hide resolved
<>
<GridColumn
span={['1/1', '1/2']}
paddingBottom={2}
paddingTop={2}
>
<InputController
key={`${id}[${index}].name`}
id={`${id}[${index}].name`}
name={`${id}[${index}].name`}
backgroundColor="blue"
defaultValue={member.name}
error={error?.name ?? undefined}
label={formatMessage(m.inheritanceNameLabel)}
required
disabled={!member.enabled}
readOnly
/>
</GridColumn>
<GridColumn
span={['1/1', '1/2']}
paddingBottom={2}
paddingTop={2}
>
<DatePickerController
label={formatMessage(m.inheritanceDayOfBirthLabel)}
placeholder={formatMessage(m.inheritanceDayOfBirthLabel)}
key={`${id}[${index}].dateOfBirth`}
id={`${id}[${index}].dateOfBirth`}
name={`${id}[${index}].dateOfBirth`}
locale="is"
maxDate={new Date()}
minYear={1900}
maxYear={new Date().getFullYear()}
backgroundColor="blue"
onChange={(d) => {
setValue(`${id}[${index}].dateOfBirth`, d)
}}
error={error && error[index] && error[index].dateOfBirth}
juni-haukur marked this conversation as resolved.
Show resolved Hide resolved
required
disabled={!member.enabled}
/>
</GridColumn>
</>
) : (
<>
<GridColumn span={['1/1', '1/2']} paddingBottom={2}>
<InputController
id={`${id}[${index}].nationalId`}
name={`${id}[${index}].nationalId`}
label={formatMessage(m.inheritanceKtLabel)}
defaultValue={formatNationalId(member.nationalId || '')}
backgroundColor="white"
disabled={!member.enabled}
format={'######-####'}
error={error && error[index] && error[index].nationalId}
juni-haukur marked this conversation as resolved.
Show resolved Hide resolved
/>
</GridColumn>
<GridColumn span={['1/1', '1/2']} paddingBottom={2}>
<InputController
id={`${id}[${index}].name`}
name={`${id}[${index}].name`}
label={formatMessage(m.inheritanceNameLabel)}
readOnly
defaultValue={member.name}
backgroundColor="white"
disabled={!member.enabled}
/>
</GridColumn>
</>
)}
<GridColumn span={['1/1', '1/2']} paddingBottom={2}>
<InputController
id={`${id}[${index}].relation`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import {
buildDividerField,
buildKeyValueField,
getValueViaPath,
YES,
} from '@island.is/application/core'
import { Application } from '@island.is/application/types'
import { EstateInfo } from '@island.is/clients/syslumenn'
import { m } from '../../lib/messages'
import { deceasedInfoFields } from '../Sections/deceasedInfoFields'
import { format as formatNationalId } from 'kennitala'
import { formatPhoneNumber } from '@island.is/application/ui-components'
import { JA, NEI, YES } from '../../lib/constants'
import { JA, NEI } from '../../lib/constants'
import format from 'date-fns/format'

export const commonOverviewFields = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import {
buildCheckboxField,
getValueViaPath,
YES,
} from '@island.is/application/core'
import { m } from '../../lib/messages'
import { EstateTypes, YES } from '../../lib/constants'
import { EstateTypes } from '../../lib/constants'

export const overviewConfirmAction = [
buildCheckboxField({
Expand Down
4 changes: 3 additions & 1 deletion libs/application/templates/estate/src/forms/Overviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import {
buildSection,
buildSubmitField,
getValueViaPath,
NO,
YES,
} from '@island.is/application/core'
import { DefaultEvents } from '@island.is/application/types'
import { m } from '../lib/messages'
import { commonOverviewFields } from './OverviewSections/commonFields'
import { overviewAssetsAndDebts } from './OverviewSections/assetsAndDebts'
import { overviewAttachments } from './OverviewSections/attachments'
import { overviewConfirmAction } from './OverviewSections/confirmAction'
import { EstateTypes, YES, NO } from '../lib/constants'
import { EstateTypes } from '../lib/constants'
import { deceasedInfoFields } from './Sections/deceasedInfoFields'
import { representativeOverview } from './OverviewSections/representative'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import {
buildSection,
buildSelectField,
buildTextField,
NO,
YES,
} from '@island.is/application/core'
import { JA, YES, NEI, NO } from '../../lib/constants'
import { JA, NEI } from '../../lib/constants'
import { m } from '../../lib/messages'
import { format as formatNationalId } from 'kennitala'
import { EstateTypes } from '../../lib/constants'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {
buildMultiField,
buildCheckboxField,
buildSection,
YES,
} from '@island.is/application/core'
import { m } from '../../lib/messages'
juni-haukur marked this conversation as resolved.
Show resolved Hide resolved
import { YES } from '../../lib/constants'

export const approvePrivateDivisionSubmission = buildSection({
id: 'approveSubmission',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import {
buildCustomField,
buildSubSection,
getValueViaPath,
YES,
} from '@island.is/application/core'
import { m } from '../../lib/messages'
import { EstateTypes, YES } from '../../lib/constants'
import { EstateTypes } from '../../lib/constants'
import { getAssetDescriptionText } from '../../lib/utils'

export const estateAssets = buildSection({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import {
buildMultiField,
buildCustomField,
getValueViaPath,
YES,
} from '@island.is/application/core'
import { m } from '../../lib/messages'
import { EstateTypes, YES } from '../../lib/constants'
import { EstateTypes } from '../../lib/constants'

export const estateDebts = buildSection({
id: 'debts',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import {
buildMultiField,
buildRadioField,
getValueViaPath,
YES,
NO,
} from '@island.is/application/core'
import { m } from '../../lib/messages'
import { JA, YES, NEI, NO } from '../../lib/constants'
import { JA, NEI } from '../../lib/constants'

export const estateWithoutAssets = buildSection({
id: 'estateAssetsExist',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import {
buildRadioField,
getValueViaPath,
buildCustomField,
YES,
NO,
} from '@island.is/application/core'
import { JA, YES, NEI, NO } from '../../lib/constants'
import { JA, NEI } from '../../lib/constants'
juni-haukur marked this conversation as resolved.
Show resolved Hide resolved
import { deceasedInfoFields } from './deceasedInfoFields'
import { m } from '../../lib/messages'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import {
buildRadioField,
buildTextField,
getValueViaPath,
YES,
NO,
} from '@island.is/application/core'
import { m } from '../../lib/messages'
import { JA, YES, NEI, NO, EstateTypes } from '../../lib/constants'
import { JA, NEI, EstateTypes } from '../../lib/constants'
import { getWillsAndAgreementsDescriptionText } from '../../lib/utils'

export const testamentInfo = buildSection({
Expand Down
3 changes: 0 additions & 3 deletions libs/application/templates/estate/src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { DefaultEvents } from '@island.is/application/types'

export const YES = 'Yes'
export const NO = 'No'

export const JA = 'Já'
export const NEI = 'Nei'

Expand Down
Loading