import React from 'react'; import { usePlanning } from '@/context/PlanningContext'; import { format, startOfWeek, endOfWeek, eachDayOfInterval, startOfMonth, endOfMonth, isSameMonth, isToday, } from 'date-fns'; import { fr } from 'date-fns/locale'; import { getEventsForDate } from '@/utils/events'; const MonthView = ({ onDateClick, onEventClick }) => { const { currentDate, setViewType, setCurrentDate, events } = usePlanning(); // Obtenir tous les jours du mois actuel const monthStart = startOfMonth(currentDate); const monthEnd = endOfMonth(currentDate); const startDate = startOfWeek(monthStart, { locale: fr, weekStartsOn: 1 }); const endDate = endOfWeek(monthEnd, { locale: fr, weekStartsOn: 1 }); const days = eachDayOfInterval({ start: startDate, end: endDate }); const handleDayClick = (day) => { setCurrentDate(day); // Met à jour la date courante setViewType('week'); // Change la vue en mode semaine }; const renderDay = (day) => { const isCurrentMonth = isSameMonth(day, currentDate); const dayEvents = getEventsForDate(day, events); const isCurrentDay = isToday(day); return (