"use client"; import { CalendarClock, ClipboardList, Pill } from "lucide-react"; import type { LucideIcon } from "lucide-react"; import { useTranslation } from "react-i18next"; import { Badge } from "@/components/ui/badge"; import { Card } from "@/components/ui/card"; import type { Appointment } from "@/lib/appointments"; import { formatPrescribedAt, type Prescription } from "@/lib/prescriptions"; import type { Task } from "@/lib/tasks"; type Row = { primary: string; secondary?: string; badge?: string }; function Shell({ icon: Icon, title, rows, emptyKey, }: { icon: LucideIcon; title: string; rows: Row[]; emptyKey: string; }) { const { t } = useTranslation(); return ( {title} {rows.length} {rows.length === 0 ? ( {t(emptyKey)} ) : ( {rows.map((row, i) => ( {row.primary} {row.secondary ? ( {row.secondary} ) : null} {row.badge ? ( {row.badge} ) : null} ))} )} ); } export function AppointmentListCard({ appointments }: { appointments: Appointment[] }) { const { t } = useTranslation(); const rows: Row[] = appointments.map((a) => ({ primary: a.name, secondary: [a.date, a.time, a.type, a.provider].filter(Boolean).join(" · "), badge: a.status, })); return ( ); } export function TaskListCard({ tasks }: { tasks: Task[] }) { const { t } = useTranslation(); const rows: Row[] = tasks.map((tk) => ({ primary: tk.title, secondary: [tk.assignee, tk.due].filter(Boolean).join(" · "), badge: tk.done ? t("chat.lists.done") : tk.priority, })); return ( ); } export function PrescriptionListCard({ prescriptions, }: { prescriptions: Prescription[]; }) { const { t } = useTranslation(); const rows: Row[] = prescriptions.map((rx) => ({ primary: [rx.medication, rx.dose].filter(Boolean).join(" "), secondary: [rx.name, rx.frequency, formatPrescribedAt(rx.prescribedAt)] .filter(Boolean) .join(" · "), badge: rx.status, })); return ( ); }
{t(emptyKey)}