import RequestsTable from "@/components/commissions/requests/RequestsTable";
import { prisma } from "@/lib/prisma";

// Server-rendered commissions list page.
export default async function CommissionPage() {
  const items = await prisma.commissionRequest.findMany({
    include: {
      _count: { select: { files: true } },
    },
    orderBy: { index: "desc" },
  });

  return (
    <div className="space-y-8">
      <div className="flex flex-col gap-4">
        <div>
          <h1 className="text-2xl font-semibold">Commission Requests</h1>
          <p className="text-sm text-muted-foreground">
            List of all incoming requests via website.
          </p>
        </div>
        <RequestsTable requests={items} />
      </div>
    </div>
  );
}
