import Link from "next/link"; import { ClipboardList } from "lucide-react"; import { dismissApplication } from "@/actions/admin-applications"; import { StatusCard } from "@/components/admin/dashboard"; import { prisma } from "@/lib/prisma"; import { getTranslations } from "next-intl/server"; export const dynamic = "force-dynamic"; type ApplicationRow = { id: bigint; userId: number; rankId: number; content: string; createdAt: Date | null; }; function formatDate(d: Date | null): string { return d ? d.toISOString().slice(0, 16).replace("T", " ") : "—"; } export default async function AdminApplications() { const t = await getTranslations("pages.admin.applications"); let applications: ApplicationRow[]; try { applications = await prisma.websiteStaffApplications.findMany({ orderBy: { createdAt: "desc" }, take: 100, }); } catch { applications = []; } // Resolve applicant usernames (no relation defined on the model). const userMap = new Map(); if (applications.length > 0) { try { const ids = Array.from(new Set(applications.map((a) => a.userId))); const users = await prisma.user.findMany({ where: { id: { in: ids } }, select: { id: true, username: true }, }); for (const u of users) userMap.set(u.id, u.username); } catch { // no DB — fall back to raw ids } } return (

{t("title")}

{t("subtitle")}

0 ? "warn" : "ok"} icon="📨" />

{t("applicationsTitle", { count: applications.length })}

{applications.length === 0 ? (
{t("noApplications")}
) : (
{applications.map((a) => { const username = userMap.get(a.userId); return (

{username ? ( {username} ) : ( <>{t("userNumber", { id: a.userId })} )}

{t("rankLabel", { rank: a.rankId })}

{formatDate(a.createdAt)}

{a.content}

); })}
)}
); }