fix: Champs requis sur les teachers and classes

This commit is contained in:
N3WT DE COMPET
2025-02-07 16:43:29 +01:00
parent 1a8ef26f58
commit 42b4c99be8
2 changed files with 35 additions and 30 deletions

View File

@ -150,25 +150,30 @@ const TeachersSection = ({ teachers, setTeachers, specialities, handleCreate, ha
};
const handleUpdateTeacher = (id, updatedData) => {
console.log(updatedData)
const data = {
email: updatedData.email,
username: updatedData.email,
droit: updatedData.droit,
};
updateProfile(updatedData.associated_profile, data, csrfToken)
.then(response => {
console.log('Success:', response);
handleEdit(id, updatedData)
.then((updatedTeacher) => {
setTeachers(prevTeachers => prevTeachers.map(teacher => teacher.id === id ? { ...teacher, ...updatedTeacher } : teacher));
setEditingTeacher(null);
setFormData({});
if (updatedData.last_name && updatedData.first_name && updatedData.email) {
const data = {
email: updatedData.email,
username: updatedData.email,
droit: updatedData.droit,
};
updateProfile(updatedData.associated_profile, data, csrfToken)
.then(response => {
console.log('Success:', response);
handleEdit(id, updatedData)
.then((updatedTeacher) => {
setTeachers(prevTeachers => prevTeachers.map(teacher => teacher.id === id ? { ...teacher, ...updatedTeacher } : teacher));
setEditingTeacher(null);
setFormData({});
})
})
})
.catch(error => {
console.error(error);
});
}
else {
setPopupMessage("Tous les champs doivent être remplis et valides");
setPopupVisible(true);
}
};
const handleChange = (e) => {