mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 16:03:21 +00:00
refactor: refactoring du FRONT page subscribe
This commit is contained in:
@ -6,7 +6,7 @@ import { DndProvider } from 'react-dnd';
|
||||
import { AnimatePresence, motion } from 'framer-motion';
|
||||
import PlanningClassView from '@/components/Structure/Planning/PlanningClassView';
|
||||
import SpecialitiesList from '@/components/Structure/Planning/SpecialitiesList';
|
||||
import { BK_GESTIONENSEIGNANTS_PLANNING_URL } from '@/utils/Url';
|
||||
import { BE_SCHOOL_PLANNING_URL } from '@/utils/Url';
|
||||
import { useClasses } from '@/context/ClassesContext';
|
||||
import { ClasseFormProvider } from '@/context/ClasseFormContext';
|
||||
import TabsStructure from '@/components/Structure/Configuration/TabsStructure';
|
||||
@ -60,14 +60,14 @@ const ScheduleManagement = ({ handleUpdatePlanning, classes }) => {
|
||||
const onDrop = (item, hour, day) => {
|
||||
const { id, name, color, teachers } = item;
|
||||
const newSchedule = { ...schedule, emploiDuTemps: schedule.emploiDuTemps || {} };
|
||||
|
||||
|
||||
if (!newSchedule.emploiDuTemps[day]) {
|
||||
newSchedule.emploiDuTemps[day] = [];
|
||||
}
|
||||
const courseTime = `${hour.toString().padStart(2, '0')}:00`;
|
||||
|
||||
|
||||
const existingCourseIndex = newSchedule.emploiDuTemps[day].findIndex(course => course.heure === courseTime);
|
||||
|
||||
|
||||
const newCourse = {
|
||||
duree: '1',
|
||||
heure: courseTime,
|
||||
@ -75,21 +75,21 @@ const ScheduleManagement = ({ handleUpdatePlanning, classes }) => {
|
||||
teachers: teachers,
|
||||
color: color,
|
||||
};
|
||||
|
||||
|
||||
if (existingCourseIndex !== -1) {
|
||||
newSchedule.emploiDuTemps[day][existingCourseIndex] = newCourse;
|
||||
} else {
|
||||
newSchedule.emploiDuTemps[day].push(newCourse);
|
||||
}
|
||||
|
||||
|
||||
// Mettre à jour scheduleRef
|
||||
setSchedule(newSchedule)
|
||||
|
||||
|
||||
// Utiliser `handleUpdatePlanning` pour mettre à jour le planning du niveau de la classe
|
||||
const planningId = selectedClass.plannings_read.find(planning => planning.niveau === selectedLevel)?.planning.id;
|
||||
if (planningId) {
|
||||
console.log('newSchedule : ', newSchedule)
|
||||
handleUpdatePlanning(BK_GESTIONENSEIGNANTS_PLANNING_URL, planningId, newSchedule);
|
||||
handleUpdatePlanning(BE_SCHOOL_PLANNING_URL, planningId, newSchedule);
|
||||
}
|
||||
};
|
||||
|
||||
@ -110,7 +110,7 @@ const ScheduleManagement = ({ handleUpdatePlanning, classes }) => {
|
||||
<DndProvider backend={HTML5Backend}>
|
||||
<div className="p-4 bg-gray-100 border-b">
|
||||
<div className="grid grid-cols-3 gap-4">
|
||||
|
||||
|
||||
{/* Colonne Classes */}
|
||||
<div className="p-4 bg-gray-50 rounded-lg shadow-inner">
|
||||
<div className="flex justify-between items-center mb-4">
|
||||
@ -131,7 +131,7 @@ const ScheduleManagement = ({ handleUpdatePlanning, classes }) => {
|
||||
/>
|
||||
}
|
||||
</div>
|
||||
|
||||
|
||||
{/* Colonne Niveaux */}
|
||||
<div className="p-4 bg-gray-50 rounded-lg shadow-inner">
|
||||
<div className="flex justify-between items-center mb-4">
|
||||
@ -144,7 +144,7 @@ const ScheduleManagement = ({ handleUpdatePlanning, classes }) => {
|
||||
<TabsStructure activeTab={selectedLevel} setActiveTab={handleLevelSelect} tabs={niveauxLabels} />
|
||||
}
|
||||
</div>
|
||||
|
||||
|
||||
{/* Colonne Spécialités */}
|
||||
<div className="p-4 bg-gray-50 rounded-lg shadow-inner">
|
||||
<div className="flex justify-between items-center mb-4">
|
||||
@ -155,10 +155,10 @@ const ScheduleManagement = ({ handleUpdatePlanning, classes }) => {
|
||||
</div>
|
||||
<SpecialitiesList teachers={selectedClass ? selectedClass.enseignants : []} />
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="flex-1 p-4 overflow-y-auto">
|
||||
<AnimatePresence mode="wait">
|
||||
<motion.div
|
||||
@ -178,7 +178,7 @@ const ScheduleManagement = ({ handleUpdatePlanning, classes }) => {
|
||||
</DndProvider>
|
||||
</div>
|
||||
);
|
||||
|
||||
|
||||
};
|
||||
|
||||
export default ScheduleManagement;
|
||||
|
||||
@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
|
||||
import SelectChoice from '@/components/SelectChoice';
|
||||
import { useClasses } from '@/context/ClassesContext';
|
||||
import { useClasseForm } from '@/context/ClasseFormContext';
|
||||
import { BK_GESTIONENSEIGNANTS_PLANNING_URL } from '@/utils/Url';
|
||||
import { BE_SCHOOL_PLANNING_URL } from '@/utils/Url';
|
||||
import { BookOpen, Users } from 'lucide-react';
|
||||
|
||||
const SpecialityEventModal = ({ isOpen, onClose, selectedCell, existingEvent, handleUpdatePlanning, classe }) => {
|
||||
@ -56,17 +56,17 @@ const SpecialityEventModal = ({ isOpen, onClose, selectedCell, existingEvent, ha
|
||||
|
||||
const handleSubmit = (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
|
||||
if (!eventData.specialiteId) {
|
||||
alert('Veuillez sélectionner une spécialité');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!eventData.teacherId) {
|
||||
alert('Veuillez sélectionner un enseignant');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Transformer eventData pour correspondre au format du planning
|
||||
const selectedTeacherData = formData.enseignants.find(teacher => teacher.id === parseInt(eventData.teacherId, 10));
|
||||
const newCourse = {
|
||||
@ -114,14 +114,14 @@ const SpecialityEventModal = ({ isOpen, onClose, selectedCell, existingEvent, ha
|
||||
const planningId = updatedPlanning ? updatedPlanning.planning.id : null;
|
||||
console.log("id : ", planningId)
|
||||
if (planningId) {
|
||||
handleUpdatePlanning(BK_GESTIONENSEIGNANTS_PLANNING_URL, planningId, updatedPlanning.emploiDuTemps);
|
||||
handleUpdatePlanning(BE_SCHOOL_PLANNING_URL, planningId, updatedPlanning.emploiDuTemps);
|
||||
}
|
||||
|
||||
onClose();
|
||||
};
|
||||
|
||||
const filteredTeachers = selectedSpeciality
|
||||
? formData.enseignants.filter(teacher =>
|
||||
const filteredTeachers = selectedSpeciality
|
||||
? formData.enseignants.filter(teacher =>
|
||||
teacher.specialites_ids.includes(parseInt(selectedSpeciality, 10))
|
||||
)
|
||||
: formData.enseignants;
|
||||
|
||||
Reference in New Issue
Block a user