Files
twenty/front/src/modules/metadata/utils/formatMetadataFieldInput.ts
T
2023-10-26 11:34:26 +02:00

18 lines
552 B
TypeScript

import toCamelCase from 'lodash.camelcase';
import upperFirst from 'lodash.upperfirst';
import { ObjectFieldDataType } from '@/settings/data-model/types/ObjectFieldDataType';
import { Field } from '~/generated-metadata/graphql';
export const formatMetadataFieldInput = (
input: Pick<Field, 'label' | 'icon' | 'description'> & {
type: ObjectFieldDataType;
},
) => ({
description: input.description?.trim() ?? null,
icon: input.icon,
label: input.label.trim(),
name: upperFirst(toCamelCase(input.label.trim())),
type: input.type,
});