import { prisma } from "@/lib/db"; import { InquiryRow, type InquiryRowData } from "@/components/admin/InquiryRow"; import type { InquiryStatus } from "@/types"; import { INQUIRY_STATUS_LABELS } from "@/types"; import Link from "next/link"; import { cn } from "@/lib/utils"; export const dynamic = "force-dynamic"; interface PageProps { searchParams: { status?: string }; } const FILTERS: Array<{ key: InquiryStatus | "all"; label: string }> = [ { key: "all", label: "Alle" }, { key: "new", label: "Neu" }, { key: "read", label: "Gelesen" }, { key: "confirmed", label: "Bestätigt" }, { key: "declined", label: "Abgelehnt" }, { key: "archived", label: "Archiviert" }, ]; export default async function AdminInquiriesPage({ searchParams }: PageProps) { const filter = (searchParams.status ?? "all") as InquiryStatus | "all"; const inquiries = await prisma.inquiry.findMany({ where: filter === "all" ? {} : { status: filter }, include: { apartment: { select: { name: true } } }, orderBy: { createdAt: "desc" }, }); const newCount = await prisma.inquiry.count({ where: { status: "new" } }); const rows: InquiryRowData[] = inquiries.map((i) => ({ id: i.id, apartmentName: i.apartment.name, arrival: i.arrival.toISOString(), departure: i.departure.toISOString(), guests: i.guests, name: i.name, email: i.email, phone: i.phone, message: i.message, status: i.status as InquiryStatus, createdAt: i.createdAt.toISOString(), })); return (
{newCount > 0 ? `${newCount} neue Anfrage${newCount === 1 ? "" : "n"} wartet auf Ihre Rückmeldung.` : "Alle Anfragen sind bearbeitet."}