diff --git a/packages/twenty-front/src/modules/object-metadata/validation-schemas/selectOptionsSchema.ts b/packages/twenty-front/src/modules/object-metadata/validation-schemas/selectOptionsSchema.ts index 4b634a3ac4..814892da9b 100644 --- a/packages/twenty-front/src/modules/object-metadata/validation-schemas/selectOptionsSchema.ts +++ b/packages/twenty-front/src/modules/object-metadata/validation-schemas/selectOptionsSchema.ts @@ -1,7 +1,7 @@ import { z } from 'zod'; import { FieldMetadataItemOption } from '@/object-metadata/types/FieldMetadataItem'; -import { getOptionValueFromLabel } from '@/settings/data-model/fields/forms/utils/getOptionValueFromLabel'; +import { getOptionValueFromLabel } from '@/settings/data-model/fields/forms/select/utils/getOptionValueFromLabel'; import { themeColorSchema } from '@/ui/theme/utils/themeColorSchema'; import { computeOptionValueFromLabelOrThrow } from '~/pages/settings/data-model/utils/compute-option-value-from-label.utils'; diff --git a/packages/twenty-front/src/modules/settings/data-model/fields/forms/components/boolean/SettingsDataModelFieldBooleanForm.tsx b/packages/twenty-front/src/modules/settings/data-model/fields/forms/boolean/components/SettingsDataModelFieldBooleanForm.tsx similarity index 79% rename from packages/twenty-front/src/modules/settings/data-model/fields/forms/components/boolean/SettingsDataModelFieldBooleanForm.tsx rename to packages/twenty-front/src/modules/settings/data-model/fields/forms/boolean/components/SettingsDataModelFieldBooleanForm.tsx index 806e3d16fb..c737fab7db 100644 --- a/packages/twenty-front/src/modules/settings/data-model/fields/forms/components/boolean/SettingsDataModelFieldBooleanForm.tsx +++ b/packages/twenty-front/src/modules/settings/data-model/fields/forms/boolean/components/SettingsDataModelFieldBooleanForm.tsx @@ -1,10 +1,10 @@ -import { useEffect } from 'react'; import { Controller, useFormContext } from 'react-hook-form'; import styled from '@emotion/styled'; import { IconCheck, IconX } from 'twenty-ui'; import { z } from 'zod'; import { FieldMetadataItem } from '@/object-metadata/types/FieldMetadataItem'; +import { useBooleanSettingsFormInitialValues } from '@/settings/data-model/fields/forms/boolean/hooks/useBooleanSettingsFormInitialValues'; import { Select } from '@/ui/input/components/Select'; import { CardContent } from '@/ui/layout/card/components/CardContent'; import { isDefined } from '~/utils/isDefined'; @@ -13,13 +13,13 @@ export const settingsDataModelFieldBooleanFormSchema = z.object({ defaultValue: z.boolean(), }); -type SettingsDataModelFieldBooleanFormValues = z.infer< +export type SettingsDataModelFieldBooleanFormValues = z.infer< typeof settingsDataModelFieldBooleanFormSchema >; type SettingsDataModelFieldBooleanFormProps = { className?: string; - fieldMetadataItem?: Pick; + fieldMetadataItem: Pick; }; const StyledContainer = styled(CardContent)` @@ -38,16 +38,12 @@ export const SettingsDataModelFieldBooleanForm = ({ className, fieldMetadataItem, }: SettingsDataModelFieldBooleanFormProps) => { - const { control, resetField } = - useFormContext(); + const { control } = useFormContext(); const isEditMode = isDefined(fieldMetadataItem?.defaultValue); - const initialValue = fieldMetadataItem?.defaultValue ?? true; - - // Reset defaultValue on mount, so it doesn't conflict with other field types. - useEffect(() => { - resetField('defaultValue', { defaultValue: initialValue }); - }, [initialValue, resetField]); + const { initialDefaultValue } = useBooleanSettingsFormInitialValues({ + fieldMetadataItem, + }); return ( @@ -55,7 +51,7 @@ export const SettingsDataModelFieldBooleanForm = ({ (