import { prisma } from "@/lib/prisma";

export default async function AdminDashboardPage() {
  const [adminCount, codeCount, usedCodeCount] = await Promise.all([
    prisma.adminUser.count(),
    prisma.code.count(),
    prisma.code.count({ where: { usedByUserId: { not: null } } }),
  ]);

  return (
    <div>
      <h1 className="mb-8 text-2xl font-semibold text-stone-900">Контролна табла</h1>
      <div className="grid gap-6 sm:grid-cols-3">
        <div className="rounded-lg bg-white p-6 shadow-sm">
          <p className="text-sm text-stone-500">Администратори</p>
          <p className="mt-1 text-3xl font-semibold text-stone-900">{adminCount}</p>
        </div>
        <div className="rounded-lg bg-white p-6 shadow-sm">
          <p className="text-sm text-stone-500">Генерирани кодови</p>
          <p className="mt-1 text-3xl font-semibold text-stone-900">{codeCount}</p>
        </div>
        <div className="rounded-lg bg-white p-6 shadow-sm">
          <p className="text-sm text-stone-500">Искористени кодови</p>
          <p className="mt-1 text-3xl font-semibold text-stone-900">{usedCodeCount}</p>
        </div>
      </div>
    </div>
  );
}
