import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' import { Pencil, Trash2 } from 'lucide-react' import type { ScheduleSlot, LessonType } from '@/types/lesson' const DAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'] interface Props { slots: ScheduleSlot[] lessonTypes: LessonType[] onEdit: (slot: ScheduleSlot) => void onDelete: (slot: ScheduleSlot) => void } function formatTime(t: string) { const [h, m] = t.split(':').map(Number) const ampm = h >= 12 ? 'PM' : 'AM' const hour = h % 12 || 12 return `${hour}:${String(m).padStart(2, '0')} ${ampm}` } export function WeeklySlotGrid({ slots, lessonTypes, onEdit, onDelete }: Props) { const ltMap = new Map(lessonTypes.map((lt) => [lt.id, lt])) const slotsByDay = DAYS.map((_, day) => slots.filter((s) => s.dayOfWeek === day).sort((a, b) => a.startTime.localeCompare(b.startTime)), ) const hasAny = slots.length > 0 return (
{DAYS.map((day, idx) => (
{day}
{slotsByDay[idx].map((slot) => { const lt = ltMap.get(slot.lessonTypeId) return (
{formatTime(slot.startTime)}
{lt?.name ?? 'Unknown'}
{slot.room &&
{slot.room}
} {lt && ( {lt.lessonFormat} )}
) })}
))} {!hasAny && (
No schedule slots yet — add one to get started.
)}
) }