"use client"; import { useQuery } from "@tanstack/react-query"; import { useParams } from "next/navigation"; import { api } from "@/lib/api"; import type { Appointment } from "@/lib/types"; import { Breadcrumb } from "@/components/layout/Breadcrumb"; import { NotesList } from "@/components/notes/NotesList"; import { Skeleton } from "@/components/ui/Skeleton"; import { format, parseISO } from "date-fns"; import { de } from "date-fns/locale"; import { AlertTriangle, Calendar, ExternalLink, MapPin, } from "lucide-react"; import Link from "next/link"; interface AppointmentDetail extends Appointment { case_number?: string; case_title?: string; } const TYPE_LABELS: Record = { hearing: "Verhandlung", meeting: "Besprechung", consultation: "Beratung", deadline_hearing: "Fristanhoerung", other: "Sonstiges", }; const TYPE_COLORS: Record = { hearing: "bg-blue-50 text-blue-700", meeting: "bg-violet-50 text-violet-700", consultation: "bg-emerald-50 text-emerald-700", deadline_hearing: "bg-amber-50 text-amber-700", other: "bg-neutral-100 text-neutral-600", }; function DetailSkeleton() { return (
); } export default function AppointmentDetailPage() { const { id } = useParams<{ id: string }>(); const { data: appointment, isLoading, error, } = useQuery({ queryKey: ["appointment", id], queryFn: () => api.get(`/appointments/${id}`), }); if (isLoading) return ; if (error || !appointment) { return (

Termin nicht gefunden

Der Termin existiert nicht oder Sie haben keine Berechtigung.

Zurueck zu Termine
); } const startDate = parseISO(appointment.start_at); const typeBadge = appointment.appointment_type ? TYPE_COLORS[appointment.appointment_type] ?? TYPE_COLORS.other : null; const typeLabel = appointment.appointment_type ? TYPE_LABELS[appointment.appointment_type] ?? appointment.appointment_type : null; return (
{/* Header */}

{appointment.title}

{typeBadge && typeLabel && ( {typeLabel} )}
{/* Date & Time */}
{format(startDate, "EEEE, d. MMMM yyyy", { locale: de })}

{format(startDate, "HH:mm", { locale: de })} Uhr {appointment.end_at && ( <> {" "} – {format(parseISO(appointment.end_at), "HH:mm", { locale: de })}{" "} Uhr )}

{/* Location */} {appointment.location && (
{appointment.location}
)} {/* Case context */} {appointment.case_id && (

Akte

{appointment.case_number ? `Az. ${appointment.case_number}` : "Verknuepfte Akte"} {appointment.case_title && ` — ${appointment.case_title}`}

Zur Akte
)} {/* Description */} {appointment.description && (

Beschreibung

{appointment.description}

)} {/* Notes */}
); }