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;