mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
feat: Ajout de l'emploi du temps sur la page parent
This commit is contained in:
@ -381,16 +381,20 @@ class RegistrationFormSerializer(serializers.ModelSerializer):
|
|||||||
|
|
||||||
class StudentByParentSerializer(serializers.ModelSerializer):
|
class StudentByParentSerializer(serializers.ModelSerializer):
|
||||||
id = serializers.IntegerField(required=False)
|
id = serializers.IntegerField(required=False)
|
||||||
|
associated_class_name = serializers.SerializerMethodField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Student
|
model = Student
|
||||||
fields = ['id', 'last_name', 'first_name', 'level', 'photo']
|
fields = ['id', 'last_name', 'first_name', 'level', 'photo', 'associated_class_name']
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super(StudentByParentSerializer, self).__init__(*args, **kwargs)
|
super(StudentByParentSerializer, self).__init__(*args, **kwargs)
|
||||||
for field in self.fields:
|
for field in self.fields:
|
||||||
self.fields[field].required = False
|
self.fields[field].required = False
|
||||||
|
|
||||||
|
def get_associated_class_name(self, obj):
|
||||||
|
return obj.associated_class.atmosphere_name if obj.associated_class else None
|
||||||
|
|
||||||
class RegistrationFormByParentSerializer(serializers.ModelSerializer):
|
class RegistrationFormByParentSerializer(serializers.ModelSerializer):
|
||||||
student = StudentByParentSerializer(many=False, required=True)
|
student = StudentByParentSerializer(many=False, required=True)
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
import Table from '@/components/Table';
|
import Table from '@/components/Table';
|
||||||
import { Edit3, Users, Download, Eye, Upload } from 'lucide-react';
|
import { Edit3, Users, Download, Eye, Upload, CalendarDays } from 'lucide-react';
|
||||||
import StatusLabel from '@/components/StatusLabel';
|
import StatusLabel from '@/components/StatusLabel';
|
||||||
import FileUpload from '@/components/FileUpload';
|
import FileUpload from '@/components/FileUpload';
|
||||||
import { FE_PARENTS_EDIT_SUBSCRIPTION_URL } from '@/utils/Url';
|
import { FE_PARENTS_EDIT_SUBSCRIPTION_URL } from '@/utils/Url';
|
||||||
@ -15,6 +15,12 @@ import { BASE_URL } from '@/utils/Url';
|
|||||||
import { useEstablishment } from '@/context/EstablishmentContext';
|
import { useEstablishment } from '@/context/EstablishmentContext';
|
||||||
import { useCsrfToken } from '@/context/CsrfContext';
|
import { useCsrfToken } from '@/context/CsrfContext';
|
||||||
import { useClasses } from '@/context/ClassesContext';
|
import { useClasses } from '@/context/ClassesContext';
|
||||||
|
import {
|
||||||
|
PlanningProvider,
|
||||||
|
PlanningModes
|
||||||
|
} from '@/context/PlanningContext';
|
||||||
|
import SectionHeader from '@/components/SectionHeader';
|
||||||
|
import ParentPlanningSection from '@/components/ParentPlanningSection';
|
||||||
|
|
||||||
export default function ParentHomePage() {
|
export default function ParentHomePage() {
|
||||||
const [children, setChildren] = useState([]);
|
const [children, setChildren] = useState([]);
|
||||||
@ -22,6 +28,8 @@ export default function ParentHomePage() {
|
|||||||
const [uploadingStudentId, setUploadingStudentId] = useState(null); // ID de l'étudiant pour l'upload
|
const [uploadingStudentId, setUploadingStudentId] = useState(null); // ID de l'étudiant pour l'upload
|
||||||
const [uploadedFile, setUploadedFile] = useState(null); // Fichier uploadé
|
const [uploadedFile, setUploadedFile] = useState(null); // Fichier uploadé
|
||||||
const [uploadState, setUploadState] = useState('off'); // État "on" ou "off" pour l'affichage du composant
|
const [uploadState, setUploadState] = useState('off'); // État "on" ou "off" pour l'affichage du composant
|
||||||
|
const [showPlanning, setShowPlanning] = useState(false);
|
||||||
|
const [planningClassName, setPlanningClassName] = useState(null);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const csrfToken = useCsrfToken();
|
const csrfToken = useCsrfToken();
|
||||||
const [reloadFetch, setReloadFetch] = useState(false);
|
const [reloadFetch, setReloadFetch] = useState(false);
|
||||||
@ -97,6 +105,11 @@ export default function ParentHomePage() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const showClassPlanning = (student) => {
|
||||||
|
setPlanningClassName(`${student.associated_class_name} - ${getNiveauLabel(student.level)}`);
|
||||||
|
setShowPlanning(true);
|
||||||
|
};
|
||||||
|
|
||||||
const childrenColumns = [
|
const childrenColumns = [
|
||||||
{
|
{
|
||||||
name: 'photo',
|
name: 'photo',
|
||||||
@ -127,6 +140,12 @@ export default function ParentHomePage() {
|
|||||||
},
|
},
|
||||||
{ name: 'Nom', transform: (row) => `${row.student.last_name}` },
|
{ name: 'Nom', transform: (row) => `${row.student.last_name}` },
|
||||||
{ name: 'Prénom', transform: (row) => `${row.student.first_name}` },
|
{ name: 'Prénom', transform: (row) => `${row.student.first_name}` },
|
||||||
|
{
|
||||||
|
name: 'Classe',
|
||||||
|
transform: (row) => (
|
||||||
|
<div className="text-center">{(row.student.associated_class_name)}</div>
|
||||||
|
),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'Niveau',
|
name: 'Niveau',
|
||||||
transform: (row) => (
|
transform: (row) => (
|
||||||
@ -192,7 +211,6 @@ export default function ParentHomePage() {
|
|||||||
>
|
>
|
||||||
<Download className="h-5 w-5" />
|
<Download className="h-5 w-5" />
|
||||||
</a>
|
</a>
|
||||||
{/* Nouvelle action Upload */}
|
|
||||||
<button
|
<button
|
||||||
className={`flex items-center justify-center w-8 h-8 rounded-full ${
|
className={`flex items-center justify-center w-8 h-8 rounded-full ${
|
||||||
uploadingStudentId === row.student.id && uploadState === 'on'
|
uploadingStudentId === row.student.id && uploadState === 'on'
|
||||||
@ -201,7 +219,7 @@ export default function ParentHomePage() {
|
|||||||
}`}
|
}`}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
toggleUpload(row.student.id); // Activer ou désactiver l'upload pour cet étudiant
|
toggleUpload(row.student.id);
|
||||||
}}
|
}}
|
||||||
aria-label="Uploader un fichier"
|
aria-label="Uploader un fichier"
|
||||||
>
|
>
|
||||||
@ -211,16 +229,28 @@ export default function ParentHomePage() {
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
{row.status === 5 && (
|
{row.status === 5 && (
|
||||||
<button
|
<>
|
||||||
className="text-purple-500 hover:text-purple-700"
|
<button
|
||||||
onClick={(e) => {
|
className="text-purple-500 hover:text-purple-700"
|
||||||
e.stopPropagation();
|
onClick={(e) => {
|
||||||
handleView(row.student.id);
|
e.stopPropagation();
|
||||||
}}
|
handleView(row.student.id);
|
||||||
aria-label="Visualiser le dossier"
|
}}
|
||||||
>
|
aria-label="Visualiser le dossier"
|
||||||
<Eye className="h-5 w-5" />
|
>
|
||||||
</button>
|
<Eye className="h-5 w-5" />
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="text-emerald-500 hover:text-emerald-700 ml-1"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
showClassPlanning(row.student);
|
||||||
|
}}
|
||||||
|
aria-label="Voir le planning de la classe"
|
||||||
|
>
|
||||||
|
<CalendarDays className="h-5 w-5" />
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
),
|
),
|
||||||
@ -228,40 +258,66 @@ export default function ParentHomePage() {
|
|||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="px-2 py-4 md:px-4 max-w-full">
|
<div className="w-full h-full">
|
||||||
<div>
|
{showPlanning && planningClassName ? (
|
||||||
<h2 className="text-xl font-semibold mb-3 px-1 flex items-center gap-2">
|
// Affichage grand format mais respectant la sidebar
|
||||||
<Users className="h-6 w-6 text-emerald-600" />
|
<>
|
||||||
Enfants
|
<div className="p-4 flex items-center border-b">
|
||||||
</h2>
|
|
||||||
<div className="overflow-x-auto">
|
|
||||||
<Table
|
|
||||||
data={children}
|
|
||||||
columns={childrenColumns}
|
|
||||||
defaultTheme="bg-gray-50"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{/* Composant FileUpload et bouton Valider en dessous du tableau */}
|
|
||||||
{uploadState === 'on' && uploadingStudentId && (
|
|
||||||
<div className="mt-4">
|
|
||||||
<FileUpload
|
|
||||||
selectionMessage="Sélectionnez un fichier à uploader"
|
|
||||||
onFileSelect={handleFileUpload}
|
|
||||||
/>
|
|
||||||
<button
|
<button
|
||||||
className={`mt-4 px-6 py-2 rounded-md ${
|
className="text-emerald-600 hover:text-emerald-800 font-semibold flex items-center"
|
||||||
uploadedFile
|
onClick={() => setShowPlanning(false)}
|
||||||
? 'bg-emerald-500 text-white hover:bg-emerald-600'
|
|
||||||
: 'bg-gray-300 text-gray-700 cursor-not-allowed'
|
|
||||||
}`}
|
|
||||||
onClick={handleSubmit}
|
|
||||||
disabled={!uploadedFile}
|
|
||||||
>
|
>
|
||||||
Valider
|
← Retour
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
)}
|
<div className="flex-1 flex overflow-hidden">
|
||||||
</div>
|
<PlanningProvider
|
||||||
|
establishmentId={selectedEstablishmentId}
|
||||||
|
modeSet={PlanningModes.CLASS_SCHEDULE}
|
||||||
|
readOnly={true}
|
||||||
|
>
|
||||||
|
<ParentPlanningSection
|
||||||
|
planningClassName={planningClassName}
|
||||||
|
/>
|
||||||
|
</PlanningProvider>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
// Affichage classique avec le tableau des enfants
|
||||||
|
<div>
|
||||||
|
<SectionHeader
|
||||||
|
icon={Users}
|
||||||
|
title="Vos enfants"
|
||||||
|
description="Suivez le parcours de vos enfants"
|
||||||
|
/>
|
||||||
|
<div className="overflow-x-auto">
|
||||||
|
<Table
|
||||||
|
data={children}
|
||||||
|
columns={childrenColumns}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{/* Composant FileUpload et bouton Valider en dessous du tableau */}
|
||||||
|
{uploadState === 'on' && uploadingStudentId && (
|
||||||
|
<div className="mt-4">
|
||||||
|
<FileUpload
|
||||||
|
selectionMessage="Sélectionnez un fichier à uploader"
|
||||||
|
onFileSelect={handleFileUpload}
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
className={`mt-4 px-6 py-2 rounded-md ${
|
||||||
|
uploadedFile
|
||||||
|
? 'bg-emerald-500 text-white hover:bg-emerald-600'
|
||||||
|
: 'bg-gray-300 text-gray-700 cursor-not-allowed'
|
||||||
|
}`}
|
||||||
|
onClick={handleSubmit}
|
||||||
|
disabled={!uploadedFile}
|
||||||
|
>
|
||||||
|
Valider
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { usePlanning } from '@/context/PlanningContext';
|
import { usePlanning, PlanningModes } from '@/context/PlanningContext';
|
||||||
import WeekView from '@/components/Calendar/WeekView';
|
import WeekView from '@/components/Calendar/WeekView';
|
||||||
import MonthView from '@/components/Calendar/MonthView';
|
import MonthView from '@/components/Calendar/MonthView';
|
||||||
import YearView from '@/components/Calendar/YearView';
|
import YearView from '@/components/Calendar/YearView';
|
||||||
@ -22,14 +22,16 @@ import { fr } from 'date-fns/locale';
|
|||||||
import { AnimatePresence, motion } from 'framer-motion'; // Ajouter cet import
|
import { AnimatePresence, motion } from 'framer-motion'; // Ajouter cet import
|
||||||
import logger from '@/utils/logger';
|
import logger from '@/utils/logger';
|
||||||
|
|
||||||
const Calendar = ({ modeSet, onDateClick, onEventClick, schoolClassMode=false }) => {
|
const Calendar = ({ modeSet, onDateClick, onEventClick, planningClassName='' }) => {
|
||||||
const {
|
const {
|
||||||
currentDate,
|
currentDate,
|
||||||
setCurrentDate,
|
setCurrentDate,
|
||||||
viewType,
|
viewType,
|
||||||
setViewType,
|
setViewType,
|
||||||
events,
|
events,
|
||||||
hiddenSchedules
|
hiddenSchedules,
|
||||||
|
planningMode,
|
||||||
|
parentView
|
||||||
} = usePlanning();
|
} = usePlanning();
|
||||||
const [visibleEvents, setVisibleEvents] = useState([]);
|
const [visibleEvents, setVisibleEvents] = useState([]);
|
||||||
const [showDatePicker, setShowDatePicker] = useState(false);
|
const [showDatePicker, setShowDatePicker] = useState(false);
|
||||||
@ -90,9 +92,9 @@ const Calendar = ({ modeSet, onDateClick, onEventClick, schoolClassMode=false })
|
|||||||
return (
|
return (
|
||||||
<div className="flex-1 flex flex-col">
|
<div className="flex-1 flex flex-col">
|
||||||
<div className="flex items-center justify-between p-4 bg-white sticky top-0 z-30 border-b shadow-sm h-[64px]">
|
<div className="flex items-center justify-between p-4 bg-white sticky top-0 z-30 border-b shadow-sm h-[64px]">
|
||||||
{!schoolClassMode && (
|
{/* Navigation à gauche */}
|
||||||
|
{planningMode === PlanningModes.PLANNING && (
|
||||||
<div className="flex items-center gap-4">
|
<div className="flex items-center gap-4">
|
||||||
{/* Navigation à gauche */}
|
|
||||||
<button
|
<button
|
||||||
onClick={() => setCurrentDate(new Date())}
|
onClick={() => setCurrentDate(new Date())}
|
||||||
className="px-3 py-1.5 text-sm font-medium text-gray-700 hover:text-gray-900 bg-gray-100 hover:bg-gray-200 rounded-md transition-colors"
|
className="px-3 py-1.5 text-sm font-medium text-gray-700 hover:text-gray-900 bg-gray-100 hover:bg-gray-200 rounded-md transition-colors"
|
||||||
@ -105,8 +107,6 @@ const Calendar = ({ modeSet, onDateClick, onEventClick, schoolClassMode=false })
|
|||||||
>
|
>
|
||||||
<ChevronLeft className="w-5 h-5" />
|
<ChevronLeft className="w-5 h-5" />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{/* Menu déroulant pour le mois/année */}
|
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<button
|
<button
|
||||||
onClick={() => setShowDatePicker(!showDatePicker)}
|
onClick={() => setShowDatePicker(!showDatePicker)}
|
||||||
@ -121,8 +121,6 @@ const Calendar = ({ modeSet, onDateClick, onEventClick, schoolClassMode=false })
|
|||||||
</h2>
|
</h2>
|
||||||
<ChevronDown className="w-4 h-4" />
|
<ChevronDown className="w-4 h-4" />
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{/* Menu de sélection du mois/année */}
|
|
||||||
{showDatePicker && (
|
{showDatePicker && (
|
||||||
<div className="absolute top-full left-0 mt-1 bg-white border border-gray-200 rounded-lg shadow-lg z-50 w-64">
|
<div className="absolute top-full left-0 mt-1 bg-white border border-gray-200 rounded-lg shadow-lg z-50 w-64">
|
||||||
{viewType !== 'year' && (
|
{viewType !== 'year' && (
|
||||||
@ -156,7 +154,6 @@ const Calendar = ({ modeSet, onDateClick, onEventClick, schoolClassMode=false })
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button
|
<button
|
||||||
onClick={() => navigateDate('next')}
|
onClick={() => navigateDate('next')}
|
||||||
className="p-2 hover:bg-gray-100 rounded-full"
|
className="p-2 hover:bg-gray-100 rounded-full"
|
||||||
@ -166,27 +163,37 @@ const Calendar = ({ modeSet, onDateClick, onEventClick, schoolClassMode=false })
|
|||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* Numéro de semaine au centre */}
|
{/* Centre : numéro de semaine ou classe/niveau */}
|
||||||
{viewType === 'week' && (
|
<div className="flex-1 flex justify-center">
|
||||||
<div className="flex items-center gap-1 text-sm font-medium text-gray-600">
|
{((planningMode === PlanningModes.PLANNING || planningMode === PlanningModes.CLASS_SCHEDULE) && viewType === 'week' && !parentView) && (
|
||||||
<span>Semaine</span>
|
<div className="flex items-center gap-1 text-sm font-medium text-gray-600">
|
||||||
<span className="px-2 py-1 bg-gray-100 rounded-md">
|
<span>Semaine</span>
|
||||||
{getWeek(currentDate, { weekStartsOn: 1 })}
|
<span className="px-2 py-1 bg-gray-100 rounded-md">
|
||||||
|
{getWeek(currentDate, { weekStartsOn: 1 })}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{parentView && (
|
||||||
|
<span className="px-2 py-1 bg-gray-100 rounded-md text-base font-semibold">
|
||||||
|
{/* À adapter selon les props disponibles */}
|
||||||
|
{planningClassName}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
)}
|
||||||
)}
|
</div>
|
||||||
|
|
||||||
{/* Contrôles à droite */}
|
{/* Contrôles à droite */}
|
||||||
<div className="flex items-center gap-4">
|
<div className="flex items-center gap-4">
|
||||||
{!schoolClassMode && (
|
{planningMode === PlanningModes.PLANNING && (
|
||||||
<ToggleView viewType={viewType} setViewType={setViewType} />
|
<ToggleView viewType={viewType} setViewType={setViewType} />
|
||||||
)}
|
)}
|
||||||
|
{(planningMode === PlanningModes.PLANNING || (planningMode === PlanningModes.CLASS_SCHEDULE && !parentView)) && (
|
||||||
<button
|
<button
|
||||||
onClick={onDateClick}
|
onClick={onDateClick}
|
||||||
className="w-10 h-10 flex items-center justify-center bg-emerald-600 text-white rounded-full hover:bg-emerald-700 shadow-md transition-colors"
|
className="w-10 h-10 flex items-center justify-center bg-emerald-600 text-white rounded-full hover:bg-emerald-700 shadow-md transition-colors"
|
||||||
>
|
>
|
||||||
<Plus className="w-5 h-5" />
|
<Plus className="w-5 h-5" />
|
||||||
</button>
|
</button>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@ -1,12 +1,13 @@
|
|||||||
import React, { useEffect, useState, useRef } from 'react';
|
import React, { useEffect, useState, useRef } from 'react';
|
||||||
import { usePlanning } from '@/context/PlanningContext';
|
import { usePlanning, PlanningModes } from '@/context/PlanningContext';
|
||||||
import { format, startOfWeek, addDays, isSameDay } from 'date-fns';
|
import { format, startOfWeek, addDays, isSameDay } from 'date-fns';
|
||||||
import { fr } from 'date-fns/locale';
|
import { fr } from 'date-fns/locale';
|
||||||
import { getWeekEvents } from '@/utils/events';
|
import { getWeekEvents } from '@/utils/events';
|
||||||
import { isToday } from 'date-fns';
|
import { isToday } from 'date-fns';
|
||||||
|
|
||||||
|
|
||||||
const WeekView = ({ onDateClick, onEventClick, events }) => {
|
const WeekView = ({ onDateClick, onEventClick, events }) => {
|
||||||
const { currentDate } = usePlanning();
|
const { currentDate, planningMode, parentView } = usePlanning();
|
||||||
const [currentTime, setCurrentTime] = useState(new Date());
|
const [currentTime, setCurrentTime] = useState(new Date());
|
||||||
const scrollContainerRef = useRef(null); // Ajouter cette référence
|
const scrollContainerRef = useRef(null); // Ajouter cette référence
|
||||||
|
|
||||||
@ -106,10 +107,14 @@ const WeekView = ({ onDateClick, onEventClick, events }) => {
|
|||||||
key={event.id}
|
key={event.id}
|
||||||
className="rounded-sm overflow-hidden cursor-pointer hover:shadow-lg"
|
className="rounded-sm overflow-hidden cursor-pointer hover:shadow-lg"
|
||||||
style={eventStyle}
|
style={eventStyle}
|
||||||
onClick={(e) => {
|
onClick={
|
||||||
e.stopPropagation();
|
parentView
|
||||||
onEventClick(event);
|
? undefined
|
||||||
}}
|
: (e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
onEventClick(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<div className="p-1">
|
<div className="p-1">
|
||||||
<div
|
<div
|
||||||
@ -198,11 +203,15 @@ const WeekView = ({ onDateClick, onEventClick, events }) => {
|
|||||||
className={`h-20 relative border-b border-gray-100
|
className={`h-20 relative border-b border-gray-100
|
||||||
${isWeekend(day) ? 'bg-gray-50' : 'bg-white'}
|
${isWeekend(day) ? 'bg-gray-50' : 'bg-white'}
|
||||||
${isToday(day) ? 'bg-emerald-100/50 border-x border-emerald-600' : ''}`}
|
${isToday(day) ? 'bg-emerald-100/50 border-x border-emerald-600' : ''}`}
|
||||||
onClick={() => {
|
onClick={
|
||||||
const date = new Date(day);
|
parentView
|
||||||
date.setHours(hour);
|
? undefined
|
||||||
onDateClick(date);
|
: () => {
|
||||||
}}
|
const date = new Date(day);
|
||||||
|
date.setHours(hour);
|
||||||
|
onDateClick(date);
|
||||||
|
}
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<div className="grid gap-1">
|
<div className="grid gap-1">
|
||||||
{dayEvents
|
{dayEvents
|
||||||
|
|||||||
30
Front-End/src/components/ParentPlanningSection.js
Normal file
30
Front-End/src/components/ParentPlanningSection.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
import React, { useEffect } from 'react';
|
||||||
|
import Calendar from '@/components/Calendar/Calendar';
|
||||||
|
import { usePlanning } from '@/context/PlanningContext';
|
||||||
|
|
||||||
|
const ParentPlanningSection = ({ planningClassName }) => {
|
||||||
|
const { setHiddenSchedules, schedules } = usePlanning();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (schedules && schedules.length > 0 && planningClassName) {
|
||||||
|
const visibleSchedule = schedules.find(s => s.name === planningClassName);
|
||||||
|
const hidden = schedules
|
||||||
|
.filter(s => s.name !== planningClassName)
|
||||||
|
.map(s => s.id);
|
||||||
|
setHiddenSchedules(hidden);
|
||||||
|
|
||||||
|
// Optionnel : si aucun planning ne correspond, tout masquer
|
||||||
|
if (!visibleSchedule) {
|
||||||
|
setHiddenSchedules(schedules.map(s => s.id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [schedules, planningClassName, setHiddenSchedules]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex w-full h-full overflow-hidden">
|
||||||
|
<Calendar planningClassName={planningClassName} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default ParentPlanningSection;
|
||||||
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
import logger from '@/utils/logger';
|
|
||||||
import { RecurrenceType } from '@/context/PlanningContext';
|
import { RecurrenceType } from '@/context/PlanningContext';
|
||||||
import Calendar from '@/components/Calendar/Calendar';
|
import Calendar from '@/components/Calendar/Calendar';
|
||||||
import ScheduleEventModal from '@/components/Structure/Planning/ScheduleEventModal';
|
import ScheduleEventModal from '@/components/Structure/Planning/ScheduleEventModal';
|
||||||
@ -60,7 +59,6 @@ export default function ScheduleManagement({
|
|||||||
setEventData(event);
|
setEventData(event);
|
||||||
setIsModalOpen(true);
|
setIsModalOpen(true);
|
||||||
}}
|
}}
|
||||||
schoolClassMode={true}
|
|
||||||
/>
|
/>
|
||||||
<ScheduleEventModal
|
<ScheduleEventModal
|
||||||
isOpen={isModalOpen}
|
isOpen={isModalOpen}
|
||||||
|
|||||||
@ -33,12 +33,13 @@ export const RecurrenceType = Object.freeze({
|
|||||||
|
|
||||||
export const PlanningModes = Object.freeze({
|
export const PlanningModes = Object.freeze({
|
||||||
CLASS_SCHEDULE: 'classSchedule',
|
CLASS_SCHEDULE: 'classSchedule',
|
||||||
PLANNING: 'planning',
|
PLANNING: 'planning'
|
||||||
});
|
});
|
||||||
|
|
||||||
export function PlanningProvider({
|
export function PlanningProvider({
|
||||||
children,
|
children,
|
||||||
modeSet = PlanningModes.PLANNING,
|
modeSet = PlanningModes.PLANNING,
|
||||||
|
readOnly = false
|
||||||
}) {
|
}) {
|
||||||
const [events, setEvents] = useState([]);
|
const [events, setEvents] = useState([]);
|
||||||
const [schedules, setSchedules] = useState([]);
|
const [schedules, setSchedules] = useState([]);
|
||||||
@ -46,6 +47,7 @@ export function PlanningProvider({
|
|||||||
const [planningMode, setPlanningMode] = useState(modeSet);
|
const [planningMode, setPlanningMode] = useState(modeSet);
|
||||||
const [currentDate, setCurrentDate] = useState(new Date());
|
const [currentDate, setCurrentDate] = useState(new Date());
|
||||||
const [viewType, setViewType] = useState('week'); // Changer 'month' en 'week'
|
const [viewType, setViewType] = useState('week'); // Changer 'month' en 'week'
|
||||||
|
const [parentView, setParentView] = useState(readOnly);
|
||||||
const [hiddenSchedules, setHiddenSchedules] = useState([]);
|
const [hiddenSchedules, setHiddenSchedules] = useState([]);
|
||||||
const { selectedEstablishmentId } = useEstablishment();
|
const { selectedEstablishmentId } = useEstablishment();
|
||||||
|
|
||||||
@ -136,10 +138,12 @@ export function PlanningProvider({
|
|||||||
viewType,
|
viewType,
|
||||||
setViewType,
|
setViewType,
|
||||||
hiddenSchedules,
|
hiddenSchedules,
|
||||||
|
setHiddenSchedules,
|
||||||
toggleScheduleVisibility,
|
toggleScheduleVisibility,
|
||||||
planningMode,
|
planningMode,
|
||||||
reloadEvents,
|
reloadEvents,
|
||||||
reloadPlanning,
|
reloadPlanning,
|
||||||
|
parentView
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user