import moment from 'moment' import type { CalendarEvent } from '../types' interface TimeSlotModalProps { selectedDate: Date newTimeSlot: { startTime: string endTime: string } existingEvents: CalendarEvent[] onTimeSlotChange: (timeSlot: { startTime: string; endTime: string }) => void onAdd: () => void onCancel: () => void isAdding?: boolean validationError?: string | null } export function TimeSlotModal({ selectedDate, newTimeSlot, existingEvents, onTimeSlotChange, onAdd, onCancel, isAdding = false, validationError = null }: TimeSlotModalProps) { const getEventsForDate = (date: Date) => { return existingEvents.filter(event => { const eventDate = new Date(event.start) return eventDate.toDateString() === date.toDateString() }) } // Validate time slot const isValid = () => { if (!newTimeSlot.startTime || !newTimeSlot.endTime) { return false } const [startHour, startMinute] = newTimeSlot.startTime.split(':').map(Number) const [endHour, endMinute] = newTimeSlot.endTime.split(':').map(Number) const startMinutes = startHour * 60 + startMinute const endMinutes = endHour * 60 + endMinute return startMinutes < endMinutes } return (
{validationError || 'End time must be after start time'}
)}