mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
refactor: Partie FRONT / School
This commit is contained in:
@ -51,16 +51,16 @@ export const ClassesProvider = ({ children }) => {
|
||||
7: 'dimanche'
|
||||
};
|
||||
|
||||
const getNiveauxLabels = (niveaux) => {
|
||||
return niveaux.map(niveauId => {
|
||||
const getNiveauxLabels = (levels) => {
|
||||
return levels.map(niveauId => {
|
||||
const niveau = allNiveaux.find(n => n.id === niveauId);
|
||||
return niveau ? niveau.name : niveauId;
|
||||
});
|
||||
};
|
||||
|
||||
const getNiveauxTabs = (niveaux) => {
|
||||
// Trier les niveaux par id
|
||||
const sortedNiveaux = niveaux.sort((a, b) => a - b);
|
||||
const getNiveauxTabs = (levels) => {
|
||||
// Trier les levels par id
|
||||
const sortedNiveaux = levels.sort((a, b) => a - b);
|
||||
|
||||
// Mapper les labels correspondants
|
||||
return sortedNiveaux.map(niveauId => {
|
||||
@ -87,7 +87,7 @@ export const ClassesProvider = ({ children }) => {
|
||||
|
||||
const getAmbianceText = (classe) => {
|
||||
const ambiance = classe.nom_ambiance ? classe.nom_ambiance : '';
|
||||
const trancheAge = classe.tranche_age ? `${classe.tranche_age} ans` : '';
|
||||
const trancheAge = classe.age_range ? `${classe.age_range} ans` : '';
|
||||
|
||||
if (ambiance && trancheAge) {
|
||||
return `${ambiance} (${trancheAge})`;
|
||||
@ -111,20 +111,17 @@ export const ClassesProvider = ({ children }) => {
|
||||
};
|
||||
|
||||
const updatePlannings = (formData, existingPlannings) => {
|
||||
return formData.niveaux.map(niveau => {
|
||||
return formData.levels.map(niveau => {
|
||||
let existingPlanning = existingPlannings.find(planning => planning.niveau === niveau);
|
||||
|
||||
const emploiDuTemps = formData.jours_ouverture.reduce((acc, dayId) => {
|
||||
const emploiDuTemps = formData.opening_days.reduce((acc, dayId) => {
|
||||
const dayName = selectedDays[dayId];
|
||||
console.log('dayId:', dayId, 'dayName:', dayName); // Ajout de log pour vérifier les correspondances
|
||||
if (dayName) {
|
||||
acc[dayName] = existingPlanning?.emploiDuTemps?.[dayName] || [];
|
||||
}
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
console.log('Emploi du Temps initialisé :', emploiDuTemps);
|
||||
|
||||
let updatedPlanning;
|
||||
if (formData.type === 1) {
|
||||
updatedPlanning = {
|
||||
@ -170,8 +167,6 @@ export const ClassesProvider = ({ children }) => {
|
||||
};
|
||||
}
|
||||
|
||||
console.log('Updated Planning:', updatedPlanning);
|
||||
|
||||
// Fusionner les plannings existants avec les nouvelles données
|
||||
return existingPlanning
|
||||
? { ...existingPlanning, ...updatedPlanning }
|
||||
@ -179,10 +174,10 @@ export const ClassesProvider = ({ children }) => {
|
||||
});
|
||||
};
|
||||
|
||||
const groupSpecialitiesBySubject = (enseignants) => {
|
||||
const groupSpecialitiesBySubject = (teachers) => {
|
||||
const groupedSpecialities = {};
|
||||
|
||||
enseignants.forEach(teacher => {
|
||||
teachers.forEach(teacher => {
|
||||
teacher.specialites.forEach(specialite => {
|
||||
if (!groupedSpecialities[specialite.id]) {
|
||||
groupedSpecialities[specialite.id] = {
|
||||
|
||||
Reference in New Issue
Block a user