From da5200eb1b660682dfc6a4fb8a74e0eafbd8e9cc Mon Sep 17 00:00:00 2001 From: yassinedorbozgithub Date: Thu, 5 Jun 2025 16:53:27 +0100 Subject: [PATCH] fix(frontend): apply feedback --- .../content-types/ContentTypeForm.tsx | 9 +++++++-- .../content-types/components/FieldInput.tsx | 18 ++++++++---------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/frontend/src/components/content-types/ContentTypeForm.tsx b/frontend/src/components/content-types/ContentTypeForm.tsx index d91bbb8c..7bc201a9 100644 --- a/frontend/src/components/content-types/ContentTypeForm.tsx +++ b/frontend/src/components/content-types/ContentTypeForm.tsx @@ -131,9 +131,14 @@ export const ContentTypeForm: FC> = ({ gap={2} > uuid === f.uuid, + )} /> ))} diff --git a/frontend/src/components/content-types/components/FieldInput.tsx b/frontend/src/components/content-types/components/FieldInput.tsx index 4c07603c..8041b336 100644 --- a/frontend/src/components/content-types/components/FieldInput.tsx +++ b/frontend/src/components/content-types/components/FieldInput.tsx @@ -18,13 +18,17 @@ import { import { IconButton } from "@/app-components/buttons/IconButton"; import { Input } from "@/app-components/inputs/Input"; import { useTranslate } from "@/hooks/useTranslate"; -import { ContentFieldType, IContentType } from "@/types/content-type.types"; +import { + ContentField, + ContentFieldType, + IContentType, +} from "@/types/content-type.types"; import { slugify } from "@/utils/string"; export const FieldInput = ({ setValue, index, - uuid, + contentTypeField, ...props }: { index: number; @@ -32,7 +36,7 @@ export const FieldInput = ({ remove: UseFieldArrayRemove; control: Control; setValue: UseFormSetValue; - uuid?: string; + contentTypeField?: ContentField; }) => { const { t } = useTranslate(); @@ -61,14 +65,8 @@ export const FieldInput = ({ helperText={fieldState.error?.message} onChange={(e) => { const currentValue = e.target.value; - const { label, name } = - props.control._defaultValues.fields?.find( - (field) => field?.uuid === uuid, - ) || {}; - if (label && name !== slugify(label)) { - name && setValue(`fields.${index}.name`, name); - } else { + if (!contentTypeField?.label || !contentTypeField?.name) { setValue( `fields.${index}.name`, currentValue ? slugify(currentValue) : "",