'use client';
import { createContext, useMemo, useState } from 'react';

type ContextType = {
  selectedDate: Date;
  setSelectedDate: (date: Date) => void;
};

export const ScheduleContext = createContext<ContextType>({} as ContextType);

export function ScheduleContextProvider({ children }: { readonly children: React.ReactNode }) {
  const [selectedDate, setSelectedDate] = useState(new Date());

  const value = useMemo(() => ({ selectedDate, setSelectedDate }), [selectedDate]);

  return <ScheduleContext value={value}>{children}</ScheduleContext>;
}
