mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-28 23:43:22 +00:00
fix: Champs requis sur les teachers and classes
This commit is contained in:
@ -161,7 +161,7 @@ const ClassesSection = ({ classes, setClasses, teachers, handleCreate, handleEdi
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSaveNewClass = () => {
|
const handleSaveNewClass = () => {
|
||||||
if (newClass.atmosphere_name) {
|
if (newClass.atmosphere_name && newClass.age_range && newClass.levels.length > 0 && newClass.number_of_students && newClass.school_year) {
|
||||||
handleCreate(newClass)
|
handleCreate(newClass)
|
||||||
.then((createdClass) => {
|
.then((createdClass) => {
|
||||||
setClasses((prevClasses) => [createdClass, ...classes]);
|
setClasses((prevClasses) => [createdClass, ...classes]);
|
||||||
@ -178,21 +178,21 @@ const ClassesSection = ({ classes, setClasses, teachers, handleCreate, handleEdi
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleUpdateClass = (id, updatedData) => {
|
const handleUpdateClass = (id, updatedData) => {
|
||||||
if (!updatedData.atmosphere_name) {
|
if (updatedData.atmosphere_name && updatedData.age_range && updatedData.levels.length > 0 && updatedData.number_of_students && updatedData.school_year) {
|
||||||
setLocalErrors({ atmosphere_name: 'Le nom d\'ambiance est requis.' });
|
handleEdit(id, updatedData)
|
||||||
return;
|
.then((updatedClass) => {
|
||||||
|
setClasses((prevClasses) => prevClasses.map((classe) => (classe.id === id ? updatedClass : classe)));
|
||||||
|
setEditingClass(null);
|
||||||
|
setFormData({});
|
||||||
|
setLocalErrors({});
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
setPopupMessage("Tous les champs doivent être remplis et valides");
|
||||||
|
setPopupVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleEdit(id, updatedData)
|
|
||||||
.then((updatedClass) => {
|
|
||||||
setClasses((prevClasses) => prevClasses.map((classe) => (classe.id === id ? updatedClass : classe)));
|
|
||||||
setEditingClass(null);
|
|
||||||
setFormData({});
|
|
||||||
setLocalErrors({});
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.error(error);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleTeachersChange = (selectedTeachers) => {
|
const handleTeachersChange = (selectedTeachers) => {
|
||||||
|
|||||||
@ -150,25 +150,30 @@ const TeachersSection = ({ teachers, setTeachers, specialities, handleCreate, ha
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleUpdateTeacher = (id, updatedData) => {
|
const handleUpdateTeacher = (id, updatedData) => {
|
||||||
console.log(updatedData)
|
if (updatedData.last_name && updatedData.first_name && updatedData.email) {
|
||||||
const data = {
|
const data = {
|
||||||
email: updatedData.email,
|
email: updatedData.email,
|
||||||
username: updatedData.email,
|
username: updatedData.email,
|
||||||
droit: updatedData.droit,
|
droit: updatedData.droit,
|
||||||
};
|
};
|
||||||
updateProfile(updatedData.associated_profile, data, csrfToken)
|
updateProfile(updatedData.associated_profile, data, csrfToken)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
console.log('Success:', response);
|
console.log('Success:', response);
|
||||||
handleEdit(id, updatedData)
|
handleEdit(id, updatedData)
|
||||||
.then((updatedTeacher) => {
|
.then((updatedTeacher) => {
|
||||||
setTeachers(prevTeachers => prevTeachers.map(teacher => teacher.id === id ? { ...teacher, ...updatedTeacher } : teacher));
|
setTeachers(prevTeachers => prevTeachers.map(teacher => teacher.id === id ? { ...teacher, ...updatedTeacher } : teacher));
|
||||||
setEditingTeacher(null);
|
setEditingTeacher(null);
|
||||||
setFormData({});
|
setFormData({});
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
setPopupMessage("Tous les champs doivent être remplis et valides");
|
||||||
|
setPopupVisible(true);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleChange = (e) => {
|
const handleChange = (e) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user