mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
Merge branch 'refactoring' of ssh://git.v0id.ovh:5022/n3wt-innov/n3wt-school into refactoring
This commit is contained in:
@ -363,7 +363,6 @@ useEffect(()=>{
|
||||
|
||||
if (updatedData.selectedGuardians.length !== 0) {
|
||||
const selectedGuardiansIds = updatedData.selectedGuardians.map(guardianId => guardianId)
|
||||
|
||||
const data = {
|
||||
student: {
|
||||
last_name: updatedData.studentLastName,
|
||||
@ -374,88 +373,69 @@ useEffect(()=>{
|
||||
discounts: allDiscountsds
|
||||
};
|
||||
|
||||
createRegisterForm(data,csrfToken)
|
||||
.then(data => {
|
||||
console.log('Success:', data);
|
||||
setRegistrationFormsDataPending(prevState => {
|
||||
if (prevState) {
|
||||
return [...prevState, data];
|
||||
createRegisterForm(data, csrfToken)
|
||||
.then(data => {
|
||||
// Mise à jour immédiate des données
|
||||
setRegistrationFormsDataPending(prevState => [...(prevState || []), data]);
|
||||
setTotalPending(prev => prev + 1);
|
||||
if (updatedData.autoMail) {
|
||||
sendConfirmRegisterForm(data.student.id, updatedData.studentLastName, updatedData.studentFirstName);
|
||||
}
|
||||
return [data];
|
||||
});
|
||||
setTotalPending(totalPending+1);
|
||||
if (updatedData.autoMail) {
|
||||
sendConfirmRegisterForm(data.student.id, updatedData.studentLastName, updatedData.studentFirstName);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
closeModal();
|
||||
// Forcer le rechargement complet des données
|
||||
setReloadFetch(true);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
}
|
||||
else {
|
||||
// Création d'un profil associé à l'adresse mail du responsable saisie
|
||||
// Le profil est inactif
|
||||
const data = {
|
||||
email: updatedData.guardianEmail,
|
||||
password: 'Provisoire01!',
|
||||
username: updatedData.guardianEmail,
|
||||
is_active: 0, // On rend le profil inactif : impossible de s'y connecter dans la fenêtre du login tant qu'il ne s'est pas inscrit
|
||||
droit:2 // Profil PARENT
|
||||
}
|
||||
createProfile(data,csrfToken)
|
||||
});
|
||||
} else {
|
||||
const data = {
|
||||
email: updatedData.guardianEmail,
|
||||
password: 'Provisoire01!',
|
||||
username: updatedData.guardianEmail,
|
||||
is_active: 0,
|
||||
droit: 2
|
||||
}
|
||||
|
||||
createProfile(data, csrfToken)
|
||||
.then(response => {
|
||||
console.log('Success:', response);
|
||||
if (response.id) {
|
||||
let idProfile = response.id;
|
||||
if (response.id) {
|
||||
const data = {
|
||||
student: {
|
||||
last_name: updatedData.studentLastName,
|
||||
first_name: updatedData.studentFirstName,
|
||||
guardians: [{
|
||||
email: updatedData.guardianEmail,
|
||||
phone: updatedData.guardianPhone,
|
||||
associated_profile: response.id
|
||||
}],
|
||||
sibling: []
|
||||
}
|
||||
};
|
||||
|
||||
const data = {
|
||||
student: {
|
||||
last_name: updatedData.studentLastName,
|
||||
first_name: updatedData.studentFirstName,
|
||||
guardians: [
|
||||
{
|
||||
email: updatedData.guardianEmail,
|
||||
phone: updatedData.guardianPhone,
|
||||
associated_profile: idProfile // Association entre le responsable de l'élève et le profil créé par défaut précédemment
|
||||
}
|
||||
],
|
||||
sibling: []
|
||||
},
|
||||
fees: allFeesIds,
|
||||
discounts: allDiscountsds
|
||||
};
|
||||
|
||||
createRegisterForm(data,csrfToken)
|
||||
.then(data => {
|
||||
console.log('Success:', data);
|
||||
setRegistrationFormsDataPending(prevState => {
|
||||
if (prevState && prevState.length > 0) {
|
||||
return [...prevState, data];
|
||||
}
|
||||
return prevState;
|
||||
});
|
||||
setTotalPending(totalPending+1);
|
||||
if (updatedData.autoMail) {
|
||||
sendConfirmRegisterForm(data.student.id, updatedData.studentLastName, updatedData.studentFirstName);
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
}
|
||||
createRegisterForm(data, csrfToken)
|
||||
.then(data => {
|
||||
// Mise à jour immédiate des données
|
||||
setRegistrationFormsDataPending(prevState => [...(prevState || []), data]);
|
||||
setTotalPending(prev => prev + 1);
|
||||
if (updatedData.autoMail) {
|
||||
sendConfirmRegisterForm(data.student.id, updatedData.studentLastName, updatedData.studentFirstName);
|
||||
}
|
||||
closeModal();
|
||||
// Forcer le rechargement complet des données
|
||||
setReloadFetch(true);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error fetching data:', error);
|
||||
error = error.errorMessage;
|
||||
console.log(error);
|
||||
console.error('Error:', error);
|
||||
});
|
||||
}
|
||||
closeModal();
|
||||
setReloadFetch(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
const columns = [
|
||||
{ name: t('studentName'), transform: (row) => row.student.last_name },
|
||||
{ name: t('studentFistName'), transform: (row) => row.student.first_name },
|
||||
@ -469,11 +449,11 @@ const columns = [
|
||||
)
|
||||
},
|
||||
{ name: t('files'), transform: (row) =>
|
||||
(row.registerForms != null) &&(
|
||||
(row.registration_file != null) &&(
|
||||
<ul>
|
||||
<li className="flex items-center gap-2">
|
||||
<FileText size={16} />
|
||||
<a href={ `${BASE_URL}${row.registerForms}`} target='_blank'>{row.registerForms?.split('/').pop()}</a>
|
||||
<a href={ `${BASE_URL}${row.registration_file}`} target='_blank'>{row.registration_file?.split('/').pop()}</a>
|
||||
</li>
|
||||
</ul>
|
||||
) },
|
||||
@ -550,11 +530,11 @@ const columnsSubscribed = [
|
||||
)
|
||||
},
|
||||
{ name: t('files'), transform: (row) =>
|
||||
(row.registerForm != null) &&(
|
||||
(row.registration_file != null) &&(
|
||||
<ul>
|
||||
<li className="flex items-center gap-2">
|
||||
<FileText size={16} />
|
||||
<a href={ `${BASE_URL}${row.registerForm}`} target='_blank'>{row.registerForm?.split('/').pop()}</a>
|
||||
<a href={ `${BASE_URL}${row.registration_file}`} target='_blank'>{row.registration_file?.split('/').pop()}</a>
|
||||
</li>
|
||||
</ul>
|
||||
) },
|
||||
@ -720,7 +700,7 @@ const handleFileUpload = ({file, name, is_required, order}) => {
|
||||
text={(
|
||||
<>
|
||||
{t('subscribeFiles')}
|
||||
<span className="ml-2 text-sm text-gray-400">({totalSubscribed})</span>
|
||||
<span className="ml-2 text-sm text-gray-400">({fichiers.length})</span>
|
||||
</>
|
||||
)}
|
||||
active={activeTab === 'subscribeFiles'}
|
||||
@ -778,12 +758,14 @@ const handleFileUpload = ({file, name, is_required, order}) => {
|
||||
{/*SI STATE == subscribeFiles */}
|
||||
{activeTab === 'subscribeFiles' && (
|
||||
<div>
|
||||
<button
|
||||
onClick={() => { setIsModalOpen(true); setIsEditing(false); }}
|
||||
className="flex items-center bg-emerald-600 text-white p-2 rounded-full shadow hover:bg-emerald-900 transition duration-200 ml-4"
|
||||
>
|
||||
<Plus className="w-5 h-5" />
|
||||
</button>
|
||||
<div className="flex justify-end mb-4">
|
||||
<button
|
||||
onClick={() => { setIsModalOpen(true); setIsEditing(false); }}
|
||||
className="flex items-center bg-emerald-600 text-white p-2 rounded-full shadow hover:bg-emerald-900 transition duration-200"
|
||||
>
|
||||
<Plus className="w-5 h-5" />
|
||||
</button>
|
||||
</div>
|
||||
<Modal
|
||||
isOpen={isModalOpen}
|
||||
setIsOpen={setIsModalOpen}
|
||||
|
||||
Reference in New Issue
Block a user