'use client'; import { Appointment } from '@/types/appointment'; interface AppointmentListProps { appointments: Appointment[]; onToggleDone: (id: string) => void; onEdit: (appointment: Appointment) => void; onDelete: (id: string) => void; } const weekdays = ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa']; const formatDate = (iso: string) => { const d = new Date(iso); const day = String(d.getDate()).padStart(2, '0'); const m = String(d.getMonth() + 1).padStart(2, '0'); return `${day}.${m}.${d.getFullYear()}`; }; const formatTime = (iso: string) => { const d = new Date(iso); const h = String(d.getHours()).padStart(2, '0'); const min = String(d.getMinutes()).padStart(2, '0'); return `${h}:${min}`; }; const getWeekday = (iso: string) => weekdays[new Date(iso).getDay()]; export default function AppointmentList({ appointments, onToggleDone, onEdit, onDelete, }: AppointmentListProps) { if (appointments.length === 0) { return (
Keine Termine vorhanden. Fügen Sie oben einen neuen Termin hinzu!
); } const sorted = [...appointments].sort( (a, b) => new Date(a.termin).getTime() - new Date(b.termin).getTime() ); return (
{sorted.map((app, index) => ( onEdit(app)} className={`border-b border-gray-300 hover:bg-gray-100 cursor-pointer ${ app.erledigt ? 'bg-green-50 text-gray-400 line-through' : index % 2 === 0 ? 'bg-white' : 'bg-gray-50' }`} > ))}
Erledigt Arzt Fachrichtung Datum Tag Zeit Bemerkungen Aktion
e.stopPropagation()} > onToggleDone(app.id)} /> {app.arztName} {app.arztArt || '-'} {formatDate(app.termin)} {getWeekday(app.termin)} {formatTime(app.termin)} {app.bemerkungen || '-'} e.stopPropagation()} >
); }