mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-04-03 16:51:26 +00:00
feat: Finalisation de la validation / refus des documents signés par les parents [N3WTS-2]
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import logger from '@/utils/logger';
|
||||
import { useForm, Controller } from 'react-hook-form';
|
||||
import { useEffect } from 'react';
|
||||
import SelectChoice from './SelectChoice';
|
||||
import InputTextIcon from './InputTextIcon';
|
||||
import * as LucideIcons from 'lucide-react';
|
||||
@ -28,6 +29,7 @@ export function getIcon(name) {
|
||||
export default function FormRenderer({
|
||||
formConfig,
|
||||
csrfToken,
|
||||
initialValues = {},
|
||||
onFormSubmit = (data) => {
|
||||
alert(JSON.stringify(data, null, 2));
|
||||
}, // Callback de soumission personnalisé (optionnel)
|
||||
@ -37,7 +39,14 @@ export default function FormRenderer({
|
||||
control,
|
||||
formState: { errors },
|
||||
reset,
|
||||
} = useForm();
|
||||
} = useForm({ defaultValues: initialValues });
|
||||
|
||||
// Réinitialiser le formulaire quand les valeurs initiales changent
|
||||
useEffect(() => {
|
||||
if (initialValues && Object.keys(initialValues).length > 0) {
|
||||
reset(initialValues);
|
||||
}
|
||||
}, [initialValues, reset]);
|
||||
|
||||
// Fonction utilitaire pour envoyer les données au backend
|
||||
const sendFormDataToBackend = async (formData) => {
|
||||
|
||||
Reference in New Issue
Block a user