'use client'; import { useState } from 'react'; import { FiPlus, FiEye, FiEdit } from 'react-icons/fi'; import Link from 'next/link'; import { formatDate } from '@/lib/date-utils'; interface BookingsTableProps { bookings: any[]; locations: any[]; user: any; } export default function BookingsTable({ bookings, locations, user }: BookingsTableProps) { const [statusFilter, setStatusFilter] = useState('ALL'); const [locationFilter, setLocationFilter] = useState('ALL'); const [searchTerm, setSearchTerm] = useState(''); const filteredBookings = bookings.filter(booking => { if (statusFilter !== 'ALL' && booking.status !== statusFilter) return false; if (locationFilter !== 'ALL' && booking.location.slug !== locationFilter) return false; if (searchTerm) { const search = searchTerm.toLowerCase(); return ( booking.customerName.toLowerCase().includes(search) || booking.customerEmail.toLowerCase().includes(search) || booking.bookingNumber.toLowerCase().includes(search) || booking.eventCity.toLowerCase().includes(search) ); } return true; }); 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; } }; const stats = { total: bookings.length, reserved: bookings.filter(b => b.status === 'RESERVED').length, confirmed: bookings.filter(b => b.status === 'CONFIRMED').length, completed: bookings.filter(b => b.status === 'COMPLETED').length, }; return (

Buchungen

Alle Buchungsanfragen im Überblick

Neue Buchung

Gesamt

{stats.total}

Reserviert

{stats.reserved}

Bestätigt

{stats.confirmed}

Abgeschlossen

{stats.completed}

setSearchTerm(e.target.value)} className="w-full px-4 py-2 bg-gray-700 border border-gray-600 text-white rounded-lg focus:ring-2 focus:ring-red-500 focus:border-transparent placeholder-gray-400" />
{filteredBookings.length === 0 ? (

Keine Buchungen gefunden

) : (
{filteredBookings.map(booking => ( window.location.href = `/dashboard/bookings/${booking.id}`} className="border-b border-gray-700 hover:bg-gray-700/50 transition-colors cursor-pointer" > ))}
Buchungsnr. Kunde Event Standort Datum Status Aktionen
{booking.bookingNumber}

{booking.customerName}

{booking.customerEmail}

{booking.eventCity}

{booking.eventLocation && (

{booking.eventLocation}

)}
{booking.location.name} {formatDate(booking.eventDate)} {getStatusLabel(booking.status)} e.stopPropagation()}>
)}
); }