diff --git a/packages/twenty-front/src/modules/object-metadata/utils/formatFieldMetadataItemInput.ts b/packages/twenty-front/src/modules/object-metadata/utils/formatFieldMetadataItemInput.ts index 26f2def0b9..80ba590d68 100644 --- a/packages/twenty-front/src/modules/object-metadata/utils/formatFieldMetadataItemInput.ts +++ b/packages/twenty-front/src/modules/object-metadata/utils/formatFieldMetadataItemInput.ts @@ -23,8 +23,8 @@ export const getOptionValueFromLabel = (label: string) => { export const formatFieldMetadataItemInput = ( input: Pick< Field, - 'label' | 'icon' | 'description' | 'defaultValue' | 'type' | 'options' - >, + 'label' | 'icon' | 'description' | 'defaultValue' | 'options' + > & { type?: FieldMetadataType }, ) => { const options = input.options as FieldMetadataOption[]; let defaultValue = input.defaultValue; diff --git a/packages/twenty-front/src/modules/object-metadata/utils/formatRelationMetadataInput.ts b/packages/twenty-front/src/modules/object-metadata/utils/formatRelationMetadataInput.ts index 12db079c1f..a33a215233 100644 --- a/packages/twenty-front/src/modules/object-metadata/utils/formatRelationMetadataInput.ts +++ b/packages/twenty-front/src/modules/object-metadata/utils/formatRelationMetadataInput.ts @@ -12,7 +12,7 @@ export type FormatRelationMetadataInputParams = { field: Pick; objectMetadataId: string; connect: { - field: Pick; + field: Pick; objectMetadataId: string; }; }; diff --git a/packages/twenty-front/src/modules/settings/data-model/fields/forms/hooks/useFieldMetadataForm.ts b/packages/twenty-front/src/modules/settings/data-model/fields/forms/hooks/useFieldMetadataForm.ts index c462b88ba0..a24ad10a9a 100644 --- a/packages/twenty-front/src/modules/settings/data-model/fields/forms/hooks/useFieldMetadataForm.ts +++ b/packages/twenty-front/src/modules/settings/data-model/fields/forms/hooks/useFieldMetadataForm.ts @@ -36,6 +36,12 @@ export const fieldMetadataFormDefaultValues: FormValues = { select: [{ color: 'green', label: 'Option 1', value: v4() }], multiSelect: [{ color: 'green', label: 'Option 1', value: v4() }], }; +const relationTargetFieldSchema = z.object({ + description: z.string().optional(), + icon: z.string().startsWith('Icon'), + label: z.string().min(1), + defaultValue: z.any(), +}); const fieldSchema = z.object({ description: z.string().optional(), icon: z.string().startsWith('Icon'), @@ -62,7 +68,7 @@ const relationSchema = fieldSchema.merge( z.object({ type: z.literal(FieldMetadataType.Relation), relation: z.object({ - field: fieldSchema, + field: relationTargetFieldSchema, objectMetadataId: z.string().uuid(), type: z.enum([ RelationMetadataType.OneToMany, diff --git a/packages/twenty-front/src/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldStep2.tsx b/packages/twenty-front/src/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldStep2.tsx index 99ec054709..c921eba888 100644 --- a/packages/twenty-front/src/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldStep2.tsx +++ b/packages/twenty-front/src/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldStep2.tsx @@ -141,7 +141,6 @@ export const SettingsObjectNewFieldStep2 = () => { field: { icon: validatedFormValues.relation.field.icon, label: validatedFormValues.relation.field.label, - type: validatedFormValues.relation.field.type, }, objectMetadataId: validatedFormValues.relation.objectMetadataId, },