mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 16:03:21 +00:00
Merge remote-tracking branch 'origin/WIP_Inscriptions' into develop
This commit is contained in:
@ -23,10 +23,10 @@ import {
|
||||
fetchRegistrationPaymentModes,
|
||||
fetchTuitionPaymentModes,
|
||||
} from '@/app/actions/schoolAction';
|
||||
import { fetchProfileRoles, fetchProfiles } from '@/app/actions/authAction';
|
||||
import { fetchProfiles } from '@/app/actions/authAction';
|
||||
import SidebarTabs from '@/components/SidebarTabs';
|
||||
import FilesGroupsManagement from '@/components/Structure/Files/FilesGroupsManagement';
|
||||
import { fetchRegistrationTemplateMaster } from '@/app/actions/registerFileGroupAction';
|
||||
import { fetchRegistrationSchoolFileMasters } from '@/app/actions/registerFileGroupAction';
|
||||
import logger from '@/utils/logger';
|
||||
import { useEstablishment } from '@/context/EstablishmentContext';
|
||||
|
||||
@ -75,8 +75,8 @@ export default function Page() {
|
||||
// Fetch data for tuition fees
|
||||
handleTuitionFees();
|
||||
|
||||
// Fetch data for registration file templates
|
||||
fetchRegistrationTemplateMaster()
|
||||
// Fetch data for registration file schoolFileTemplates
|
||||
fetchRegistrationSchoolFileMasters()
|
||||
.then((data) => {
|
||||
setFichiers(data);
|
||||
})
|
||||
@ -275,7 +275,7 @@ export default function Page() {
|
||||
const tabs = [
|
||||
{
|
||||
id: 'Configuration',
|
||||
label: "Configuration de l'école",
|
||||
label: 'Classes',
|
||||
content: (
|
||||
<StructureManagement
|
||||
specialities={specialities}
|
||||
@ -293,7 +293,7 @@ export default function Page() {
|
||||
},
|
||||
{
|
||||
id: 'Schedule',
|
||||
label: "Gestion de l'emploi du temps",
|
||||
label: 'Emploi du temps',
|
||||
content: (
|
||||
<ClassesProvider>
|
||||
<ScheduleManagement
|
||||
@ -305,7 +305,7 @@ export default function Page() {
|
||||
},
|
||||
{
|
||||
id: 'Fees',
|
||||
label: 'Tarifications',
|
||||
label: 'Tarifs',
|
||||
content: (
|
||||
<FeesManagement
|
||||
registrationDiscounts={registrationDiscounts}
|
||||
@ -332,7 +332,7 @@ export default function Page() {
|
||||
},
|
||||
{
|
||||
id: 'Files',
|
||||
label: "Documents d'inscription",
|
||||
label: 'Documents',
|
||||
content: (
|
||||
<FilesGroupsManagement
|
||||
csrfToken={csrfToken}
|
||||
@ -343,7 +343,7 @@ export default function Page() {
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="p-8">
|
||||
<div className="p-4">
|
||||
<DjangoCSRFToken csrfToken={csrfToken} />
|
||||
|
||||
<div className="w-full p-4">
|
||||
|
||||
@ -16,7 +16,7 @@ import {
|
||||
Edit,
|
||||
Archive,
|
||||
FileText,
|
||||
CircleCheck,
|
||||
CheckCircle,
|
||||
Plus,
|
||||
XCircle,
|
||||
} from 'lucide-react';
|
||||
@ -39,8 +39,10 @@ import {
|
||||
} from '@/app/actions/subscriptionAction';
|
||||
|
||||
import {
|
||||
fetchRegistrationTemplateMaster,
|
||||
createRegistrationTemplates,
|
||||
fetchRegistrationSchoolFileMasters,
|
||||
fetchRegistrationParentFileMasters,
|
||||
createRegistrationSchoolFileTemplate,
|
||||
createRegistrationParentFileTemplate,
|
||||
fetchRegistrationFileGroups,
|
||||
cloneTemplate,
|
||||
} from '@/app/actions/registerFileGroupAction';
|
||||
@ -96,7 +98,8 @@ export default function Page({ params: { locale } }) {
|
||||
const [totalArchives, setTotalArchives] = useState(0);
|
||||
const [itemsPerPage, setItemsPerPage] = useState(10); // Définir le nombre d'éléments par page
|
||||
|
||||
const [templateMasters, setTemplateMasters] = useState([]);
|
||||
const [schoolFileMasters, setSchoolFileMasters] = useState([]);
|
||||
const [parentFileMasters, setParentFileMasters] = useState([]);
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const [isOpenAffectationClasse, setIsOpenAffectationClasse] = useState(false);
|
||||
const [student, setStudent] = useState('');
|
||||
@ -239,9 +242,16 @@ export default function Page({ params: { locale } }) {
|
||||
fetchRegisterForms(selectedEstablishmentId, ARCHIVED)
|
||||
.then(registerFormArchivedDataHandler)
|
||||
.catch(requestErrorHandler),
|
||||
fetchRegistrationTemplateMaster()
|
||||
fetchRegistrationSchoolFileMasters()
|
||||
.then((data) => {
|
||||
setTemplateMasters(data);
|
||||
setSchoolFileMasters(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
logger.debug(err.message);
|
||||
}),
|
||||
fetchRegistrationParentFileMasters()
|
||||
.then((data) => {
|
||||
setParentFileMasters(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
logger.debug(err.message);
|
||||
@ -315,9 +325,9 @@ export default function Page({ params: { locale } }) {
|
||||
fetchRegisterForms(selectedEstablishmentId, ARCHIVED)
|
||||
.then(registerFormArchivedDataHandler)
|
||||
.catch(requestErrorHandler);
|
||||
fetchRegistrationTemplateMaster()
|
||||
fetchRegistrationSchoolFileMasters()
|
||||
.then((data) => {
|
||||
setTemplateMasters(data);
|
||||
setSchoolFileMasters(data);
|
||||
})
|
||||
.catch((err) => {
|
||||
err = err.message;
|
||||
@ -521,41 +531,78 @@ export default function Page({ params: { locale } }) {
|
||||
|
||||
createRegisterForm(data, csrfToken)
|
||||
.then((data) => {
|
||||
// Cloner les templates pour chaque templateMaster du fileGroup
|
||||
const masters = templateMasters.filter((file) =>
|
||||
// Cloner les schoolFileTemplates pour chaque templateMaster du fileGroup
|
||||
const masters = schoolFileMasters.filter((file) =>
|
||||
file.groups.includes(selectedFileGroup)
|
||||
);
|
||||
const clonePromises = masters.map((templateMaster, index) => {
|
||||
return cloneTemplate(
|
||||
templateMaster.id,
|
||||
updatedData.guardianEmail,
|
||||
templateMaster.is_required
|
||||
)
|
||||
.then((clonedDocument) => {
|
||||
// Sauvegarde des templates clonés dans la base de données
|
||||
const cloneData = {
|
||||
name: `${templateMaster.name}_${updatedData.guardianFirstName}_${updatedData.guardianLastName}`,
|
||||
slug: clonedDocument.slug,
|
||||
id: clonedDocument.id,
|
||||
master: templateMaster.id,
|
||||
registration_form: data.student.id,
|
||||
};
|
||||
const parent_masters = parentFileMasters.filter((file) =>
|
||||
file.groups.includes(selectedFileGroup)
|
||||
);
|
||||
const clonePromises = masters
|
||||
.map((templateMaster, index) => {
|
||||
return cloneTemplate(
|
||||
templateMaster.id,
|
||||
updatedData.guardianEmail,
|
||||
templateMaster.is_required
|
||||
)
|
||||
.then((clonedDocument) => {
|
||||
// Sauvegarde des schoolFileTemplates clonés dans la base de données
|
||||
const cloneData = {
|
||||
name: `${templateMaster.name}_${updatedData.guardianFirstName}_${updatedData.guardianLastName}`,
|
||||
slug: clonedDocument.slug,
|
||||
id: clonedDocument.id,
|
||||
master: templateMaster.id,
|
||||
registration_form: data.student.id,
|
||||
};
|
||||
|
||||
return createRegistrationTemplates(cloneData, csrfToken)
|
||||
.then((response) => {
|
||||
logger.debug('Template enregistré avec succès:', response);
|
||||
})
|
||||
.catch((error) => {
|
||||
logger.error(
|
||||
"Erreur lors de l'enregistrement du template:",
|
||||
error
|
||||
);
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
logger.error('Error during cloning or sending:', error);
|
||||
});
|
||||
});
|
||||
return createRegistrationSchoolFileTemplate(
|
||||
cloneData,
|
||||
csrfToken
|
||||
)
|
||||
.then((response) => {
|
||||
logger.debug('Template enregistré avec succès:', response);
|
||||
})
|
||||
.catch((error) => {
|
||||
logger.error(
|
||||
"Erreur lors de l'enregistrement du template:",
|
||||
error
|
||||
);
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
logger.error('Error during cloning or sending:', error);
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
logger.error('Error:', error);
|
||||
});
|
||||
|
||||
// Créer les parentFileTemplates pour chaque parentMaster
|
||||
const parentClonePromises = parent_masters.map(
|
||||
(parentMaster, index) => {
|
||||
const parentTemplateData = {
|
||||
master: parentMaster.id,
|
||||
registration_form: data.student.id,
|
||||
};
|
||||
|
||||
return createRegistrationParentFileTemplate(
|
||||
parentTemplateData,
|
||||
csrfToken
|
||||
)
|
||||
.then((response) => {
|
||||
logger.debug(
|
||||
'Parent template enregistré avec succès:',
|
||||
response
|
||||
);
|
||||
})
|
||||
.catch((error) => {
|
||||
logger.error(
|
||||
"Erreur lors de l'enregistrement du parent template:",
|
||||
error
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// Attendre que tous les clones soient créés
|
||||
Promise.all(clonePromises)
|
||||
@ -670,7 +717,11 @@ export default function Page({ params: { locale } }) {
|
||||
const actions = {
|
||||
1: [
|
||||
{
|
||||
icon: <Edit className="w-5 h-5 text-blue-500 hover:text-blue-700" />,
|
||||
icon: (
|
||||
<span title="Editer le dossier">
|
||||
<Edit className="w-5 h-5 text-blue-500 hover:text-blue-700" />
|
||||
</span>
|
||||
),
|
||||
onClick: () =>
|
||||
router.push(
|
||||
`${FE_ADMIN_SUBSCRIPTIONS_EDIT_URL}?studentId=${row.student.id}`
|
||||
@ -678,7 +729,9 @@ export default function Page({ params: { locale } }) {
|
||||
},
|
||||
{
|
||||
icon: (
|
||||
<Send className="w-5 h-5 text-green-500 hover:text-green-700" />
|
||||
<span title="Envoyer le dossier">
|
||||
<Send className="w-5 h-5 text-green-500 hover:text-green-700" />
|
||||
</span>
|
||||
),
|
||||
onClick: () =>
|
||||
sendConfirmRegisterForm(
|
||||
@ -690,7 +743,11 @@ export default function Page({ params: { locale } }) {
|
||||
],
|
||||
2: [
|
||||
{
|
||||
icon: <Edit className="w-5 h-5 text-blue-500 hover:text-blue-700" />,
|
||||
icon: (
|
||||
<span title="Editer le dossier">
|
||||
<Edit className="w-5 h-5 text-blue-500 hover:text-blue-700" />
|
||||
</span>
|
||||
),
|
||||
onClick: () =>
|
||||
router.push(
|
||||
`${FE_ADMIN_SUBSCRIPTIONS_EDIT_URL}?studentId=${row.student.id}`
|
||||
@ -700,18 +757,26 @@ export default function Page({ params: { locale } }) {
|
||||
3: [
|
||||
{
|
||||
icon: (
|
||||
<CircleCheck className="w-5 h-5 text-green-500 hover:text-green-700" />
|
||||
<span title="Valider le dossier">
|
||||
<CheckCircle className="w-5 h-5 text-green-500 hover:text-green-700" />
|
||||
</span>
|
||||
),
|
||||
onClick: () =>
|
||||
router.push(
|
||||
`${FE_ADMIN_SUBSCRIPTIONS_VALIDATE_URL}?studentId=${row.student.id}&firstName=${row.student.first_name}&lastName=${row.student.last_name}&paymentMode=${row.registration_payment}&file=${row.registration_file}`
|
||||
),
|
||||
onClick: () => {
|
||||
const paymentSepa =
|
||||
row.registration_payment === 1 || row.tuition_payment === 1
|
||||
? 1
|
||||
: 0;
|
||||
const url = `${FE_ADMIN_SUBSCRIPTIONS_VALIDATE_URL}?studentId=${row.student.id}&firstName=${row.student.first_name}&lastName=${row.student.last_name}&paymentSepa=${paymentSepa}&file=${row.registration_file}`;
|
||||
router.push(`${url}`);
|
||||
},
|
||||
},
|
||||
],
|
||||
5: [
|
||||
{
|
||||
icon: (
|
||||
<CircleCheck className="w-5 h-5 text-green-500 hover:text-green-700" />
|
||||
<span title="Valider le dossier">
|
||||
<CheckCircle className="w-5 h-5 text-green-500 hover:text-green-700" />
|
||||
</span>
|
||||
),
|
||||
onClick: () => openModalAssociationEleve(row.student),
|
||||
},
|
||||
@ -719,7 +784,9 @@ export default function Page({ params: { locale } }) {
|
||||
default: [
|
||||
{
|
||||
icon: (
|
||||
<Archive className="w-5 h-5 text-gray-500 hover:text-gray-700" />
|
||||
<span title="Archiver le dossier">
|
||||
<Archive className="w-5 h-5 text-gray-500 hover:text-gray-700" />
|
||||
</span>
|
||||
),
|
||||
onClick: () =>
|
||||
archiveFicheInscription(
|
||||
@ -785,17 +852,34 @@ export default function Page({ params: { locale } }) {
|
||||
},
|
||||
{
|
||||
name: t('files'),
|
||||
transform: (row) =>
|
||||
row.registration_file != null && (
|
||||
<ul>
|
||||
transform: (row) => (
|
||||
<ul>
|
||||
{row.registration_file && (
|
||||
<li className="flex justify-center items-center gap-2">
|
||||
<FileText size={16} />
|
||||
<a href={`${BASE_URL}${row.registration_file}`} target="_blank">
|
||||
<a
|
||||
href={`${BASE_URL}${row.registration_file}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
{row.registration_file?.split('/').pop()}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
),
|
||||
)}
|
||||
{row.sepa_file && (
|
||||
<li className="flex justify-center items-center gap-2">
|
||||
<FileText size={16} />
|
||||
<a
|
||||
href={`${BASE_URL}${row.sepa_file}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
{row.sepa_file?.split('/').pop()}
|
||||
</a>
|
||||
</li>
|
||||
)}
|
||||
</ul>
|
||||
),
|
||||
},
|
||||
{
|
||||
name: 'Actions',
|
||||
@ -865,7 +949,7 @@ export default function Page({ params: { locale } }) {
|
||||
{
|
||||
label: (
|
||||
<>
|
||||
<CircleCheck size={16} className="mr-2" /> Rattacher
|
||||
<CheckCircle size={16} className="mr-2" /> Rattacher
|
||||
</>
|
||||
),
|
||||
onClick: () => openModalAssociationEleve(row.student),
|
||||
|
||||
@ -15,7 +15,7 @@ export default function Page() {
|
||||
const studentId = searchParams.get('studentId');
|
||||
const firstName = searchParams.get('firstName');
|
||||
const lastName = searchParams.get('lastName');
|
||||
const paymentMode = searchParams.get('paymentMode');
|
||||
const paymentSepa = searchParams.get('paymentSepa') === '1';
|
||||
const file = searchParams.get('file');
|
||||
|
||||
const csrfToken = useCsrfToken();
|
||||
@ -45,7 +45,7 @@ export default function Page() {
|
||||
studentId={studentId}
|
||||
firstName={firstName}
|
||||
lastName={lastName}
|
||||
paymentMode={paymentMode}
|
||||
paymentSepa={paymentSepa}
|
||||
file={file}
|
||||
onAccept={handleAcceptRF}
|
||||
/>
|
||||
|
||||
@ -2,21 +2,28 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import Table from '@/components/Table';
|
||||
import { Edit, Users } from 'lucide-react';
|
||||
import { Edit3, Users, Download, Eye, Upload } from 'lucide-react';
|
||||
import StatusLabel from '@/components/StatusLabel';
|
||||
import FileUpload from '@/components/FileUpload';
|
||||
import { FE_PARENTS_EDIT_INSCRIPTION_URL } from '@/utils/Url';
|
||||
import { fetchChildren } from '@/app/actions/subscriptionAction';
|
||||
import {
|
||||
fetchChildren,
|
||||
sendSEPARegisterForm,
|
||||
} from '@/app/actions/subscriptionAction';
|
||||
import logger from '@/utils/logger';
|
||||
import { BASE_URL } from '@/utils/Url';
|
||||
import { useEstablishment } from '@/context/EstablishmentContext';
|
||||
import ProfileSelector from '@/components/ProfileSelector';
|
||||
import { useCsrfToken } from '@/context/CsrfContext';
|
||||
|
||||
export default function ParentHomePage() {
|
||||
const [children, setChildren] = useState([]);
|
||||
const [userId, setUserId] = useState(null);
|
||||
const [currentPage, setCurrentPage] = useState(1);
|
||||
const { user, selectedEstablishmentId } = useEstablishment();
|
||||
|
||||
const [uploadingStudentId, setUploadingStudentId] = useState(null); // ID de l'étudiant pour l'upload
|
||||
const [uploadedFile, setUploadedFile] = useState(null); // Fichier uploadé
|
||||
const [uploadState, setUploadState] = useState('off'); // État "on" ou "off" pour l'affichage du composant
|
||||
const router = useRouter();
|
||||
const csrfToken = useCsrfToken();
|
||||
|
||||
useEffect(() => {
|
||||
const userIdFromSession = user.user_id;
|
||||
@ -27,17 +34,62 @@ export default function ParentHomePage() {
|
||||
});
|
||||
}, [selectedEstablishmentId]);
|
||||
|
||||
function handleView(eleveId) {
|
||||
logger.debug(`View dossier for student id: ${eleveId}`);
|
||||
router.push(
|
||||
`${FE_PARENTS_EDIT_INSCRIPTION_URL}?id=${userId}&studentId=${eleveId}&view=true`
|
||||
);
|
||||
}
|
||||
|
||||
function handleEdit(eleveId) {
|
||||
// Logique pour éditer le dossier de l'élève
|
||||
logger.debug(`Edit dossier for student id: ${eleveId}`);
|
||||
router.push(
|
||||
`${FE_PARENTS_EDIT_INSCRIPTION_URL}?id=${userId}&studentId=${eleveId}`
|
||||
);
|
||||
}
|
||||
|
||||
const actionColumns = [{ name: 'Action', transform: (row) => row.action }];
|
||||
const handleFileUpload = (file) => {
|
||||
if (!file) {
|
||||
logger.error("Aucun fichier sélectionné pour l'upload.");
|
||||
return;
|
||||
}
|
||||
setUploadedFile(file); // Conserve le fichier en mémoire
|
||||
logger.debug('Fichier sélectionné :', file.name);
|
||||
};
|
||||
|
||||
const handleSubmit = () => {
|
||||
if (!uploadedFile || !uploadingStudentId) {
|
||||
logger.error('Aucun fichier ou étudiant sélectionné.');
|
||||
return;
|
||||
}
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('sepa_file', uploadedFile); // Ajoute le fichier SEPA
|
||||
formData.append('status', 3); // Statut à envoyer
|
||||
|
||||
sendSEPARegisterForm(uploadingStudentId, formData, csrfToken)
|
||||
.then((response) => {
|
||||
logger.debug('RF mis à jour avec succès:', response);
|
||||
// Logique supplémentaire après la mise à jour (par exemple, redirection ou notification)
|
||||
})
|
||||
.catch((error) => {
|
||||
logger.error('Erreur lors de la mise à jour du RF:', error);
|
||||
});
|
||||
};
|
||||
|
||||
const toggleUpload = (studentId) => {
|
||||
if (uploadingStudentId === studentId && uploadState === 'on') {
|
||||
// Si le composant est déjà affiché pour cet étudiant, on le masque
|
||||
setUploadState('off');
|
||||
setUploadingStudentId(null);
|
||||
setUploadedFile(null); // Réinitialise le fichier
|
||||
} else {
|
||||
// Sinon, on l'affiche pour cet étudiant
|
||||
setUploadState('on');
|
||||
setUploadingStudentId(studentId);
|
||||
}
|
||||
};
|
||||
|
||||
// Définir les colonnes du tableau
|
||||
const childrenColumns = [
|
||||
{ name: 'Nom', transform: (row) => `${row.student.last_name}` },
|
||||
{ name: 'Prénom', transform: (row) => `${row.student.first_name}` },
|
||||
@ -52,29 +104,76 @@ export default function ParentHomePage() {
|
||||
{
|
||||
name: 'Actions',
|
||||
transform: (row) => (
|
||||
<div className="flex justify-center">
|
||||
<button
|
||||
className="p-2 hover:bg-gray-100 rounded-full transition-colors"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
handleEdit(row.student.id);
|
||||
}}
|
||||
aria-label="Modifier"
|
||||
>
|
||||
<Edit className="h-5 w-5" />
|
||||
</button>
|
||||
<div className="flex justify-center items-center gap-2">
|
||||
{row.status === 2 && (
|
||||
<button
|
||||
className="text-blue-500 hover:text-blue-700"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
handleEdit(row.student.id);
|
||||
}}
|
||||
aria-label="Remplir le dossier"
|
||||
>
|
||||
<Edit3 className="h-5 w-5" />
|
||||
</button>
|
||||
)}
|
||||
|
||||
{row.status === 3 && (
|
||||
<button
|
||||
className="text-purple-500 hover:text-purple-700"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
handleView(row.student.id);
|
||||
}}
|
||||
aria-label="Visualiser le dossier"
|
||||
>
|
||||
<Eye className="h-5 w-5" />
|
||||
</button>
|
||||
)}
|
||||
|
||||
{row.status === 7 && (
|
||||
<>
|
||||
<button
|
||||
className="flex items-center justify-center w-8 h-8 rounded-full text-purple-500 hover:text-purple-700"
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
handleView(row.student.id);
|
||||
}}
|
||||
aria-label="Visualiser le dossier"
|
||||
>
|
||||
<Eye className="h-5 w-5" />
|
||||
</button>
|
||||
<a
|
||||
href={`${BASE_URL}${row.sepa_file}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex items-center justify-center w-8 h-8 rounded-full text-green-500 hover:text-green-700"
|
||||
aria-label="Télécharger le mandat SEPA"
|
||||
>
|
||||
<Download className="h-5 w-5" />
|
||||
</a>
|
||||
{/* Nouvelle action Upload */}
|
||||
<button
|
||||
className={`flex items-center justify-center w-8 h-8 rounded-full ${
|
||||
uploadingStudentId === row.student.id && uploadState === 'on'
|
||||
? 'bg-blue-100 text-blue-600 ring-3 ring-blue-500'
|
||||
: 'text-blue-500 hover:text-blue-700'
|
||||
}`}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
toggleUpload(row.student.id); // Activer ou désactiver l'upload pour cet étudiant
|
||||
}}
|
||||
aria-label="Uploader un fichier"
|
||||
>
|
||||
<Upload className="h-5 w-5" />
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
const itemsPerPage = 5;
|
||||
const totalPages = Math.ceil(children.length / itemsPerPage) || 1;
|
||||
|
||||
const handlePageChange = (newPage) => {
|
||||
setCurrentPage(newPage);
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="px-2 py-4 md:px-4 max-w-full">
|
||||
<div>
|
||||
@ -86,13 +185,29 @@ export default function ParentHomePage() {
|
||||
<Table
|
||||
data={children}
|
||||
columns={childrenColumns}
|
||||
itemsPerPage={itemsPerPage}
|
||||
currentPage={currentPage}
|
||||
totalPages={totalPages}
|
||||
onPageChange={handlePageChange}
|
||||
defaultTheme="bg-gray-50"
|
||||
/>
|
||||
</div>
|
||||
{/* Composant FileUpload et bouton Valider en dessous du tableau */}
|
||||
{uploadState === 'on' && uploadingStudentId && (
|
||||
<div className="mt-4">
|
||||
<FileUpload
|
||||
selectionMessage="Sélectionnez un fichier à uploader"
|
||||
onFileSelect={handleFileUpload}
|
||||
/>
|
||||
<button
|
||||
className={`mt-4 px-6 py-2 rounded-md ${
|
||||
uploadedFile
|
||||
? 'bg-emerald-500 text-white hover:bg-emerald-600'
|
||||
: 'bg-gray-300 text-gray-700 cursor-not-allowed'
|
||||
}`}
|
||||
onClick={handleSubmit}
|
||||
disabled={!uploadedFile}
|
||||
>
|
||||
Valider
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
import {
|
||||
BE_SUBSCRIPTION_REGISTRATIONFILE_GROUPS_URL,
|
||||
BE_SUBSCRIPTION_REGISTRATION_TEMPLATES_URL,
|
||||
BE_SUBSCRIPTION_REGISTRATION_TEMPLATE_MASTER_URL,
|
||||
BE_SUBSCRIPTION_REGISTRATION_SCHOOL_FILE_TEMPLATES_URL,
|
||||
BE_SUBSCRIPTION_REGISTRATION_SCHOOL_FILE_MASTERS_URL,
|
||||
BE_SUBSCRIPTION_REGISTRATION_PARENT_FILE_MASTERS_URL,
|
||||
BE_SUBSCRIPTION_REGISTRATION_PARENT_FILE_TEMPLATES_URL,
|
||||
FE_API_DOCUSEAL_CLONE_URL,
|
||||
FE_API_DOCUSEAL_DOWNLOAD_URL,
|
||||
FE_API_DOCUSEAL_GENERATE_TOKEN,
|
||||
@ -18,6 +20,8 @@ const requestResponseHandler = async (response) => {
|
||||
throw error;
|
||||
};
|
||||
|
||||
// FETCH requests
|
||||
|
||||
export async function fetchRegistrationFileGroups(establishment) {
|
||||
const response = await fetch(
|
||||
`${BE_SUBSCRIPTION_REGISTRATIONFILE_GROUPS_URL}?establishment_id=${establishment}`,
|
||||
@ -34,6 +38,68 @@ export async function fetchRegistrationFileGroups(establishment) {
|
||||
return response.json();
|
||||
}
|
||||
|
||||
export const fetchRegistrationFileFromGroup = async (groupId) => {
|
||||
const response = await fetch(
|
||||
`${BE_SUBSCRIPTION_REGISTRATIONFILE_GROUPS_URL}/${groupId}/school_file_templates`,
|
||||
{
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
},
|
||||
}
|
||||
);
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
'Erreur lors de la récupération des fichiers associés au groupe'
|
||||
);
|
||||
}
|
||||
return response.json();
|
||||
};
|
||||
|
||||
export const fetchRegistrationSchoolFileMasters = (id = null) => {
|
||||
let url = `${BE_SUBSCRIPTION_REGISTRATION_SCHOOL_FILE_MASTERS_URL}`;
|
||||
if (id) {
|
||||
url = `${BE_SUBSCRIPTION_REGISTRATION_SCHOOL_FILE_MASTERS_URL}/${id}`;
|
||||
}
|
||||
const request = new Request(`${url}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
return fetch(request).then(requestResponseHandler);
|
||||
};
|
||||
|
||||
export const fetchRegistrationParentFileMasters = (id = null) => {
|
||||
let url = `${BE_SUBSCRIPTION_REGISTRATION_PARENT_FILE_MASTERS_URL}`;
|
||||
if (id) {
|
||||
url = `${BE_SUBSCRIPTION_REGISTRATION_PARENT_FILE_MASTERS_URL}/${id}`;
|
||||
}
|
||||
const request = new Request(`${url}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
return fetch(request).then(requestResponseHandler);
|
||||
};
|
||||
|
||||
export const fetchRegistrationSchoolFileTemplates = (id = null) => {
|
||||
let url = `${BE_SUBSCRIPTION_REGISTRATION_SCHOOL_FILE_TEMPLATES_URL}`;
|
||||
if (id) {
|
||||
url = `${BE_SUBSCRIPTION_REGISTRATION_SCHOOL_FILE_TEMPLATES_URL}/${id}`;
|
||||
}
|
||||
const request = new Request(`${url}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
return fetch(request).then(requestResponseHandler);
|
||||
};
|
||||
|
||||
// CREATE requests
|
||||
|
||||
export async function createRegistrationFileGroup(groupData, csrfToken) {
|
||||
const response = await fetch(
|
||||
`${BE_SUBSCRIPTION_REGISTRATIONFILE_GROUPS_URL}`,
|
||||
@ -55,20 +121,55 @@ export async function createRegistrationFileGroup(groupData, csrfToken) {
|
||||
return response.json();
|
||||
}
|
||||
|
||||
export async function deleteRegistrationFileGroup(groupId, csrfToken) {
|
||||
const response = await fetch(
|
||||
`${BE_SUBSCRIPTION_REGISTRATIONFILE_GROUPS_URL}/${groupId}`,
|
||||
{
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken,
|
||||
},
|
||||
credentials: 'include',
|
||||
}
|
||||
);
|
||||
export const createRegistrationSchoolFileMaster = (data, csrfToken) => {
|
||||
return fetch(`${BE_SUBSCRIPTION_REGISTRATION_SCHOOL_FILE_MASTERS_URL}`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
credentials: 'include',
|
||||
}).then(requestResponseHandler);
|
||||
};
|
||||
|
||||
return response;
|
||||
}
|
||||
export const createRegistrationParentFileMaster = (data, csrfToken) => {
|
||||
return fetch(`${BE_SUBSCRIPTION_REGISTRATION_PARENT_FILE_MASTERS_URL}`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
credentials: 'include',
|
||||
}).then(requestResponseHandler);
|
||||
};
|
||||
|
||||
export const createRegistrationSchoolFileTemplate = (data, csrfToken) => {
|
||||
return fetch(`${BE_SUBSCRIPTION_REGISTRATION_SCHOOL_FILE_TEMPLATES_URL}`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
credentials: 'include',
|
||||
}).then(requestResponseHandler);
|
||||
};
|
||||
|
||||
export const createRegistrationParentFileTemplate = (data, csrfToken) => {
|
||||
return fetch(`${BE_SUBSCRIPTION_REGISTRATION_PARENT_FILE_TEMPLATES_URL}`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
credentials: 'include',
|
||||
}).then(requestResponseHandler);
|
||||
};
|
||||
|
||||
// EDIT requests
|
||||
|
||||
export const editRegistrationFileGroup = async (
|
||||
groupId,
|
||||
@ -94,113 +195,9 @@ export const editRegistrationFileGroup = async (
|
||||
return response.json();
|
||||
};
|
||||
|
||||
export const fetchRegistrationFileFromGroup = async (groupId) => {
|
||||
const response = await fetch(
|
||||
`${BE_SUBSCRIPTION_REGISTRATIONFILE_GROUPS_URL}/${groupId}/templates`,
|
||||
{
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
},
|
||||
}
|
||||
);
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
'Erreur lors de la récupération des fichiers associés au groupe'
|
||||
);
|
||||
}
|
||||
return response.json();
|
||||
};
|
||||
|
||||
export const fetchRegistrationTemplates = (id = null) => {
|
||||
let url = `${BE_SUBSCRIPTION_REGISTRATION_TEMPLATES_URL}`;
|
||||
if (id) {
|
||||
url = `${BE_SUBSCRIPTION_REGISTRATION_TEMPLATES_URL}/${id}`;
|
||||
}
|
||||
const request = new Request(`${url}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
return fetch(request).then(requestResponseHandler);
|
||||
};
|
||||
|
||||
export const editRegistrationTemplates = (fileId, data, csrfToken) => {
|
||||
return fetch(`${BE_SUBSCRIPTION_REGISTRATION_TEMPLATES_URL}/${fileId}`, {
|
||||
method: 'PUT',
|
||||
body: data,
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken,
|
||||
},
|
||||
credentials: 'include',
|
||||
}).then(requestResponseHandler);
|
||||
};
|
||||
|
||||
export const createRegistrationTemplates = (data, csrfToken) => {
|
||||
return fetch(`${BE_SUBSCRIPTION_REGISTRATION_TEMPLATES_URL}`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
credentials: 'include',
|
||||
}).then(requestResponseHandler);
|
||||
};
|
||||
|
||||
export const deleteRegistrationTemplates = (fileId, csrfToken) => {
|
||||
return fetch(`${BE_SUBSCRIPTION_REGISTRATION_TEMPLATES_URL}/${fileId}`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken,
|
||||
},
|
||||
credentials: 'include',
|
||||
});
|
||||
};
|
||||
|
||||
export const fetchRegistrationTemplateMaster = (id = null) => {
|
||||
let url = `${BE_SUBSCRIPTION_REGISTRATION_TEMPLATE_MASTER_URL}`;
|
||||
if (id) {
|
||||
url = `${BE_SUBSCRIPTION_REGISTRATION_TEMPLATE_MASTER_URL}/${id}`;
|
||||
}
|
||||
const request = new Request(`${url}`, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
return fetch(request).then(requestResponseHandler);
|
||||
};
|
||||
|
||||
export const createRegistrationTemplateMaster = (data, csrfToken) => {
|
||||
return fetch(`${BE_SUBSCRIPTION_REGISTRATION_TEMPLATE_MASTER_URL}`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(data),
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
credentials: 'include',
|
||||
}).then(requestResponseHandler);
|
||||
};
|
||||
|
||||
export const deleteRegistrationTemplateMaster = (fileId, csrfToken) => {
|
||||
export const editRegistrationSchoolFileMaster = (fileId, data, csrfToken) => {
|
||||
return fetch(
|
||||
`${BE_SUBSCRIPTION_REGISTRATION_TEMPLATE_MASTER_URL}/${fileId}`,
|
||||
{
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken,
|
||||
},
|
||||
credentials: 'include',
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export const editRegistrationTemplateMaster = (fileId, data, csrfToken) => {
|
||||
return fetch(
|
||||
`${BE_SUBSCRIPTION_REGISTRATION_TEMPLATE_MASTER_URL}/${fileId}`,
|
||||
`${BE_SUBSCRIPTION_REGISTRATION_SCHOOL_FILE_MASTERS_URL}/${fileId}`,
|
||||
{
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(data),
|
||||
@ -213,6 +210,128 @@ export const editRegistrationTemplateMaster = (fileId, data, csrfToken) => {
|
||||
).then(requestResponseHandler);
|
||||
};
|
||||
|
||||
export const editRegistrationParentFileMaster = (id, data, csrfToken) => {
|
||||
return fetch(
|
||||
`${BE_SUBSCRIPTION_REGISTRATION_PARENT_FILE_MASTERS_URL}/${id}`,
|
||||
{
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(data),
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken,
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
credentials: 'include',
|
||||
}
|
||||
).then(requestResponseHandler);
|
||||
};
|
||||
|
||||
export const editRegistrationSchoolFileTemplates = (
|
||||
fileId,
|
||||
data,
|
||||
csrfToken
|
||||
) => {
|
||||
return fetch(
|
||||
`${BE_SUBSCRIPTION_REGISTRATION_SCHOOL_FILE_TEMPLATES_URL}/${fileId}`,
|
||||
{
|
||||
method: 'PUT',
|
||||
body: data,
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken,
|
||||
},
|
||||
credentials: 'include',
|
||||
}
|
||||
).then(requestResponseHandler);
|
||||
};
|
||||
|
||||
export const editRegistrationParentFileTemplates = (
|
||||
fileId,
|
||||
data,
|
||||
csrfToken
|
||||
) => {
|
||||
return fetch(
|
||||
`${BE_SUBSCRIPTION_REGISTRATION_PARENT_FILE_TEMPLATES_URL}/${fileId}`,
|
||||
{
|
||||
method: 'PUT',
|
||||
body: data,
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken,
|
||||
},
|
||||
credentials: 'include',
|
||||
}
|
||||
).then(requestResponseHandler);
|
||||
};
|
||||
|
||||
// DELETE requests
|
||||
|
||||
export async function deleteRegistrationFileGroup(groupId, csrfToken) {
|
||||
const response = await fetch(
|
||||
`${BE_SUBSCRIPTION_REGISTRATIONFILE_GROUPS_URL}/${groupId}`,
|
||||
{
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken,
|
||||
},
|
||||
credentials: 'include',
|
||||
}
|
||||
);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
export const deleteRegistrationSchoolFileMaster = (fileId, csrfToken) => {
|
||||
return fetch(
|
||||
`${BE_SUBSCRIPTION_REGISTRATION_SCHOOL_FILE_MASTERS_URL}/${fileId}`,
|
||||
{
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken,
|
||||
},
|
||||
credentials: 'include',
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export const deleteRegistrationParentFileMaster = (id, csrfToken) => {
|
||||
return fetch(
|
||||
`${BE_SUBSCRIPTION_REGISTRATION_PARENT_FILE_MASTERS_URL}/${id}`,
|
||||
{
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken,
|
||||
},
|
||||
credentials: 'include',
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export const deleteRegistrationSchoolFileTemplates = (fileId, csrfToken) => {
|
||||
return fetch(
|
||||
`${BE_SUBSCRIPTION_REGISTRATION_SCHOOL_FILE_TEMPLATES_URL}/${fileId}`,
|
||||
{
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken,
|
||||
},
|
||||
credentials: 'include',
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export const deleteRegistrationParentFileTemplate = (id, csrfToken) => {
|
||||
return fetch(
|
||||
`${BE_SUBSCRIPTION_REGISTRATION_PARENT_FILE_TEMPLATES_URL}/${id}`,
|
||||
{
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken,
|
||||
},
|
||||
credentials: 'include',
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
// API requests
|
||||
|
||||
export const cloneTemplate = (templateId, email, is_required) => {
|
||||
return fetch(`${FE_API_DOCUSEAL_CLONE_URL}`, {
|
||||
method: 'POST',
|
||||
|
||||
@ -153,9 +153,27 @@ export async function getRegisterFormFileTemplate(fileId) {
|
||||
return response.json();
|
||||
}
|
||||
|
||||
export const fetchTemplatesFromRegistrationFiles = async (id) => {
|
||||
export const fetchSchoolFileTemplatesFromRegistrationFiles = async (id) => {
|
||||
const response = await fetch(
|
||||
`${BE_SUBSCRIPTION_REGISTERFORMS_URL}/${id}/templates`,
|
||||
`${BE_SUBSCRIPTION_REGISTERFORMS_URL}/${id}/school_file_templates`,
|
||||
{
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
},
|
||||
}
|
||||
);
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
'Erreur lors de la récupération des fichiers associés au groupe'
|
||||
);
|
||||
}
|
||||
return response.json();
|
||||
};
|
||||
|
||||
export const fetchParentFileTemplatesFromRegistrationFiles = async (id) => {
|
||||
const response = await fetch(
|
||||
`${BE_SUBSCRIPTION_REGISTERFORMS_URL}/${id}/parent_file_templates`,
|
||||
{
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
|
||||
Reference in New Issue
Block a user