)}
);
}
// "2026-06-16" -> "Jun 16" (compact, for the date-range summary).
function shortDate(iso: string): string {
return new Date(`${iso}T00:00:00`).toLocaleDateString("en-US", {
month: "short",
day: "numeric",
});
}
// Appointments are rendered condensed: rather than one dense card per row (which
// floods the chat for a week's schedule), show a small summary + a few previews
// and send the clinician to the Appointments calendar for the full picture.
const APPT_PREVIEW = 3;
export function AppointmentListCard({
appointments,
}: {
appointments: Appointment[];
}) {
const { t } = useTranslation();
if (appointments.length === 0) {
return (
);
}
const dates = appointments.map((a) => a.date).filter(Boolean).sort();
const first = dates[0];
const last = dates[dates.length - 1];
const range = first
? first === last
? shortDate(first)
: `${shortDate(first)} – ${shortDate(last as string)}`
: "";
// Deep-link to the Appointments calendar, opened on the first appointment's
// month (the page reads `?calendar=1&date=`).
const href = first
? `/appointments?calendar=1&date=${first}`
: "/appointments?calendar=1";
const preview = appointments.slice(0, APPT_PREVIEW);
const remaining = appointments.length - preview.length;
return (