'use client'; import { CalendarDays } from 'lucide-react'; import { purposeStyle } from '@/components/ui/appointments/appointmentPurposeStyles'; import { Card } from '@/components/ui/common/Card'; import { ScheduleDayPicker } from '@/components/ui/common/ScheduleDayPicker'; import { startOfLocalDay } from '@/lib/appointmentTime'; import type { TreatmentAppointment } from '@/types/treatment'; interface AppointmentsStripProps { stripHidden: boolean; onToggleStripHidden: () => void; selectedDay: Date; onSelectDay: (day: Date) => void; /** Same lower bound as Appointments schedule (cannot pick days before this). */ minScheduleDate: Date; appointments: TreatmentAppointment[]; selectedAppointmentId: string | null; onSelectAppointment: (id: string) => void; loading?: boolean; } export function AppointmentsStrip({ stripHidden, onToggleStripHidden, selectedDay, onSelectDay, minScheduleDate, appointments, selectedAppointmentId, onSelectAppointment, loading = false, }: AppointmentsStripProps) { if (stripHidden) { return (

Appointments are hidden.

); } return (

My appointments

onSelectDay(startOfLocalDay(d))} /> {loading && (

Loading appointments…

)}
{appointments.length === 0 && (

No appointments assigned to you on this day.

)} {appointments.map((a) => { const sel = a.id === selectedAppointmentId; const start = new Date(a.startAt); const end = new Date(a.endAt); const timeLabel = `${start.toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit', })} – ${end.toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit', })}`; const palette = purposeStyle(a.purpose); return ( onSelectAppointment(a.id)} padding="none" className={` text-left rounded-[var(--radius-sm)] px-3 py-2 min-w-[200px] max-w-[280px] transition-shadow min-h-[52px] focus:outline-none focus-visible:ring-2 focus-visible:ring-primary/45 ${palette} ${sel ? 'ring-2 ring-primary ring-offset-2 ring-offset-background-secondary shadow-[inset_0_1px_0_rgba(255,255,255,0.06)]' : 'hover:brightness-110'} `} >

{timeLabel}

{a.patientFirstName} {a.patientLastName}

{a.purpose}

); })}
); }