import Link from "next/link";
import { prisma } from "@/lib/prisma";

export default async function AdminHomePage() {
  const [offerCount, photoCount, bookingCount] = await Promise.all([
    prisma.offer.count(),
    prisma.galleryPhoto.count(),
    prisma.booking.count(),
  ]);

  const cards = [
    { label: "Offers", value: offerCount, href: "/admin/offers" },
    { label: "Gallery Photos", value: photoCount, href: "/admin/gallery" },
    { label: "Bookings", value: bookingCount, href: "/admin/bookings" },
  ];

  return (
    <div>
      <h1 className="text-2xl font-bold text-charcoal-950">Dashboard</h1>
      <p className="mt-1 text-sm text-charcoal-400">Manage your offers, photos, and bookings.</p>
      <div className="mt-8 grid gap-6 sm:grid-cols-3">
        {cards.map((card) => (
          <Link
            key={card.href}
            href={card.href}
            className="rounded-2xl border border-charcoal-950/10 bg-white p-6 shadow-sm transition-shadow hover:shadow-md"
          >
            <p className="text-sm text-charcoal-400">{card.label}</p>
            <p className="mt-2 text-3xl font-bold text-charcoal-950">{card.value}</p>
          </Link>
        ))}
      </div>
    </div>
  );
}
