mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
feat: Nommage des templates / Intégration dans formulaire d'inscription
parent [#22]
This commit is contained in:
@ -7,7 +7,7 @@ import Loader from '@/components/Loader';
|
||||
import Button from '@/components/Button';
|
||||
import DjangoCSRFToken from '@/components/DjangoCSRFToken';
|
||||
import Table from '@/components/Table';
|
||||
import { fetchRegistrationTemplateMaster, createRegistrationTemplates, fetchRegisterForm, deleteRegistrationTemplates } from '@/app/actions/subscriptionAction';
|
||||
import { fetchRegistrationTemplateMaster, createRegistrationTemplates, fetchRegisterForm, deleteRegistrationTemplates, fetchTemplatesFromRegistrationFiles } from '@/app/actions/subscriptionAction';
|
||||
import { fetchRegistrationFileFromGroup } from '@/app/actions/registerFileGroupAction';
|
||||
import { Download, Upload, Trash2, Eye } from 'lucide-react';
|
||||
import { BASE_URL } from '@/utils/Url';
|
||||
@ -18,6 +18,7 @@ import logger from '@/utils/logger';
|
||||
import StudentInfoForm from '@/components/Inscription/StudentInfoForm';
|
||||
import FilesToSign from '@/components/Inscription/FilesToSign';
|
||||
import FilesToUpload from '@/components/Inscription/FilesToUpload';
|
||||
import { DocusealForm } from '@docuseal/react';
|
||||
|
||||
/**
|
||||
* Composant de formulaire d'inscription partagé
|
||||
@ -83,7 +84,6 @@ export default function InscriptionFormShared({
|
||||
});
|
||||
setGuardians(data?.student?.guardians || []);
|
||||
setUploadedFiles(data.registration_files || []);
|
||||
setFileGroup(data.fileGroup || null);
|
||||
});
|
||||
|
||||
setIsLoading(false);
|
||||
@ -91,12 +91,10 @@ export default function InscriptionFormShared({
|
||||
}, [studentId]);
|
||||
|
||||
useEffect(() => {
|
||||
if(fileGroup){
|
||||
fetchRegistrationFileFromGroup(fileGroup).then((data) => {
|
||||
setFileTemplates(data);
|
||||
});
|
||||
}
|
||||
}, [fileGroup]);
|
||||
fetchTemplatesFromRegistrationFiles(studentId).then((data) => {
|
||||
setFileTemplates(data);
|
||||
})
|
||||
}, []);
|
||||
|
||||
// Fonctions de gestion du formulaire et des fichiers
|
||||
const updateFormField = (field, value) => {
|
||||
@ -190,12 +188,7 @@ export default function InscriptionFormShared({
|
||||
setCurrentPage(currentPage - 1);
|
||||
};
|
||||
|
||||
const requiredFileTemplates = fileTemplates.filter(template => template.is_required);
|
||||
|
||||
// Ajout des logs pour débogage
|
||||
console.log('BASE_URL:', BASE_URL);
|
||||
console.log('requiredFileTemplates:', requiredFileTemplates);
|
||||
console.log('currentPage:', currentPage);
|
||||
const requiredFileTemplates = fileTemplates;
|
||||
|
||||
// Configuration des colonnes pour le tableau des fichiers
|
||||
const columns = [
|
||||
@ -275,15 +268,18 @@ export default function InscriptionFormShared({
|
||||
{currentPage > 1 && currentPage <= requiredFileTemplates.length + 1 && (
|
||||
<div className="bg-white p-6 rounded-lg shadow-sm border border-gray-200">
|
||||
<h2 className="text-xl font-bold mb-4 text-gray-800">{requiredFileTemplates[currentPage - 2].name}</h2>
|
||||
<iframe
|
||||
src={`${BASE_URL}/data/${requiredFileTemplates[currentPage - 2].file}`}
|
||||
width="100%"
|
||||
height="800px"
|
||||
className="w-full" // Utiliser la classe CSS pour la largeur
|
||||
title={requiredFileTemplates[currentPage - 2].name}
|
||||
<DocusealForm
|
||||
id="docusealForm"
|
||||
src={"https://docuseal.com/s/"+requiredFileTemplates[currentPage - 2].slug}
|
||||
withDownloadButton={false}
|
||||
onComplete={() => {
|
||||
const formContainer = document.getElementById('form_container');
|
||||
if (formContainer) {
|
||||
formContainer.style.display = 'none';
|
||||
}
|
||||
}}
|
||||
>
|
||||
<p>Votre navigateur ne prend pas en charge les fichiers PDF. Vous pouvez télécharger le fichier en cliquant <a href={`${BASE_URL}/data/${requiredFileTemplates[currentPage - 2].file}`}>ici</a>.</p>
|
||||
</iframe>
|
||||
</DocusealForm>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user