mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 16:03:21 +00:00
feat: Ajout d'un nouveau status avec envoi de mandat SEPA + envoi de
This commit is contained in:
@ -14,6 +14,7 @@ import Modal from '@/components/Modal';
|
||||
import InscriptionForm from '@/components/Inscription/InscriptionForm'
|
||||
import AffectationClasseForm from '@/components/AffectationClasseForm'
|
||||
import { useEstablishment } from '@/context/EstablishmentContext';
|
||||
import ValidateSubscription from '@/components/Inscription/ValidateSubscription';
|
||||
|
||||
import {
|
||||
PENDING,
|
||||
@ -44,7 +45,8 @@ import { createProfile, deleteProfile, fetchProfiles } from '@/app/actions/authA
|
||||
|
||||
import {
|
||||
BASE_URL,
|
||||
FE_ADMIN_SUBSCRIPTIONS_EDIT_URL } from '@/utils/Url';
|
||||
FE_ADMIN_SUBSCRIPTIONS_EDIT_URL,
|
||||
FE_ADMIN_SUBSCRIPTIONS_VALIDATE_URL } from '@/utils/Url';
|
||||
|
||||
import DjangoCSRFToken from '@/components/DjangoCSRFToken'
|
||||
import { useCsrfToken } from '@/context/CsrfContext';
|
||||
@ -594,11 +596,7 @@ useEffect(()=>{
|
||||
3: [
|
||||
{
|
||||
icon: <CircleCheck className="w-5 h-5 text-green-500 hover:text-green-700" />,
|
||||
onClick: () => openModalAssociationEleve(row.student),
|
||||
},
|
||||
{
|
||||
icon: <XCircle className="w-5 h-5 text-red-500 hover:text-red-700" />,
|
||||
onClick: () => refuseRegistrationForm(row.student.id, row.student.last_name, row.student.first_name, row.student.guardians[0].associated_profile_email),
|
||||
onClick: () => window.location.href = `${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}`,
|
||||
},
|
||||
],
|
||||
5: [
|
||||
|
||||
@ -0,0 +1,53 @@
|
||||
'use client'
|
||||
import React from 'react';
|
||||
import { useSearchParams, useRouter } from 'next/navigation';
|
||||
import ValidateSubscription from '@/components/Inscription/ValidateSubscription';
|
||||
import { sendSEPARegisterForm } from "@/app/actions/subscriptionAction"
|
||||
import { useCsrfToken } from '@/context/CsrfContext';
|
||||
import logger from '@/utils/logger';
|
||||
import { FE_ADMIN_SUBSCRIPTIONS_URL} from '@/utils/Url';
|
||||
|
||||
export default function Page() {
|
||||
const searchParams = useSearchParams();
|
||||
const router = useRouter();
|
||||
|
||||
// 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 paymentMode = searchParams.get('paymentMode');
|
||||
const file = searchParams.get('file');
|
||||
|
||||
const csrfToken = useCsrfToken();
|
||||
|
||||
const handleAcceptRF = (data) => {
|
||||
logger.debug('Mise à jour du RF avec les données:', data);
|
||||
|
||||
const {status, sepa_file} = data
|
||||
const formData = new FormData();
|
||||
formData.append('status', status); // Ajoute le statut
|
||||
formData.append('sepa_file', sepa_file); // Ajoute le fichier SEPA
|
||||
|
||||
// Appeler l'API pour mettre à jour le RF
|
||||
sendSEPARegisterForm(studentId, formData, csrfToken)
|
||||
.then((response) => {
|
||||
logger.debug('RF mis à jour avec succès:', response);
|
||||
router.push(FE_ADMIN_SUBSCRIPTIONS_URL);
|
||||
// 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);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<ValidateSubscription
|
||||
studentId={studentId}
|
||||
firstName={firstName}
|
||||
lastName={lastName}
|
||||
paymentMode={paymentMode}
|
||||
file={file}
|
||||
onAccept={handleAcceptRF}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@ -3,6 +3,7 @@ import React, { useState } from 'react';
|
||||
import InscriptionFormShared from '@/components/Inscription/InscriptionFormShared';
|
||||
import { useSearchParams, useRouter } from 'next/navigation';
|
||||
import { useCsrfToken } from '@/context/CsrfContext';
|
||||
import { useEstablishment } from '@/context/EstablishmentContext';
|
||||
import { FE_PARENTS_HOME_URL} from '@/utils/Url';
|
||||
import { editRegisterForm} from '@/app/actions/subscriptionAction';
|
||||
import logger from '@/utils/logger';
|
||||
@ -13,6 +14,7 @@ export default function Page() {
|
||||
const studentId = searchParams.get('studentId');
|
||||
const router = useRouter();
|
||||
const csrfToken = useCsrfToken();
|
||||
const { selectedEstablishmentId } = useEstablishment();
|
||||
|
||||
const handleSubmit = async (data) => {
|
||||
try {
|
||||
@ -28,6 +30,7 @@ export default function Page() {
|
||||
<InscriptionFormShared
|
||||
studentId={studentId}
|
||||
csrfToken={csrfToken}
|
||||
selectedEstablishmentId={selectedEstablishmentId}
|
||||
onSubmit={handleSubmit}
|
||||
cancelUrl={FE_PARENTS_HOME_URL}
|
||||
/>
|
||||
|
||||
@ -62,25 +62,6 @@ export default function ParentHomePage() {
|
||||
{ name: 'Action', transform: (row) => row.action },
|
||||
];
|
||||
|
||||
const getShadowColor = (status) => {
|
||||
switch (status) {
|
||||
case 1:
|
||||
return 'shadow-blue-500'; // Couleur d'ombre plus visible
|
||||
case 2:
|
||||
return 'shadow-orange-500'; // Couleur d'ombre plus visible
|
||||
case 3:
|
||||
return 'shadow-purple-500'; // Couleur d'ombre plus visible
|
||||
case 4:
|
||||
return 'shadow-red-500'; // Couleur d'ombre plus visible
|
||||
case 5:
|
||||
return 'shadow-green-500'; // Couleur d'ombre plus visible
|
||||
case 6:
|
||||
return 'shadow-red-500'; // Couleur d'ombre plus visible
|
||||
default:
|
||||
return 'shadow-green-500'; // Couleur d'ombre plus visible
|
||||
}
|
||||
};
|
||||
|
||||
// Définir les colonnes du tableau
|
||||
const childrenColumns = [
|
||||
{ name: 'Nom', transform: (row) => `${row.student.last_name}` },
|
||||
@ -89,7 +70,7 @@ export default function ParentHomePage() {
|
||||
name: 'Statut',
|
||||
transform: (row) => (
|
||||
<div className="flex justify-center items-center">
|
||||
<StatusLabel status={row.status} showDropdown={false}/>
|
||||
<StatusLabel status={row.status} showDropdown={false} parent/>
|
||||
</div>
|
||||
)
|
||||
},
|
||||
|
||||
@ -2,7 +2,8 @@ import { BE_SUBSCRIPTION_REGISTRATIONFILE_GROUPS_URL,
|
||||
BE_SUBSCRIPTION_REGISTRATION_TEMPLATES_URL,
|
||||
BE_SUBSCRIPTION_REGISTRATION_TEMPLATE_MASTER_URL,
|
||||
FE_API_DOCUSEAL_CLONE_URL,
|
||||
FE_API_DOCUSEAL_DOWNLOAD_URL
|
||||
FE_API_DOCUSEAL_DOWNLOAD_URL,
|
||||
FE_API_DOCUSEAL_GENERATE_TOKEN
|
||||
} from '@/utils/Url';
|
||||
|
||||
const requestResponseHandler = async (response) => {
|
||||
@ -220,4 +221,14 @@ export const downloadTemplate = (slug) => {
|
||||
}
|
||||
})
|
||||
.then(requestResponseHandler)
|
||||
}
|
||||
}
|
||||
|
||||
export const generateToken = (email, id = null) => {
|
||||
return fetch(`${FE_API_DOCUSEAL_GENERATE_TOKEN}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ user_email: email, id }),
|
||||
}).then(requestResponseHandler);
|
||||
};
|
||||
@ -56,6 +56,17 @@ export const editRegisterForm=(id, data, csrfToken)=>{
|
||||
.then(requestResponseHandler)
|
||||
};
|
||||
|
||||
export const sendSEPARegisterForm=(id, data, csrfToken)=>{
|
||||
return fetch(`${BE_SUBSCRIPTION_REGISTERFORMS_URL}/${id}`, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken
|
||||
},
|
||||
body: data,
|
||||
credentials: 'include'
|
||||
})
|
||||
.then(requestResponseHandler)
|
||||
};
|
||||
|
||||
export const createRegisterForm=(data, csrfToken)=>{
|
||||
const url = `${BE_SUBSCRIPTION_REGISTERFORMS_URL}`;
|
||||
|
||||
Reference in New Issue
Block a user