import Link from 'next/link'; import { ArrowLeft, BedDouble, CalendarDays, LogIn, LogOut, XCircle, User, } from 'lucide-react'; import { getSupabaseServerClient } from '@kit/supabase/server-client'; import { Badge } from '@kit/ui/badge'; import { Button } from '@kit/ui/button'; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from '@kit/ui/card'; import { CmsPageShell } from '~/components/cms-page-shell'; import { AccountNotFound } from '~/components/account-not-found'; interface PageProps { params: Promise<{ account: string; bookingId: string }>; } const STATUS_BADGE_VARIANT: Record< string, 'secondary' | 'default' | 'info' | 'outline' | 'destructive' > = { pending: 'secondary', confirmed: 'default', checked_in: 'info', checked_out: 'outline', cancelled: 'destructive', no_show: 'destructive', }; const STATUS_LABEL: Record = { pending: 'Ausstehend', confirmed: 'Bestätigt', checked_in: 'Eingecheckt', checked_out: 'Ausgecheckt', cancelled: 'Storniert', no_show: 'Nicht erschienen', }; export default async function BookingDetailPage({ params }: PageProps) { const { account, bookingId } = await params; const client = getSupabaseServerClient(); const { data: acct } = await client .from('accounts') .select('id') .eq('slug', account) .single(); if (!acct) { return ( ); } // Load booking directly const { data: booking } = await client .from('bookings') .select('*') .eq('id', bookingId) .eq('account_id', acct.id) .single(); if (!booking) { return (

Buchung mit ID "{bookingId}" wurde nicht gefunden.

); } // Load related room and guest data const [roomResult, guestResult] = await Promise.all([ booking.room_id ? client.from('rooms').select('*').eq('id', booking.room_id).single() : Promise.resolve({ data: null }), booking.guest_id ? client.from('guests').select('*').eq('id', booking.guest_id).single() : Promise.resolve({ data: null }), ]); const room = roomResult.data; const guest = guestResult.data; const status = String(booking.status ?? 'pending'); return (
{/* Header */}
{STATUS_LABEL[status] ?? status}

ID: {bookingId}

{/* Zimmer */} Zimmer {room ? (
Zimmernummer {String(room.room_number)}
{room.name && (
Name {String(room.name)}
)}
Typ {String(room.room_type ?? '—')}
) : (

Kein Zimmer zugewiesen

)}
{/* Gast */} Gast {guest ? (
Name {String(guest.first_name)} {String(guest.last_name)}
{guest.email && (
E-Mail {String(guest.email)}
)} {guest.phone && (
Telefon {String(guest.phone)}
)}
) : (

Kein Gast zugewiesen

)}
{/* Aufenthalt */} Aufenthalt
Check-in {booking.check_in ? new Date(String(booking.check_in)).toLocaleDateString( 'de-DE', { weekday: 'short', day: '2-digit', month: '2-digit', year: 'numeric', }, ) : '—'}
Check-out {booking.check_out ? new Date(String(booking.check_out)).toLocaleDateString( 'de-DE', { weekday: 'short', day: '2-digit', month: '2-digit', year: 'numeric', }, ) : '—'}
Erwachsene {booking.adults ?? '—'}
Kinder {booking.children ?? 0}
{/* Betrag */} Betrag
Gesamtpreis {booking.total_price != null ? `${Number(booking.total_price).toFixed(2)} €` : '—'}
{booking.notes && (
Notizen

{String(booking.notes)}

)}
{/* Status Workflow */} Aktionen Status der Buchung ändern
{(status === 'pending' || status === 'confirmed') && ( )} {status === 'checked_in' && ( )} {status !== 'cancelled' && status !== 'checked_out' && status !== 'no_show' && ( )} {status === 'cancelled' || status === 'checked_out' ? (

Diese Buchung ist{' '} {status === 'cancelled' ? 'storniert' : 'abgeschlossen'} — keine weiteren Aktionen verfügbar.

) : null}
); }