Skip to content

Commit

Permalink
Merge branch 'main' into j-s/complete-indictment-review
Browse files Browse the repository at this point in the history
  • Loading branch information
unakb authored May 10, 2024
2 parents 30e101c + 1e05ec6 commit b6581dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { InputController } from '@island.is/shared/form-fields'
import { format as formatNationalId } from 'kennitala'
import intervalToDuration from 'date-fns/intervalToDuration'
import {
formatPhoneNumber,
getEstateDataFromApplication,
valueToNumber,
} from '../../lib/utils/helpers'
Expand Down Expand Up @@ -273,6 +274,7 @@ export const HeirsAndPartitionRepeater: FC<
(heir) => {
return {
...heir,
phone: heir.phone ? formatPhoneNumber(heir.phone) : '', //Remove all non-digit characters and keep the last 7 digits
initial: true,
enabled: true,
}
Expand Down Expand Up @@ -560,7 +562,6 @@ export const HeirsAndPartitionRepeater: FC<
)}
{fields.map((member: GenericFormField<EstateMember>, index) => {
if (member.initial) return null

return (
<Box key={member.id}>
<AdditionalHeir
Expand All @@ -571,7 +572,7 @@ export const HeirsAndPartitionRepeater: FC<
relationOptions={relations}
updateValues={updateValues}
remove={remove}
error={error ?? null}
error={error[index] ?? null}
/>
</Box>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ export const isValidPhoneNumber = (phoneNumber: string) => {
return phone && phone.isValid()
}

export const formatPhoneNumber = (phoneNumber: string) => {
return phoneNumber.replace(/\D/g, '').slice(-7)
}

/**
* Returns zero if value is not a number or number string
* @param value
Expand Down

0 comments on commit b6581dd

Please sign in to comment.