fix: apply feedback

This commit is contained in:
yassinedorbozgithub
2025-06-10 18:14:22 +01:00
parent c71d750bdc
commit f4ca6613c7
4 changed files with 9 additions and 15 deletions

View File

@@ -52,16 +52,10 @@ export const ContentTypeForm: FC<ComponentFormProps<IContentType>> = ({
const { append, fields, remove } = useFieldArray({
name: "fields",
rules: {
validate: (value) => {
const labelCounts = value.reduce((acc, field) => {
if (!field.label.trim()) return acc;
acc[field.label] = (acc[field.label] || 0) + 1;
return acc;
}, {} as Record<string, number>);
const hasDuplicatedLabels = Object.values(labelCounts).some(
(count: number) => count > 1,
);
validate: (fields) => {
const hasDuplicatedLabels =
new Set(fields.map((f) => f["label"] as string)).size ===
fields.length;
if (hasDuplicatedLabels) {
toast.error(t("message.duplicate_labels_not_allowed"));