'use client';

import { DateContext } from '@/context/date';
import { Calendar } from '@repo/ui/components/ui/calendar';
import dayjs from 'dayjs';
import { use } from 'react';

export function ScheduleCalendar() {
  const { selectedDate, setSelectedDate } = use(DateContext);

  return (
    <Calendar
      className="bg-background"
      disabled={(date) => {
        return dayjs().isAfter(dayjs(date), 'day');
      }}
      mode="single"
      onSelect={(date) => {
        if (date) setSelectedDate(date);
      }}
      selected={selectedDate}
    />
  );
}
