import { listTenants, listUsers, listPlans } from '@/db/admin-queries';

export const dynamic = 'force-dynamic';

export default async function AdminHome() {
  const [tenants, users, plans] = await Promise.all([listTenants(), listUsers(), listPlans()]);
  const cards = [
    { label: 'Reformistas (tenants)', value: tenants.length },
    { label: 'Usuarios', value: users.length },
    { label: 'Planes activos', value: plans.length },
    { label: 'En trial', value: tenants.filter((t) => t.subscriptionStatus === 'trial').length },
  ];
  return (
    <div className="flex flex-col gap-6">
      <h1 className="text-2xl font-black tracking-tight text-black">Resumen</h1>
      <div className="grid grid-cols-2 md:grid-cols-4 gap-4">
        {cards.map((c) => (
          <div key={c.label} className="bg-white border border-gray-200 rounded-xl p-5">
            <div className="text-3xl font-black text-black">{c.value}</div>
            <div className="text-xs text-gray-500 mt-1">{c.label}</div>
          </div>
        ))}
      </div>
    </div>
  );
}
