Files
twenty/front/src/modules/ui/input/phone/components/PhoneInputDisplay.tsx
Mustajab Ikram 4f7e1fb60e Feat/phone email link enhancements (#1172)
* feat: Add type guards for ViewField email values and definitions, update ViewFieldTypes & peopleViewFields

* feat: use ContactLink for EditablePhoneCell & create EditableEmailCell & EmailInputDisplay comp

* fix: set second value for field

* enhance: add edit btn for phone cell

* feat: install dependencies intl-tel-input

* feat: add phone cell input & connect intl-tel-input

* fix: resolve rebase errors

* fix: remove placeholder

* feat(storybook): create stories for EmailInputDisplay, PhoneInputDisplay, and PhoneEditableField components

---------

Co-authored-by: Charles Bochet <charlesBochet@users.noreply.github.com>
2023-08-25 18:42:22 +02:00

24 lines
650 B
TypeScript

import { MouseEvent } from 'react';
import { isValidPhoneNumber, parsePhoneNumber } from 'libphonenumber-js';
import { ContactLink } from '@/ui/link/components/ContactLink';
type OwnProps = {
value: string | null;
};
export function PhoneInputDisplay({ value }: OwnProps) {
return value && isValidPhoneNumber(value) ? (
<ContactLink
href={parsePhoneNumber(value, 'FR')?.getURI()}
onClick={(event: MouseEvent<HTMLElement>) => {
event.stopPropagation();
}}
>
{parsePhoneNumber(value, 'FR')?.formatInternational() || value}
</ContactLink>
) : (
<ContactLink href="#">{value}</ContactLink>
);
}