diff --git a/packages/twenty-front/src/modules/object-record/record-field/components/FieldDisplay.tsx b/packages/twenty-front/src/modules/object-record/record-field/components/FieldDisplay.tsx index 47a0b7a03c..2bc4da0b07 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/components/FieldDisplay.tsx +++ b/packages/twenty-front/src/modules/object-record/record-field/components/FieldDisplay.tsx @@ -34,13 +34,18 @@ import { isFieldUuid } from '../types/guards/isFieldUuid'; export const FieldDisplay = () => { const { fieldDefinition, isLabelIdentifier } = useContext(FieldContext); - return isLabelIdentifier && + const isChipDisplay = + isLabelIdentifier && (isFieldText(fieldDefinition) || isFieldFullName(fieldDefinition) || - isFieldNumber(fieldDefinition)) ? ( + isFieldNumber(fieldDefinition)); + + return isChipDisplay ? ( ) : isFieldRelation(fieldDefinition) ? ( + ) : isFieldPhone(fieldDefinition) ? ( + ) : isFieldText(fieldDefinition) ? ( ) : isFieldUuid(fieldDefinition) ? ( @@ -57,8 +62,6 @@ export const FieldDisplay = () => { ) : isFieldFullName(fieldDefinition) ? ( - ) : isFieldPhone(fieldDefinition) ? ( - ) : isFieldSelect(fieldDefinition) ? ( ) : isFieldMultiSelect(fieldDefinition) ? ( diff --git a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldAddress.ts b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldAddress.ts index f5ffb55bf5..c552808118 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldAddress.ts +++ b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldAddress.ts @@ -1,6 +1,9 @@ +import { FieldMetadataType } from '~/generated-metadata/graphql.ts'; + import { FieldDefinition } from '../FieldDefinition'; import { FieldAddressMetadata, FieldMetadata } from '../FieldMetadata'; export const isFieldAddress = ( field: Pick, 'type'>, -): field is FieldDefinition => field.type === 'ADDRESS'; +): field is FieldDefinition => + field.type === FieldMetadataType.Address; diff --git a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldBoolean.ts b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldBoolean.ts index d0c2a09d7f..69add94d56 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldBoolean.ts +++ b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldBoolean.ts @@ -1,6 +1,9 @@ +import { FieldMetadataType } from '~/generated-metadata/graphql.ts'; + import { FieldDefinition } from '../FieldDefinition'; import { FieldBooleanMetadata, FieldMetadata } from '../FieldMetadata'; export const isFieldBoolean = ( field: Pick, 'type'>, -): field is FieldDefinition => field.type === 'BOOLEAN'; +): field is FieldDefinition => + field.type === FieldMetadataType.Boolean; diff --git a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldCurrency.ts b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldCurrency.ts index 1cba9a1699..b6738c0bb6 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldCurrency.ts +++ b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldCurrency.ts @@ -1,6 +1,9 @@ +import { FieldMetadataType } from '~/generated-metadata/graphql.ts'; + import { FieldDefinition } from '../FieldDefinition'; import { FieldCurrencyMetadata, FieldMetadata } from '../FieldMetadata'; export const isFieldCurrency = ( field: Pick, 'type'>, -): field is FieldDefinition => field.type === 'CURRENCY'; +): field is FieldDefinition => + field.type === FieldMetadataType.Currency; diff --git a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldDateTime.ts b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldDateTime.ts index f98fa6846a..15c2a01c53 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldDateTime.ts +++ b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldDateTime.ts @@ -1,7 +1,9 @@ +import { FieldMetadataType } from '~/generated-metadata/graphql.ts'; + import { FieldDefinition } from '../FieldDefinition'; import { FieldDateTimeMetadata, FieldMetadata } from '../FieldMetadata'; export const isFieldDateTime = ( field: Pick, 'type'>, ): field is FieldDefinition => - field.type === 'DATE_TIME'; + field.type === FieldMetadataType.DateTime; diff --git a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldEmail.ts b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldEmail.ts index bd5f5e4c12..265301773c 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldEmail.ts +++ b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldEmail.ts @@ -1,6 +1,9 @@ +import { FieldMetadataType } from '~/generated-metadata/graphql.ts'; + import { FieldDefinition } from '../FieldDefinition'; import { FieldEmailMetadata, FieldMetadata } from '../FieldMetadata'; export const isFieldEmail = ( field: Pick, 'type'>, -): field is FieldDefinition => field.type === 'EMAIL'; +): field is FieldDefinition => + field.type === FieldMetadataType.Email; diff --git a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldFullName.ts b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldFullName.ts index be25711176..a6261d6428 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldFullName.ts +++ b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldFullName.ts @@ -1,7 +1,9 @@ +import { FieldMetadataType } from '~/generated-metadata/graphql.ts'; + import { FieldDefinition } from '../FieldDefinition'; import { FieldFullNameMetadata, FieldMetadata } from '../FieldMetadata'; export const isFieldFullName = ( field: Pick, 'type'>, ): field is FieldDefinition => - field.type === 'FULL_NAME'; + field.type === FieldMetadataType.FullName; diff --git a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldLink.ts b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldLink.ts index 0c957c0042..526881a8a3 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldLink.ts +++ b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldLink.ts @@ -1,6 +1,9 @@ +import { FieldMetadataType } from '~/generated-metadata/graphql.ts'; + import { FieldDefinition } from '../FieldDefinition'; import { FieldLinkMetadata, FieldMetadata } from '../FieldMetadata'; export const isFieldLink = ( field: Pick, 'type'>, -): field is FieldDefinition => field.type === 'LINK'; +): field is FieldDefinition => + field.type === FieldMetadataType.Link; diff --git a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldNumber.ts b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldNumber.ts index b4b5c7b8d1..6b863170ad 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldNumber.ts +++ b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldNumber.ts @@ -1,6 +1,9 @@ +import { FieldMetadataType } from '~/generated-metadata/graphql.ts'; + import { FieldDefinition } from '../FieldDefinition'; import { FieldMetadata, FieldNumberMetadata } from '../FieldMetadata'; export const isFieldNumber = ( field: Pick, 'type'>, -): field is FieldDefinition => field.type === 'NUMBER'; +): field is FieldDefinition => + field.type === FieldMetadataType.Number; diff --git a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldPhone.ts b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldPhone.ts index 9e84a5c426..a417d1fb0d 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldPhone.ts +++ b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldPhone.ts @@ -1,3 +1,5 @@ +import { FieldMetadataType } from '~/generated-metadata/graphql.ts'; + import { FieldDefinition } from '../FieldDefinition'; import { FieldMetadata, FieldPhoneMetadata } from '../FieldMetadata'; @@ -6,4 +8,4 @@ export const isFieldPhone = ( ): field is FieldDefinition => field.metadata.objectMetadataNameSingular === 'person' && field.metadata.fieldName === 'phone' && - field.type === 'TEXT'; + field.type === FieldMetadataType.Text; diff --git a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldRawJson.ts b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldRawJson.ts index 3decadfb86..1cdc93665c 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldRawJson.ts +++ b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldRawJson.ts @@ -1,6 +1,9 @@ +import { FieldMetadataType } from '~/generated-metadata/graphql.ts'; + import { FieldDefinition } from '../FieldDefinition'; import { FieldMetadata, FieldRawJsonMetadata } from '../FieldMetadata'; export const isFieldRawJson = ( field: Pick, 'type'>, -): field is FieldDefinition => field.type === 'RAW_JSON'; +): field is FieldDefinition => + field.type === FieldMetadataType.RawJson; diff --git a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldRelation.ts b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldRelation.ts index 2927569c35..b64046647c 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldRelation.ts +++ b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldRelation.ts @@ -1,6 +1,9 @@ +import { FieldMetadataType } from '~/generated-metadata/graphql.ts'; + import { FieldDefinition } from '../FieldDefinition'; import { FieldMetadata, FieldRelationMetadata } from '../FieldMetadata'; export const isFieldRelation = ( field: Pick, 'type'>, -): field is FieldDefinition => field.type === 'RELATION'; +): field is FieldDefinition => + field.type === FieldMetadataType.Relation; diff --git a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldText.ts b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldText.ts index 7c1b5eee12..197c460467 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldText.ts +++ b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldText.ts @@ -1,6 +1,9 @@ +import { FieldMetadataType } from '~/generated-metadata/graphql.ts'; + import { FieldDefinition } from '../FieldDefinition'; import { FieldMetadata, FieldTextMetadata } from '../FieldMetadata'; export const isFieldText = ( field: Pick, 'type'>, -): field is FieldDefinition => field.type === 'TEXT'; +): field is FieldDefinition => + field.type === FieldMetadataType.Text; diff --git a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldUuid.ts b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldUuid.ts index 84f83e2b1f..a8bf679c55 100644 --- a/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldUuid.ts +++ b/packages/twenty-front/src/modules/object-record/record-field/types/guards/isFieldUuid.ts @@ -1,6 +1,9 @@ +import { FieldMetadataType } from '~/generated-metadata/graphql.ts'; + import { FieldDefinition } from '../FieldDefinition'; import { FieldMetadata, FieldUuidMetadata } from '../FieldMetadata'; export const isFieldUuid = ( field: Pick, 'type'>, -): field is FieldDefinition => field.type === 'UUID'; +): field is FieldDefinition => + field.type === FieldMetadataType.Uuid; diff --git a/packages/twenty-front/src/modules/ui/field/display/components/PhoneDisplay.tsx b/packages/twenty-front/src/modules/ui/field/display/components/PhoneDisplay.tsx index 7ad5b97ecb..b9e73c45da 100644 --- a/packages/twenty-front/src/modules/ui/field/display/components/PhoneDisplay.tsx +++ b/packages/twenty-front/src/modules/ui/field/display/components/PhoneDisplay.tsx @@ -18,7 +18,7 @@ export const PhoneDisplay = ({ value }: PhoneDisplayProps) => ( event.stopPropagation(); }} > - {parsePhoneNumber(value, 'FR')?.formatInternational() || value} + {parsePhoneNumber(value, 'FR')?.formatNational() || value} ) : ( {value}