feat: Ajout des composants manquant dans le FormTemplateBuilder [N3WTS-17]

This commit is contained in:
Luc SORIGNET
2025-09-01 12:09:19 +02:00
parent e89d2fc4c3
commit 5e62ee5100
12 changed files with 525 additions and 38 deletions

View File

@ -29,13 +29,23 @@ import {
Code,
Eye,
EyeOff,
Phone,
Radio,
ToggleLeft,
CheckSquare,
FileUp,
} from 'lucide-react';
const FIELD_TYPES_ICON = {
text: { icon: TextCursorInput },
email: { icon: AtSign },
phone: { icon: Phone },
date: { icon: Calendar },
select: { icon: ChevronDown },
radio: { icon: Radio },
checkbox: { icon: CheckSquare },
toggle: { icon: ToggleLeft },
file: { icon: FileUp },
textarea: { icon: Type },
paragraph: { icon: AlignLeft },
heading1: { icon: Heading1 },
@ -224,10 +234,22 @@ export default function FormTemplateBuilder() {
id: isContentTypeOnly
? undefined
: generateFieldId(data.label || 'field'),
options: data.type === 'select' ? currentField.options : undefined,
options: ['select', 'radio'].includes(data.type)
? currentField.options
: undefined,
icon: data.icon || currentField.icon || undefined,
placeholder: data.placeholder || undefined,
text: isContentTypeOnly ? data.text : undefined,
checked: ['checkbox', 'toggle'].includes(data.type)
? currentField.checked
: undefined,
horizontal:
data.type === 'checkbox' ? currentField.horizontal : undefined,
acceptTypes: data.type === 'file' ? currentField.acceptTypes : undefined,
maxSize: data.type === 'file' ? currentField.maxSize : undefined,
validation: ['phone', 'email', 'text'].includes(data.type)
? currentField.validation
: undefined,
};
// Nettoyer les propriétés undefined
@ -247,9 +269,7 @@ export default function FormTemplateBuilder() {
setFormConfig({ ...formConfig, fields: newFields });
setEditingIndex(-1);
};
// Modifier un champ existant
}; // Modifier un champ existant
const editField = (index) => {
setEditingIndex(index);
setShowAddFieldModal(true);