diff --git a/packages/twenty-front/src/modules/ui/field/display/components/PhonesDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/PhonesDisplay.tsx index 04423ff32..17e9d27f4 100644 --- a/packages/twenty-front/src/modules/ui/field/display/components/PhonesDisplay.tsx +++ b/packages/twenty-front/src/modules/ui/field/display/components/PhonesDisplay.tsx @@ -8,6 +8,7 @@ import { RoundedLink } from '@/ui/navigation/link/components/RoundedLink'; import { parsePhoneNumber } from 'libphonenumber-js'; import { isDefined } from '~/utils/isDefined'; +import { logError } from '~/utils/logError'; type PhonesDisplayProps = { value?: FieldPhonesValue; @@ -39,7 +40,7 @@ export const PhonesDisplay = ({ value, isFocused }: PhonesDisplayProps) => { countryCode: value.primaryPhoneCountryCode, } : null, - ...(value?.additionalPhones ?? []), + ...parseAdditionalPhones(value?.additionalPhones), ] .filter(isDefined) .map(({ number, countryCode }) => { @@ -85,3 +86,23 @@ export const PhonesDisplay = ({ value, isFocused }: PhonesDisplayProps) => { ); }; + +const parseAdditionalPhones = (additionalPhones?: any) => { + if (!additionalPhones) { + return []; + } + + if (typeof additionalPhones === 'object') { + return additionalPhones; + } + + if (typeof additionalPhones === 'string') { + try { + return JSON.parse(additionalPhones); + } catch (error) { + logError(`Error parsing additional phones' : ` + error); + } + } + + return []; +};