import { redirect } from 'next/navigation'; import { CalendarCheck } from 'lucide-react'; import type { Metadata } from 'next'; import { getPortalSession } from '@/lib/portal/auth'; import { getPortalUserReservations } from '@/lib/services/portal.service'; import { Badge } from '@/components/ui/badge'; export const metadata: Metadata = { title: 'My Reservations' }; const STATUS_COLORS: Record = { pending: 'secondary', active: 'default', ended: 'outline', cancelled: 'destructive', }; const TENURE_LABELS: Record = { permanent: 'Permanent', fixed_term: 'Fixed term', seasonal: 'Seasonal', }; function formatDate(d: Date | string): string { return new Date(d).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric', }); } export default async function PortalMyReservationsPage() { const session = await getPortalSession(); if (!session) redirect('/portal/login'); const reservations = await getPortalUserReservations(session.clientId, session.portId); return (

My Reservations

Your current and pending berth reservations

{reservations.length === 0 ? (

No active reservations

Contact your port representative to discuss reservations.

) : (
{reservations.map((r) => (
{r.yachtName ?? 'Yacht'} {r.berthMooringNumber && ( — Berth {r.berthMooringNumber} )}

{TENURE_LABELS[r.tenureType] ?? r.tenureType}

From {formatDate(r.startDate)} {r.endDate ? ` to ${formatDate(r.endDate)}` : ' · ongoing'}
{r.status}
))}
)}
); }