mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-11 11:32:27 +03:00
Fix phone cell display (#4924)
Closes #4796 ## What has been done - fix phone number value detection - Update formatting from International format to National format ## Before phone were formatted as text field type ![image](https://github.com/twentyhq/twenty/assets/29927851/27d87522-5b02-4131-8b83-6bce7501fb1b) ## After phone are properly formatted in National format ![image](https://github.com/twentyhq/twenty/assets/29927851/72f71b0f-4fd7-4060-afe3-feb87bddab0d) ## FYI Phones in International format look like ![image](https://github.com/twentyhq/twenty/assets/29927851/6bd47dc1-6350-46b9-b5fd-94f4344bffac)
This commit is contained in:
parent
a7fcc5d47e
commit
ee64576e5f
@ -34,13 +34,18 @@ import { isFieldUuid } from '../types/guards/isFieldUuid';
|
|||||||
export const FieldDisplay = () => {
|
export const FieldDisplay = () => {
|
||||||
const { fieldDefinition, isLabelIdentifier } = useContext(FieldContext);
|
const { fieldDefinition, isLabelIdentifier } = useContext(FieldContext);
|
||||||
|
|
||||||
return isLabelIdentifier &&
|
const isChipDisplay =
|
||||||
|
isLabelIdentifier &&
|
||||||
(isFieldText(fieldDefinition) ||
|
(isFieldText(fieldDefinition) ||
|
||||||
isFieldFullName(fieldDefinition) ||
|
isFieldFullName(fieldDefinition) ||
|
||||||
isFieldNumber(fieldDefinition)) ? (
|
isFieldNumber(fieldDefinition));
|
||||||
|
|
||||||
|
return isChipDisplay ? (
|
||||||
<ChipFieldDisplay />
|
<ChipFieldDisplay />
|
||||||
) : isFieldRelation(fieldDefinition) ? (
|
) : isFieldRelation(fieldDefinition) ? (
|
||||||
<RelationFieldDisplay />
|
<RelationFieldDisplay />
|
||||||
|
) : isFieldPhone(fieldDefinition) ? (
|
||||||
|
<PhoneFieldDisplay />
|
||||||
) : isFieldText(fieldDefinition) ? (
|
) : isFieldText(fieldDefinition) ? (
|
||||||
<TextFieldDisplay />
|
<TextFieldDisplay />
|
||||||
) : isFieldUuid(fieldDefinition) ? (
|
) : isFieldUuid(fieldDefinition) ? (
|
||||||
@ -57,8 +62,6 @@ export const FieldDisplay = () => {
|
|||||||
<CurrencyFieldDisplay />
|
<CurrencyFieldDisplay />
|
||||||
) : isFieldFullName(fieldDefinition) ? (
|
) : isFieldFullName(fieldDefinition) ? (
|
||||||
<FullNameFieldDisplay />
|
<FullNameFieldDisplay />
|
||||||
) : isFieldPhone(fieldDefinition) ? (
|
|
||||||
<PhoneFieldDisplay />
|
|
||||||
) : isFieldSelect(fieldDefinition) ? (
|
) : isFieldSelect(fieldDefinition) ? (
|
||||||
<SelectFieldDisplay />
|
<SelectFieldDisplay />
|
||||||
) : isFieldMultiSelect(fieldDefinition) ? (
|
) : isFieldMultiSelect(fieldDefinition) ? (
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
import { FieldMetadataType } from '~/generated-metadata/graphql.ts';
|
||||||
|
|
||||||
import { FieldDefinition } from '../FieldDefinition';
|
import { FieldDefinition } from '../FieldDefinition';
|
||||||
import { FieldAddressMetadata, FieldMetadata } from '../FieldMetadata';
|
import { FieldAddressMetadata, FieldMetadata } from '../FieldMetadata';
|
||||||
|
|
||||||
export const isFieldAddress = (
|
export const isFieldAddress = (
|
||||||
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
||||||
): field is FieldDefinition<FieldAddressMetadata> => field.type === 'ADDRESS';
|
): field is FieldDefinition<FieldAddressMetadata> =>
|
||||||
|
field.type === FieldMetadataType.Address;
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
import { FieldMetadataType } from '~/generated-metadata/graphql.ts';
|
||||||
|
|
||||||
import { FieldDefinition } from '../FieldDefinition';
|
import { FieldDefinition } from '../FieldDefinition';
|
||||||
import { FieldBooleanMetadata, FieldMetadata } from '../FieldMetadata';
|
import { FieldBooleanMetadata, FieldMetadata } from '../FieldMetadata';
|
||||||
|
|
||||||
export const isFieldBoolean = (
|
export const isFieldBoolean = (
|
||||||
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
||||||
): field is FieldDefinition<FieldBooleanMetadata> => field.type === 'BOOLEAN';
|
): field is FieldDefinition<FieldBooleanMetadata> =>
|
||||||
|
field.type === FieldMetadataType.Boolean;
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
import { FieldMetadataType } from '~/generated-metadata/graphql.ts';
|
||||||
|
|
||||||
import { FieldDefinition } from '../FieldDefinition';
|
import { FieldDefinition } from '../FieldDefinition';
|
||||||
import { FieldCurrencyMetadata, FieldMetadata } from '../FieldMetadata';
|
import { FieldCurrencyMetadata, FieldMetadata } from '../FieldMetadata';
|
||||||
|
|
||||||
export const isFieldCurrency = (
|
export const isFieldCurrency = (
|
||||||
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
||||||
): field is FieldDefinition<FieldCurrencyMetadata> => field.type === 'CURRENCY';
|
): field is FieldDefinition<FieldCurrencyMetadata> =>
|
||||||
|
field.type === FieldMetadataType.Currency;
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
|
import { FieldMetadataType } from '~/generated-metadata/graphql.ts';
|
||||||
|
|
||||||
import { FieldDefinition } from '../FieldDefinition';
|
import { FieldDefinition } from '../FieldDefinition';
|
||||||
import { FieldDateTimeMetadata, FieldMetadata } from '../FieldMetadata';
|
import { FieldDateTimeMetadata, FieldMetadata } from '../FieldMetadata';
|
||||||
|
|
||||||
export const isFieldDateTime = (
|
export const isFieldDateTime = (
|
||||||
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
||||||
): field is FieldDefinition<FieldDateTimeMetadata> =>
|
): field is FieldDefinition<FieldDateTimeMetadata> =>
|
||||||
field.type === 'DATE_TIME';
|
field.type === FieldMetadataType.DateTime;
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
import { FieldMetadataType } from '~/generated-metadata/graphql.ts';
|
||||||
|
|
||||||
import { FieldDefinition } from '../FieldDefinition';
|
import { FieldDefinition } from '../FieldDefinition';
|
||||||
import { FieldEmailMetadata, FieldMetadata } from '../FieldMetadata';
|
import { FieldEmailMetadata, FieldMetadata } from '../FieldMetadata';
|
||||||
|
|
||||||
export const isFieldEmail = (
|
export const isFieldEmail = (
|
||||||
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
||||||
): field is FieldDefinition<FieldEmailMetadata> => field.type === 'EMAIL';
|
): field is FieldDefinition<FieldEmailMetadata> =>
|
||||||
|
field.type === FieldMetadataType.Email;
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
|
import { FieldMetadataType } from '~/generated-metadata/graphql.ts';
|
||||||
|
|
||||||
import { FieldDefinition } from '../FieldDefinition';
|
import { FieldDefinition } from '../FieldDefinition';
|
||||||
import { FieldFullNameMetadata, FieldMetadata } from '../FieldMetadata';
|
import { FieldFullNameMetadata, FieldMetadata } from '../FieldMetadata';
|
||||||
|
|
||||||
export const isFieldFullName = (
|
export const isFieldFullName = (
|
||||||
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
||||||
): field is FieldDefinition<FieldFullNameMetadata> =>
|
): field is FieldDefinition<FieldFullNameMetadata> =>
|
||||||
field.type === 'FULL_NAME';
|
field.type === FieldMetadataType.FullName;
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
import { FieldMetadataType } from '~/generated-metadata/graphql.ts';
|
||||||
|
|
||||||
import { FieldDefinition } from '../FieldDefinition';
|
import { FieldDefinition } from '../FieldDefinition';
|
||||||
import { FieldLinkMetadata, FieldMetadata } from '../FieldMetadata';
|
import { FieldLinkMetadata, FieldMetadata } from '../FieldMetadata';
|
||||||
|
|
||||||
export const isFieldLink = (
|
export const isFieldLink = (
|
||||||
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
||||||
): field is FieldDefinition<FieldLinkMetadata> => field.type === 'LINK';
|
): field is FieldDefinition<FieldLinkMetadata> =>
|
||||||
|
field.type === FieldMetadataType.Link;
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
import { FieldMetadataType } from '~/generated-metadata/graphql.ts';
|
||||||
|
|
||||||
import { FieldDefinition } from '../FieldDefinition';
|
import { FieldDefinition } from '../FieldDefinition';
|
||||||
import { FieldMetadata, FieldNumberMetadata } from '../FieldMetadata';
|
import { FieldMetadata, FieldNumberMetadata } from '../FieldMetadata';
|
||||||
|
|
||||||
export const isFieldNumber = (
|
export const isFieldNumber = (
|
||||||
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
||||||
): field is FieldDefinition<FieldNumberMetadata> => field.type === 'NUMBER';
|
): field is FieldDefinition<FieldNumberMetadata> =>
|
||||||
|
field.type === FieldMetadataType.Number;
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import { FieldMetadataType } from '~/generated-metadata/graphql.ts';
|
||||||
|
|
||||||
import { FieldDefinition } from '../FieldDefinition';
|
import { FieldDefinition } from '../FieldDefinition';
|
||||||
import { FieldMetadata, FieldPhoneMetadata } from '../FieldMetadata';
|
import { FieldMetadata, FieldPhoneMetadata } from '../FieldMetadata';
|
||||||
|
|
||||||
@ -6,4 +8,4 @@ export const isFieldPhone = (
|
|||||||
): field is FieldDefinition<FieldPhoneMetadata> =>
|
): field is FieldDefinition<FieldPhoneMetadata> =>
|
||||||
field.metadata.objectMetadataNameSingular === 'person' &&
|
field.metadata.objectMetadataNameSingular === 'person' &&
|
||||||
field.metadata.fieldName === 'phone' &&
|
field.metadata.fieldName === 'phone' &&
|
||||||
field.type === 'TEXT';
|
field.type === FieldMetadataType.Text;
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
import { FieldMetadataType } from '~/generated-metadata/graphql.ts';
|
||||||
|
|
||||||
import { FieldDefinition } from '../FieldDefinition';
|
import { FieldDefinition } from '../FieldDefinition';
|
||||||
import { FieldMetadata, FieldRawJsonMetadata } from '../FieldMetadata';
|
import { FieldMetadata, FieldRawJsonMetadata } from '../FieldMetadata';
|
||||||
|
|
||||||
export const isFieldRawJson = (
|
export const isFieldRawJson = (
|
||||||
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
||||||
): field is FieldDefinition<FieldRawJsonMetadata> => field.type === 'RAW_JSON';
|
): field is FieldDefinition<FieldRawJsonMetadata> =>
|
||||||
|
field.type === FieldMetadataType.RawJson;
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
import { FieldMetadataType } from '~/generated-metadata/graphql.ts';
|
||||||
|
|
||||||
import { FieldDefinition } from '../FieldDefinition';
|
import { FieldDefinition } from '../FieldDefinition';
|
||||||
import { FieldMetadata, FieldRelationMetadata } from '../FieldMetadata';
|
import { FieldMetadata, FieldRelationMetadata } from '../FieldMetadata';
|
||||||
|
|
||||||
export const isFieldRelation = (
|
export const isFieldRelation = (
|
||||||
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
||||||
): field is FieldDefinition<FieldRelationMetadata> => field.type === 'RELATION';
|
): field is FieldDefinition<FieldRelationMetadata> =>
|
||||||
|
field.type === FieldMetadataType.Relation;
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
import { FieldMetadataType } from '~/generated-metadata/graphql.ts';
|
||||||
|
|
||||||
import { FieldDefinition } from '../FieldDefinition';
|
import { FieldDefinition } from '../FieldDefinition';
|
||||||
import { FieldMetadata, FieldTextMetadata } from '../FieldMetadata';
|
import { FieldMetadata, FieldTextMetadata } from '../FieldMetadata';
|
||||||
|
|
||||||
export const isFieldText = (
|
export const isFieldText = (
|
||||||
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
||||||
): field is FieldDefinition<FieldTextMetadata> => field.type === 'TEXT';
|
): field is FieldDefinition<FieldTextMetadata> =>
|
||||||
|
field.type === FieldMetadataType.Text;
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
|
import { FieldMetadataType } from '~/generated-metadata/graphql.ts';
|
||||||
|
|
||||||
import { FieldDefinition } from '../FieldDefinition';
|
import { FieldDefinition } from '../FieldDefinition';
|
||||||
import { FieldMetadata, FieldUuidMetadata } from '../FieldMetadata';
|
import { FieldMetadata, FieldUuidMetadata } from '../FieldMetadata';
|
||||||
|
|
||||||
export const isFieldUuid = (
|
export const isFieldUuid = (
|
||||||
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
field: Pick<FieldDefinition<FieldMetadata>, 'type'>,
|
||||||
): field is FieldDefinition<FieldUuidMetadata> => field.type === 'UUID';
|
): field is FieldDefinition<FieldUuidMetadata> =>
|
||||||
|
field.type === FieldMetadataType.Uuid;
|
||||||
|
@ -18,7 +18,7 @@ export const PhoneDisplay = ({ value }: PhoneDisplayProps) => (
|
|||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{parsePhoneNumber(value, 'FR')?.formatInternational() || value}
|
{parsePhoneNumber(value, 'FR')?.formatNational() || value}
|
||||||
</ContactLink>
|
</ContactLink>
|
||||||
) : (
|
) : (
|
||||||
<ContactLink href="#">{value}</ContactLink>
|
<ContactLink href="#">{value}</ContactLink>
|
||||||
|
Loading…
Reference in New Issue
Block a user