c69a3f01da
- Fix default value sent to backend, using single quotes by default - Use default value in field definition and column definition so that field inputs can access it - Used currency default value in CurrencyFieldInput --------- Co-authored-by: Charles Bochet <charles@twenty.com>
20 lines
677 B
TypeScript
20 lines
677 B
TypeScript
import { FieldCurrencyValue } from '@/object-record/record-field/types/FieldMetadata';
|
|
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
|
|
|
export const getDefaultValueForBackend = (
|
|
defaultValue: any,
|
|
fieldMetadataType: FieldMetadataType,
|
|
) => {
|
|
if (fieldMetadataType === FieldMetadataType.Currency) {
|
|
const currencyDefaultValue = defaultValue as FieldCurrencyValue;
|
|
return {
|
|
amountMicros: currencyDefaultValue.amountMicros,
|
|
currencyCode: `'${currencyDefaultValue.currencyCode}'` as any,
|
|
} satisfies FieldCurrencyValue;
|
|
} else if (typeof defaultValue === 'string') {
|
|
return `'${defaultValue}'`;
|
|
}
|
|
|
|
return defaultValue;
|
|
};
|