feat: add sub fields for address (#13566)
https://github.com/user-attachments/assets/8fe9079d-9b66-4b42-8b11-ad713e9de666 --------- Co-authored-by: Félix Malfait <felix@twenty.com>
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import { FieldAddressValue } from '@/object-record/record-field/types/FieldMetadata';
|
||||
import {
|
||||
ALLOWED_ADDRESS_SUBFIELDS,
|
||||
AllowedAddressSubField,
|
||||
} from 'twenty-shared/src/types/AddressFieldsType';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { joinAddressFieldValues } from '~/utils/joinAddressFieldValues';
|
||||
|
||||
export const formatAddressDisplay = (
|
||||
fieldValue: FieldAddressValue | undefined,
|
||||
subFields: AllowedAddressSubField[] | null | undefined,
|
||||
) => {
|
||||
if (!isDefined(fieldValue)) return '';
|
||||
const fieldsToUse =
|
||||
subFields && subFields.length > 0
|
||||
? subFields
|
||||
: [...ALLOWED_ADDRESS_SUBFIELDS];
|
||||
|
||||
return joinAddressFieldValues(fieldValue, fieldsToUse);
|
||||
};
|
||||
Reference in New Issue
Block a user