Files
twenty_crm/front/src/modules/ui/display/component/InplaceInputPhoneDisplayMode.tsx
Charles Bochet 8601ed04ae Add dueDate and assignee on notes (#988)
* Add dueDate and assignee on notes

* Fix tests

* Fix tests
2023-07-29 15:36:21 -07:00

35 lines
849 B
TypeScript

import { MouseEvent } from 'react';
import styled from '@emotion/styled';
import { isValidPhoneNumber, parsePhoneNumber } from 'libphonenumber-js';
import { RawLink } from '@/ui/link/components/RawLink';
const StyledRawLink = styled(RawLink)`
overflow: hidden;
a {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
`;
type OwnProps = {
value: string | null;
};
export function InplaceInputPhoneDisplayMode({ value }: OwnProps) {
return value && isValidPhoneNumber(value) ? (
<StyledRawLink
href={parsePhoneNumber(value, 'FR')?.getURI()}
onClick={(event: MouseEvent<HTMLElement>) => {
event.stopPropagation();
}}
>
{parsePhoneNumber(value, 'FR')?.formatInternational() || value}
</StyledRawLink>
) : (
<StyledRawLink href="#">{value}</StyledRawLink>
);
}