Skip to content

Commit

Permalink
fix(estate): foreign phone numbers (#15826)
Browse files Browse the repository at this point in the history
  • Loading branch information
albinagu authored and jonnigs committed Sep 2, 2024
1 parent d5a49f7 commit cc3ff7d
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
} from '@island.is/island-ui/core'
import { m } from '../../lib/messages'
import * as kennitala from 'kennitala'
import { EstateRegistrant } from '@island.is/clients/syslumenn'
import { Answers, EstateMember } from '../../types'
import { AdditionalEstateMember } from './AdditionalEstateMember'
import { getValueViaPath } from '@island.is/application/core'
Expand Down Expand Up @@ -175,7 +174,12 @@ export const EstateMembersRepeater: FC<
...acc,
<Box marginTop={index > 0 ? 7 : 0} key={index}>
<Box display="flex" justifyContent="spaceBetween" marginBottom={3}>
<Text variant="h4">{formatMessage(m.estateMember)}</Text>
<Text
color={member.enabled ? 'currentColor' : 'dark300'}
variant="h4"
>
{formatMessage(m.estateMember)}
</Text>
<Box>
<Button
variant="text"
Expand Down Expand Up @@ -349,13 +353,12 @@ export const EstateMembersRepeater: FC<
/>
</GridColumn>
<GridColumn span={['1/1', '1/2']} paddingBottom={2}>
<InputController
<PhoneInputController
id={`${id}[${index}].advocate.phone`}
name={`${id}[${index}].advocate.phone`}
label={formatMessage(m.phone)}
backgroundColor="blue"
disabled={!member.enabled}
format="###-####"
defaultValue={member.advocate?.phone || ''}
error={
error && error[index] && error[index].advocate?.phone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ export const announcerInfo = buildSection({
title: m.phone,
width: 'half',
required: true,
disableDropdown: true,
allowedCountryCodes: ['IS'],
disableDropdown: false,
defaultValue: (application: Application) => {
const phone =
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
CheckboxController,
DatePickerController,
InputController,
PhoneInputController,
SelectController,
} from '@island.is/shared/form-fields'
import * as kennitala from 'kennitala'
Expand Down Expand Up @@ -229,13 +230,12 @@ export const AdditionalHeir = ({
/>
</GridColumn>
<GridColumn span={['1/1', '1/2']} paddingBottom={2}>
<InputController
<PhoneInputController
id={phoneField}
name={phoneField}
label={formatMessage(m.phone)}
defaultValue={field.phone || ''}
backgroundColor="blue"
format={'###-####'}
error={error?.phone}
required
/>
Expand Down Expand Up @@ -354,12 +354,11 @@ export const AdditionalHeir = ({
/>
</GridColumn>
<GridColumn span={['1/1', '1/2']} paddingBottom={2}>
<InputController
<PhoneInputController
id={advocatePhoneField}
name={advocatePhoneField}
label={formatMessage(m.phone)}
backgroundColor="blue"
format="###-####"
error={(error?.advocate as unknown as ErrorValue)?.phone}
size="sm"
required
Expand Down Expand Up @@ -409,12 +408,11 @@ export const AdditionalHeir = ({
/>
</GridColumn>
<GridColumn span={['1/1', '1/2']} paddingBottom={2}>
<InputController
<PhoneInputController
id={advocatePhoneField2}
name={advocatePhoneField2}
label={formatMessage(m.phone)}
backgroundColor="blue"
format="###-####"
size="sm"
/>
</GridColumn>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ import { formatCurrency } from '@island.is/application/ui-components'
import { Answers, EstateMember, heirAgeValidation } from '../../types'
import { AdditionalHeir } from './AdditionalHeir'
import { getValueViaPath } from '@island.is/application/core'
import { InputController } from '@island.is/shared/form-fields'
import {
InputController,
PhoneInputController,
} from '@island.is/shared/form-fields'
import { format as formatNationalId, info } from 'kennitala'
import intervalToDuration from 'date-fns/intervalToDuration'
import {
Expand Down Expand Up @@ -404,13 +407,12 @@ export const HeirsRepeater: FC<
/>
</GridColumn>
<GridColumn span={['1/1', '1/2']} paddingBottom={2}>
<InputController
<PhoneInputController
id={`${fieldIndex}.phone`}
name={`${fieldIndex}.phone`}
label={formatMessage(m.phone)}
backgroundColor="blue"
disabled={!member.enabled}
format="###-####"
defaultValue={member.phone || ''}
error={
error && error[mainIndex] && error[mainIndex].phone
Expand Down Expand Up @@ -529,13 +531,12 @@ export const HeirsRepeater: FC<
/>
</GridColumn>
<GridColumn span={['1/1', '1/2']} paddingBottom={2}>
<InputController
<PhoneInputController
id={`${fieldIndex}.advocate.phone`}
name={`${fieldIndex}.advocate.phone`}
label={formatMessage(m.phone)}
backgroundColor="blue"
disabled={!member.enabled}
format="###-####"
defaultValue={member.advocate?.phone || ''}
error={
error &&
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
buildMultiField,
buildPhoneField,
buildSection,
buildSelectField,
buildTextField,
Expand Down Expand Up @@ -48,12 +49,12 @@ export const applicant = buildSection({
return externalData.nationalRegistry?.data.address.streetAddress
},
}),
buildTextField({
buildPhoneField({
id: 'applicant.phone',
title: m.phone,
width: 'half',
required: true,
format: '###-####',
disableDropdown: false,
defaultValue: (application: Application) => {
const phone =
(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import {
buildMultiField,
buildNationalIdWithNameField,
buildPhoneField,
buildSection,
buildSelectField,
buildTextField,
} from '@island.is/application/core'
import { UserProfile, Application } from '@island.is/api/schema'
import { removeCountryCode } from '@island.is/application/ui-components'
import { m } from '../../../lib/messages'
import { RelationEnum } from '../../../types'

Expand All @@ -25,32 +24,18 @@ export const prePaidApplicant = buildSection({
width: 'full',
required: true,
}),
buildTextField({
buildPhoneField({
id: 'prePaidApplicant.phone',
title: m.phone,
width: 'half',
required: true,
format: '###-####',
defaultValue: (application: Application) => {
const phone =
(
application.externalData.userProfile?.data as {
mobilePhoneNumber?: string
}
)?.mobilePhoneNumber ?? ''

return removeCountryCode(phone)
},
disableDropdown: false,
}),
buildTextField({
id: 'prePaidApplicant.email',
title: m.email,
width: 'half',
required: true,
defaultValue: ({ externalData }: Application) => {
const data = externalData.userProfile?.data as UserProfile
return data?.email
},
}),
buildSelectField({
id: 'prePaidApplicant.relation',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const inheritanceExecutor = buildSection({
title: m.phone,
width: 'half',
required: true,
disableDropdown: false,
}),
buildDescriptionField({
id: 'description_empty',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
PrePaidInheritanceOptions,
RelationSpouse,
} from './constants'
import { DebtTypes } from '../types'

const deceasedShare = {
deceasedShare: z.string().nonempty().optional(),
Expand Down

0 comments on commit cc3ff7d

Please sign in to comment.