mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 16:03:21 +00:00
feat: Gestion de la validation du dossier d'inscription
This commit is contained in:
@ -35,7 +35,7 @@ import {
|
||||
archiveRegisterForm,
|
||||
fetchStudents,
|
||||
editRegisterForm,
|
||||
sendSEPARegisterForm,
|
||||
editRegisterFormWithBinaryFile,
|
||||
} from '@/app/actions/subscriptionAction';
|
||||
|
||||
import {
|
||||
@ -379,7 +379,7 @@ export default function Page({ params: { locale } }) {
|
||||
formData.append('sepa_file', file);
|
||||
|
||||
// Appeler l'API pour uploader le fichier SEPA
|
||||
sendSEPARegisterForm(row.student.id, formData, csrfToken)
|
||||
editRegisterFormWithBinaryFile(row.student.id, formData, csrfToken)
|
||||
.then((response) => {
|
||||
logger.debug('Mandat SEPA uploadé avec succès :', response);
|
||||
setPopupMessage('Le mandat SEPA a été uploadé avec succès.');
|
||||
@ -797,11 +797,7 @@ export default function Page({ params: { locale } }) {
|
||||
</span>
|
||||
),
|
||||
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}`;
|
||||
const url = `${FE_ADMIN_SUBSCRIPTIONS_VALIDATE_URL}?studentId=${row.student.id}&firstName=${row.student.first_name}&lastName=${row.student.last_name}&sepa_file=${row.sepa_file}&student_file=${row.registration_file}`;
|
||||
router.push(`${url}`);
|
||||
},
|
||||
},
|
||||
@ -809,11 +805,11 @@ export default function Page({ params: { locale } }) {
|
||||
5: [
|
||||
{
|
||||
icon: (
|
||||
<span title="Valider le dossier">
|
||||
<CheckCircle className="w-5 h-5 text-green-500 hover:text-green-700" />
|
||||
<span title="Voir les fichiers">
|
||||
<FileText className="w-5 h-5 text-cyan-500 hover:text-cyan-700" />
|
||||
</span>
|
||||
),
|
||||
onClick: () => openModalAssociationEleve(row.student),
|
||||
onClick: () => openFilesModal(row),
|
||||
},
|
||||
],
|
||||
7: [
|
||||
@ -1087,7 +1083,10 @@ export default function Page({ params: { locale } }) {
|
||||
key={`${currentPage}-${searchTerm}`}
|
||||
data={
|
||||
activeTab === 'pending'
|
||||
? registrationFormsDataPending
|
||||
? [
|
||||
...registrationFormsDataPending,
|
||||
...registrationFormsDataSubscribed,
|
||||
]
|
||||
: activeTab === 'subscribed'
|
||||
? registrationFormsDataSubscribed
|
||||
: registrationFormsDataArchived
|
||||
|
||||
@ -1,53 +1,59 @@
|
||||
'use client';
|
||||
import React from 'react';
|
||||
import React, { useState } from 'react';
|
||||
import { useSearchParams, useRouter } from 'next/navigation';
|
||||
import ValidateSubscription from '@/components/Inscription/ValidateSubscription';
|
||||
import { sendSEPARegisterForm } from '@/app/actions/subscriptionAction';
|
||||
import { editRegisterFormWithBinaryFile } from '@/app/actions/subscriptionAction';
|
||||
import { useCsrfToken } from '@/context/CsrfContext';
|
||||
import logger from '@/utils/logger';
|
||||
import Loader from '@/components/Loader';
|
||||
import { FE_ADMIN_SUBSCRIPTIONS_URL } from '@/utils/Url';
|
||||
|
||||
export default function Page() {
|
||||
const searchParams = useSearchParams();
|
||||
const router = useRouter();
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
// Récupérer les paramètres de la requête
|
||||
const studentId = searchParams.get('studentId');
|
||||
const firstName = searchParams.get('firstName');
|
||||
const lastName = searchParams.get('lastName');
|
||||
const paymentSepa = searchParams.get('paymentSepa') === '1';
|
||||
const file = searchParams.get('file');
|
||||
const sepa_file = searchParams.get('sepa_file');
|
||||
const student_file = searchParams.get('student_file');
|
||||
|
||||
const csrfToken = useCsrfToken();
|
||||
|
||||
const handleAcceptRF = (data) => {
|
||||
logger.debug('Mise à jour du RF avec les données:', data);
|
||||
|
||||
const { status, sepa_file, fusionParam } = data;
|
||||
const { status, fusionParam } = data;
|
||||
const formData = new FormData();
|
||||
formData.append('status', status); // Ajoute le statut
|
||||
formData.append('sepa_file', sepa_file); // Ajoute le fichier SEPA
|
||||
formData.append('fusion', fusionParam);
|
||||
|
||||
setIsLoading(true);
|
||||
// Appeler l'API pour mettre à jour le RF
|
||||
sendSEPARegisterForm(studentId, formData, csrfToken)
|
||||
editRegisterFormWithBinaryFile(studentId, formData, csrfToken)
|
||||
.then((response) => {
|
||||
logger.debug('RF mis à jour avec succès:', response);
|
||||
router.push(FE_ADMIN_SUBSCRIPTIONS_URL);
|
||||
setIsLoading(false);
|
||||
// Logique supplémentaire après la mise à jour (par exemple, redirection ou notification)
|
||||
})
|
||||
.catch((error) => {
|
||||
setIsLoading(false);
|
||||
logger.error('Erreur lors de la mise à jour du RF:', error);
|
||||
});
|
||||
};
|
||||
|
||||
if (isLoading) {
|
||||
return <Loader />;
|
||||
}
|
||||
|
||||
return (
|
||||
<ValidateSubscription
|
||||
studentId={studentId}
|
||||
firstName={firstName}
|
||||
lastName={lastName}
|
||||
paymentSepa={paymentSepa}
|
||||
file={file}
|
||||
sepa_file={sepa_file}
|
||||
student_file={student_file}
|
||||
onAccept={handleAcceptRF}
|
||||
/>
|
||||
);
|
||||
|
||||
@ -8,7 +8,7 @@ import FileUpload from '@/components/FileUpload';
|
||||
import { FE_PARENTS_EDIT_INSCRIPTION_URL } from '@/utils/Url';
|
||||
import {
|
||||
fetchChildren,
|
||||
sendSEPARegisterForm,
|
||||
editRegisterFormWithBinaryFile,
|
||||
} from '@/app/actions/subscriptionAction';
|
||||
import logger from '@/utils/logger';
|
||||
import { BASE_URL } from '@/utils/Url';
|
||||
@ -68,7 +68,7 @@ export default function ParentHomePage() {
|
||||
formData.append('sepa_file', uploadedFile); // Ajoute le fichier SEPA
|
||||
formData.append('status', 3); // Statut à envoyer
|
||||
|
||||
sendSEPARegisterForm(uploadingStudentId, formData, csrfToken)
|
||||
editRegisterFormWithBinaryFile(uploadingStudentId, formData, csrfToken)
|
||||
.then((response) => {
|
||||
logger.debug('RF mis à jour avec succès:', response);
|
||||
setReloadFetch(true);
|
||||
|
||||
Reference in New Issue
Block a user