import Link from 'next/link'; import { CalendarDays, MapPin, Plus, Users } 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, CardHeader, CardTitle } from '@kit/ui/card'; import { createEventManagementApi } from '@kit/event-management/api'; import { CmsPageShell } from '~/components/cms-page-shell'; import { EmptyState } from '~/components/empty-state'; import { StatsCard } from '~/components/stats-card'; interface PageProps { params: Promise<{ account: string }>; } const STATUS_BADGE_VARIANT: Record< string, 'secondary' | 'default' | 'info' | 'outline' | 'destructive' > = { draft: 'secondary', published: 'default', registration_open: 'info', registration_closed: 'outline', cancelled: 'destructive', completed: 'outline', }; const STATUS_LABEL: Record = { draft: 'Entwurf', published: 'Veröffentlicht', registration_open: 'Anmeldung offen', registration_closed: 'Anmeldung geschlossen', cancelled: 'Abgesagt', completed: 'Abgeschlossen', }; export default async function EventsPage({ params }: PageProps) { const { account } = await params; const client = getSupabaseServerClient(); const { data: acct } = await client .from('accounts') .select('id') .eq('slug', account) .single(); if (!acct) return
Konto nicht gefunden
; const api = createEventManagementApi(client); const events = await api.listEvents(acct.id, { page: 1 }); return (
{/* Header */}

Veranstaltungen

Veranstaltungen und Ferienprogramme

{/* Stats */}
} /> ) => e.location) .filter(Boolean), ).size } icon={} /> ) => sum + (Number(e.capacity) || 0), 0, )} icon={} />
{/* Table or Empty State */} {events.data.length === 0 ? ( } title="Keine Veranstaltungen vorhanden" description="Erstellen Sie Ihre erste Veranstaltung, um loszulegen." actionLabel="Neue Veranstaltung" actionHref={`/home/${account}/events/new`} /> ) : ( Alle Veranstaltungen ({events.total})
{events.data.map((event: Record) => ( ))}
Name Datum Ort Kapazität Status Anmeldungen
{String(event.name)} {event.event_date ? new Date(String(event.event_date)).toLocaleDateString('de-DE') : '—'} {String(event.location ?? '—')} {event.capacity != null ? String(event.capacity) : '—'} {STATUS_LABEL[String(event.status)] ?? String(event.status)}
)}
); }