mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
feat: Gestion de la mise à jour des profiles / roles / lors de l'édition
du formulaire RF
This commit is contained in:
@ -26,7 +26,6 @@ import {
|
||||
sendRegisterForm,
|
||||
archiveRegisterForm,
|
||||
editRegisterForm,
|
||||
editRegisterFormWithBinaryFile,
|
||||
} from '@/app/actions/subscriptionAction';
|
||||
|
||||
import { fetchClasses } from '@/app/actions/schoolAction';
|
||||
@ -291,7 +290,7 @@ export default function Page({ params: { locale } }) {
|
||||
formData.append('sepa_file', file);
|
||||
|
||||
// Appeler l'API pour uploader le fichier SEPA
|
||||
editRegisterFormWithBinaryFile(row.student.id, formData, csrfToken)
|
||||
editRegisterForm(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.');
|
||||
@ -386,86 +385,6 @@ export default function Page({ params: { locale } }) {
|
||||
}
|
||||
};
|
||||
|
||||
const updateRF = (updatedData) => {
|
||||
logger.debug('updateRF updatedData:', updatedData);
|
||||
|
||||
const data = {
|
||||
student: {
|
||||
guardians:
|
||||
updatedData.selectedGuardians.length !== 0
|
||||
? updatedData.selectedGuardians.map((guardianId) => ({
|
||||
id: guardianId,
|
||||
}))
|
||||
: (() => {
|
||||
if (updatedData.isExistingParentProfile) {
|
||||
return [
|
||||
{
|
||||
profile_role_data: {
|
||||
establishment: selectedEstablishmentId,
|
||||
role_type: 2,
|
||||
is_active: false,
|
||||
profile: updatedData.existingProfileId, // Associer au profil existant
|
||||
},
|
||||
last_name: updatedData.guardianLastName,
|
||||
first_name: updatedData.guardianFirstName,
|
||||
birth_date: updatedData.guardianBirthDate,
|
||||
address: updatedData.guardianAddress,
|
||||
phone: updatedData.guardianPhone,
|
||||
profession: updatedData.guardianProfession,
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
// Si aucun profil existant n'est trouvé, créer un nouveau profil
|
||||
return [
|
||||
{
|
||||
profile_role_data: {
|
||||
establishment: selectedEstablishmentId,
|
||||
role_type: 2,
|
||||
is_active: false,
|
||||
profile_data: {
|
||||
email: updatedData.guardianEmail,
|
||||
password: 'Provisoire01!',
|
||||
username: updatedData.guardianEmail,
|
||||
},
|
||||
},
|
||||
last_name: updatedData.guardianLastName,
|
||||
first_name: updatedData.guardianFirstName,
|
||||
birth_date: updatedData.guardianBirthDate,
|
||||
address: updatedData.guardianAddress,
|
||||
phone: updatedData.guardianPhone,
|
||||
profession: updatedData.guardianProfession,
|
||||
},
|
||||
];
|
||||
})(),
|
||||
},
|
||||
establishment: selectedEstablishmentId,
|
||||
};
|
||||
|
||||
editRegisterForm(student.id, data, csrfToken)
|
||||
.then((data) => {
|
||||
// Mise à jour immédiate des données
|
||||
setRegistrationFormsDataCurrentYear((prevState) => [
|
||||
...(prevState || []),
|
||||
data,
|
||||
]);
|
||||
setTotalCurrentYear((prev) => prev + 1);
|
||||
if (updatedData.autoMail) {
|
||||
sendConfirmRegisterForm(
|
||||
data.student.id,
|
||||
updatedData.studentLastName,
|
||||
updatedData.studentFirstName
|
||||
);
|
||||
}
|
||||
handleCloseAddGuardian();
|
||||
// Forcer le rechargement complet des données
|
||||
setReloadFetch(true);
|
||||
})
|
||||
.catch((error) => {
|
||||
logger.error('Error during updating registration form:', error);
|
||||
});
|
||||
};
|
||||
|
||||
const getActionsByStatus = (row) => {
|
||||
const actions = {
|
||||
// Etat "A envoyer" :
|
||||
@ -511,7 +430,7 @@ export default function Page({ params: { locale } }) {
|
||||
),
|
||||
onClick: () =>
|
||||
router.push(
|
||||
`${FE_ADMIN_SUBSCRIPTIONS_CREATE_URL}?id=${row.student.id}&school_year=${activeTab}`
|
||||
`${FE_ADMIN_SUBSCRIPTIONS_EDIT_URL}?studentId=${row.student.id}&enabled=true`
|
||||
),
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user