import { DashboardLayout } from "@/components/layout/dashboard-layout"; import { AdminPatientsTable } from "@/components/admin/patients-table"; import { requireAdmin } from "@/lib/auth-session/auth-server"; import { prisma } from "@/lib/types/prisma"; import type { Metadata } from "next"; export const metadata: Metadata = { title: "Patient Management", }; // Force dynamic rendering since this page uses authentication (headers) export const dynamic = "force-dynamic"; export default async function PatientManagementPage() { const { user } = await requireAdmin(); const patients = await prisma.user.findMany({ take: 50, // Limit to 50 patients to prevent excessive data loading where: { role: "patient", }, include: { appointmentsAsPatient: { take: 10, // Limit appointments per patient to avoid N+1 issue include: { service: true, dentist: true, }, orderBy: { date: "desc", }, }, payments: { take: 10, // Limit payments per patient orderBy: { createdAt: "desc", }, }, }, orderBy: { createdAt: "desc", }, }); return (

Patient Management

Manage all patients in the system

); }