mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
feat: Ajout des payementPlans dans le formulaire / ajout de la photo
This commit is contained in:
@ -14,6 +14,8 @@ import {
|
||||
import {
|
||||
fetchRegistrationPaymentModes,
|
||||
fetchTuitionPaymentModes,
|
||||
fetchRegistrationPaymentPlans,
|
||||
fetchTuitionPaymentPlans,
|
||||
} from '@/app/actions/schoolAction';
|
||||
import { BASE_URL } from '@/utils/Url';
|
||||
import logger from '@/utils/logger';
|
||||
@ -53,13 +55,14 @@ export default function InscriptionFormShared({
|
||||
nationality: '',
|
||||
attending_physician: '',
|
||||
level: '',
|
||||
registration_payment: '',
|
||||
tuition_payment: '',
|
||||
photo: '',
|
||||
});
|
||||
const [guardians, setGuardians] = useState([]);
|
||||
|
||||
const [registrationPaymentModes, setRegistrationPaymentModes] = useState([]);
|
||||
const [tuitionPaymentModes, setTuitionPaymentModes] = useState([]);
|
||||
const [registrationPaymentPlans, setRegistrationPaymentPlans] = useState([]);
|
||||
const [tuitionPaymentPlans, setTuitionPaymentPlans] = useState([]);
|
||||
|
||||
// États pour la gestion des fichiers
|
||||
const [uploadedFiles, setUploadedFiles] = useState([]);
|
||||
@ -194,6 +197,12 @@ export default function InscriptionFormShared({
|
||||
|
||||
// Fetch data for tuition payment modes
|
||||
handleTuitionPaymentModes();
|
||||
|
||||
// Fetch data for registration payment plans
|
||||
handleRegistrationPaymentPlans();
|
||||
|
||||
// Fetch data for tuition payment plans
|
||||
handleTuitionnPaymentPlans();
|
||||
}
|
||||
}, [selectedEstablishmentId]);
|
||||
|
||||
@ -223,6 +232,32 @@ export default function InscriptionFormShared({
|
||||
);
|
||||
};
|
||||
|
||||
const handleRegistrationPaymentPlans = () => {
|
||||
fetchRegistrationPaymentPlans(selectedEstablishmentId)
|
||||
.then((data) => {
|
||||
const activePaymentPlans = data.filter(
|
||||
(mode) => mode.is_active === true
|
||||
);
|
||||
setRegistrationPaymentPlans(activePaymentPlans);
|
||||
})
|
||||
.catch((error) =>
|
||||
logger.error('Error fetching registration payment plans:', error)
|
||||
);
|
||||
};
|
||||
|
||||
const handleTuitionnPaymentPlans = () => {
|
||||
fetchTuitionPaymentPlans(selectedEstablishmentId)
|
||||
.then((data) => {
|
||||
const activePaymentPlans = data.filter(
|
||||
(mode) => mode.is_active === true
|
||||
);
|
||||
setTuitionPaymentPlans(activePaymentPlans);
|
||||
})
|
||||
.catch((error) =>
|
||||
logger.error('Error fetching registration tuition plans:', error)
|
||||
);
|
||||
};
|
||||
|
||||
const handleFileUpload = (file, selectedFile) => {
|
||||
if (!file || !selectedFile) {
|
||||
logger.error('Données manquantes pour le téléversement.');
|
||||
@ -344,8 +379,12 @@ export default function InscriptionFormShared({
|
||||
status: isSepaPayment ? 8 : 3,
|
||||
tuition_payment: formData.tuition_payment,
|
||||
registration_payment: formData.registration_payment,
|
||||
tuition_payment_plan: formData.tuition_payment_plan,
|
||||
registration_payment_plan: formData.registration_payment_plan,
|
||||
};
|
||||
|
||||
console.log('jsonData : ', jsonData);
|
||||
|
||||
// Créer un objet FormData
|
||||
const formDataToSend = new FormData();
|
||||
|
||||
@ -450,6 +489,8 @@ export default function InscriptionFormShared({
|
||||
setFormData={setFormData}
|
||||
registrationPaymentModes={registrationPaymentModes}
|
||||
tuitionPaymentModes={tuitionPaymentModes}
|
||||
registrationPaymentPlans={registrationPaymentPlans}
|
||||
tuitionPaymentPlans={tuitionPaymentPlans}
|
||||
errors={errors}
|
||||
setIsPageValid={setIsPage3Valid}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user