import Link from "next/link"; import { BookOpen, Calendar, GraduationCap, Newspaper, Plus, Users, MessageSquareQuote, } from "lucide-react"; import { query } from "@/lib/db"; import { Card, CardAction, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { buttonVariants } from "@/components/ui/button"; import { cn } from "@/lib/utils"; import { LeadsList, type LeadForDashboard } from "@/components/organisms/admin/LeadsList"; import { AdminPage, AdminPageHeader, } from "@/components/organisms/admin/AdminPage"; export const dynamic = "force-dynamic"; interface CountRow { entity: string; n: number; } const getCounts = async (): Promise> => { const res = await query( `SELECT 'courses' AS entity, count(*)::int AS n FROM courses UNION ALL SELECT 'programs', count(*) FROM programs UNION ALL SELECT 'events', count(*) FROM events UNION ALL SELECT 'articles', count(*) FROM articles UNION ALL SELECT 'faculty', count(*) FROM faculty_members UNION ALL SELECT 'alumni', count(*) FROM alumni_stories`, ); return Object.fromEntries(res.rows.map((r) => [r.entity, r.n])); }; const countCards = [ { key: "courses", label: "دوره‌ها", href: "/admin/courses", icon: BookOpen }, { key: "programs", label: "برنامه‌ها", href: "/admin/programs", icon: GraduationCap }, { key: "events", label: "رویدادها", href: "/admin/events", icon: Calendar }, { key: "articles", label: "مقالات", href: "/admin/articles", icon: Newspaper }, { key: "faculty", label: "اساتید", href: "/admin/faculty", icon: Users }, { key: "alumni", label: "دانش‌آموختگان", href: "/admin/alumni", icon: MessageSquareQuote }, ] as const; export default async function AdminDashboardPage() { const [counts, leadsRes] = await Promise.all([ getCounts(), query( `SELECT id, full_name, email, course_slug, status, created_at FROM registration_leads ORDER BY created_at DESC LIMIT 5`, ), ]); return ( دوره جدید } />

آمار محتوا

{countCards.map(({ key, label, href, icon: Icon }) => (
{label}

{counts[key] ?? 0}

))}
درخواست‌های اخیر ثبت‌نام ۵ درخواست آخر از برگ ثبت‌نام مشاهده همه
); }