import Link from "next/link"; import { dismissApplication } from "@/actions/admin-applications"; import { StatusCard } from "@/components/admin/dashboard"; import { prisma } from "@/lib/prisma"; 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() { 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 (

Staff Applications

Pending applications from players requesting a staff rank.

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

Applications ({applications.length})

{applications.length === 0 ? (

No pending applications.

) : (
{applications.map((a) => { const username = userMap.get(a.userId); return (

{username ? ( {username} ) : ( <>User #{a.userId} )}

Rank {a.rankId}

{formatDate(a.createdAt)}

{a.content}

); })}
)}
); }