import { getServerSession } from 'next-auth'; import { authOptions } from '@/lib/auth'; import { prisma } from '@/lib/prisma'; import { redirect } from 'next/navigation'; import DashboardSidebar from '@/components/DashboardSidebar'; import BookingAutomationPanel from '@/components/BookingAutomationPanel'; import { formatDate, formatDateTime } from '@/lib/date-utils'; import Link from 'next/link'; export default async function BookingDetailPage({ params }: { params: { id: string } }) { const session = await getServerSession(authOptions); if (!session || session.user.role !== 'ADMIN') { redirect('/auth/signin'); } const booking = await prisma.booking.findUnique({ where: { id: params.id }, include: { location: true, photobox: true, }, }); if (!booking) { redirect('/dashboard/bookings'); } const getStatusColor = (status: string) => { switch (status) { case 'RESERVED': return 'bg-yellow-500/20 text-yellow-400 border border-yellow-500/50'; case 'CONFIRMED': return 'bg-green-500/20 text-green-400 border border-green-500/50'; case 'COMPLETED': return 'bg-blue-500/20 text-blue-400 border border-blue-500/50'; case 'CANCELLED': return 'bg-red-500/20 text-red-400 border border-red-500/50'; default: return 'bg-gray-500/20 text-gray-400 border border-gray-500/50'; } }; const getStatusLabel = (status: string) => { switch (status) { case 'RESERVED': return 'Reserviert'; case 'CONFIRMED': return 'Bestätigt'; case 'COMPLETED': return 'Abgeschlossen'; case 'CANCELLED': return 'Storniert'; default: return status; } }; return (
{/* Header */}

{booking.bookingNumber}

{booking.customerName}

Bearbeiten
{getStatusLabel(booking.status)}
{/* Automation Panel */}
{/* Booking Details */}
{/* Customer Info */}

Kundendaten

Name: {booking.customerName}
E-Mail: {booking.customerEmail}
Telefon: {booking.customerPhone}
{booking.customerAddress && (
Adresse: {booking.customerAddress}, {booking.customerZip} {booking.customerCity}
)} {booking.companyName && (
Firma: {booking.companyName}
)}
{/* Event Info */}

Event-Details

Datum: {formatDate(booking.eventDate)}
Location: {booking.eventLocation || '-'}
Adresse: {booking.eventAddress}, {booking.eventZip} {booking.eventCity}
Aufbau Start: {formatDateTime(booking.setupTimeStart)}
Aufbau spätestens: {formatDateTime(booking.setupTimeLatest)}
{booking.dismantleTimeEarliest && (
Abbau ab: {formatDateTime(booking.dismantleTimeEarliest)}
)} {booking.dismantleTimeLatest && (
Abbau spätestens: {formatDateTime(booking.dismantleTimeLatest)}
)} {booking.notes && (
Notizen:

{booking.notes}

)}
{/* Photobox & Pricing */}

Fotobox & Preis

Modell: {booking.photobox?.model || '-'}
Serial Number: {booking.photobox?.serialNumber || '-'}
Druckflatrate: {booking.withPrintFlat ? 'Ja' : 'Nein'}
{booking.distance && (
Entfernung: {booking.distance.toFixed(1)} km
)} {booking.calculatedPrice && (
Gesamtpreis: {booking.calculatedPrice.toFixed(2)} €
)}
{/* Location Info */}

Standort

Name: {booking.location?.name}
Stadt: {booking.location?.city}
Website: {booking.location?.websiteUrl}
Kontakt: {booking.location?.contactEmail}
{/* LexOffice IDs (if present) */} {(booking.lexofficeContactId || booking.lexofficeOfferId || booking.lexofficeConfirmationId) && (

LexOffice Integration

{booking.lexofficeContactId && (
Kontakt-ID: {booking.lexofficeContactId}
)} {booking.lexofficeOfferId && (
Angebots-ID: {booking.lexofficeOfferId}
)} {booking.lexofficeConfirmationId && (
Bestätigungs-ID: {booking.lexofficeConfirmationId}
)}
)}
); }