"use client"; import { useEffect, useState } from "react"; type EventItem = { id: string; title: string; startAt: string; endAt: string; status: string; location?: string | null; description?: string | null; }; export default function AdminPanel() { const [events, setEvents] = useState([]); const [error, setError] = useState(null); const load = async () => { try { const response = await fetch("/api/events?status=PENDING"); if (!response.ok) { throw new Error("Vorschlaege konnten nicht geladen werden."); } setEvents(await response.json()); } catch (err) { setError((err as Error).message); } }; useEffect(() => { load(); }, []); const updateStatus = async (id: string, status: "APPROVED" | "REJECTED") => { await fetch(`/api/events/${id}`, { method: "PATCH", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ status }) }); load(); }; return (

Adminfreigaben

{error &&

{error}

} {events.length === 0 ? (

Keine offenen Vorschlaege.

) : (
{events.map((event) => (

{event.title}

{new Date(event.startAt).toLocaleString()} - {new Date(event.endAt).toLocaleString()}

{event.location && (

Ort: {event.location}

)}
{event.description && (

{event.description}

)}
))}
)}
); }