import type { Metadata } from "next";
import { getCurrentCustomer } from "@/lib/auth/customer";
import { getCustomerBookings } from "@/lib/booking/queries";
import { BookingCard } from "@/components/booking/BookingCard";

export const metadata: Metadata = { title: "Meine Termine" };

export default async function KontoTerminePage() {
  const customer = await getCurrentCustomer();
  if (!customer) return null;

  const bookings = await getCustomerBookings(customer.id);

  return (
    <div>
      <h2 className="font-serif text-xl font-medium text-anouma-plum">Meine Termine</h2>
      {bookings.length === 0 ? (
        <p className="mt-3 text-sm text-anouma-plum/70">
          Du hast noch keine Terminanfragen gestellt.
        </p>
      ) : (
        <div className="mt-4 grid gap-4 sm:grid-cols-2">
          {bookings.map((b) => (
            <BookingCard key={b.id} booking={b} />
          ))}
        </div>
      )}
    </div>
  );
}
