mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-06-04 21:36:12 +00:00
feat: Finalisation formulaire dynamique
This commit is contained in:
@ -3,6 +3,7 @@ import { useForm, Controller } from 'react-hook-form';
|
||||
import InputTextIcon from './InputTextIcon';
|
||||
import SelectChoice from './SelectChoice';
|
||||
import Button from './Button';
|
||||
import FileUpload from './FileUpload';
|
||||
import IconSelector from './IconSelector';
|
||||
import * as LucideIcons from 'lucide-react';
|
||||
import { FIELD_TYPES } from './FormTypes';
|
||||
@ -14,6 +15,8 @@ export default function AddFieldModal({
|
||||
onSubmit,
|
||||
editingField = null,
|
||||
editingIndex = -1,
|
||||
hasMasterFile = false,
|
||||
onMasterFileUpload,
|
||||
}) {
|
||||
const isEditing = editingIndex >= 0;
|
||||
|
||||
@ -29,6 +32,7 @@ export default function AddFieldModal({
|
||||
acceptTypes: '',
|
||||
maxSize: 5, // 5MB par défaut
|
||||
checked: false,
|
||||
masterFileToUpload: null,
|
||||
validation: {
|
||||
pattern: '',
|
||||
minLength: '',
|
||||
@ -56,6 +60,7 @@ export default function AddFieldModal({
|
||||
acceptTypes: '',
|
||||
maxSize: 5,
|
||||
checked: false,
|
||||
masterFileToUpload: null,
|
||||
signatureData: '',
|
||||
backgroundColor: '#ffffff',
|
||||
penColor: '#000000',
|
||||
@ -492,6 +497,31 @@ export default function AddFieldModal({
|
||||
|
||||
{currentField.type === 'file' && (
|
||||
<>
|
||||
<div className="rounded border border-gray-200 bg-gray-50 p-3">
|
||||
<label className="block text-sm font-medium text-gray-700 mb-2">
|
||||
Document PDF du formulaire{' '}
|
||||
<span className="text-red-500">*</span>
|
||||
</label>
|
||||
<FileUpload
|
||||
selectionMessage="Uploader le PDF à afficher dans l'aperçu"
|
||||
onFileSelect={(file) => {
|
||||
setCurrentField((prev) => ({
|
||||
...prev,
|
||||
masterFileToUpload: file,
|
||||
}));
|
||||
if (onMasterFileUpload) {
|
||||
onMasterFileUpload(file);
|
||||
}
|
||||
}}
|
||||
enable
|
||||
/>
|
||||
{!hasMasterFile && !currentField.masterFileToUpload && (
|
||||
<p className="text-xs text-red-500 mt-2">
|
||||
Uploadez un document avant d'ajouter ce type de champ.
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Controller
|
||||
name="acceptTypes"
|
||||
control={control}
|
||||
|
||||
Reference in New Issue
Block a user