- Convert admin layout, sidebar, and navigation to Tailwind classes - Convert dashboard components (StatusCard, DiagnosticRow, etc.) to Tailwind - Convert all ~48 admin page files from admin CSS classes to Tailwind - Remove unused admin CSS from globals.css (973 → 712 lines) - Convert developers page badges to Tailwind - Remove <style jsx> block from OnlineUsersWidget
108 lines
3.5 KiB
TypeScript
108 lines
3.5 KiB
TypeScript
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<number, string>();
|
|
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 (
|
|
<main>
|
|
<h1>Staff Applications</h1>
|
|
<p className="muted" style={{ marginTop: "-0.4rem" }}>
|
|
Pending applications from players requesting a staff rank.
|
|
</p>
|
|
|
|
<div className="grid grid-cols-[repeat(auto-fit,minmax(180px,1fr))] gap-3.5 mb-6">
|
|
<StatusCard
|
|
label="Pending applications"
|
|
value={applications.length}
|
|
state={applications.length > 0 ? "warn" : "ok"}
|
|
icon="📨"
|
|
/>
|
|
</div>
|
|
|
|
<section className="mt-6">
|
|
<h2>Applications ({applications.length})</h2>
|
|
{applications.length === 0 ? (
|
|
<p className="muted">No pending applications.</p>
|
|
) : (
|
|
<div className="grid cols-2">
|
|
{applications.map((a) => {
|
|
const username = userMap.get(a.userId);
|
|
return (
|
|
<article key={String(a.id)} className="card">
|
|
<div
|
|
style={{
|
|
display: "flex",
|
|
justifyContent: "space-between",
|
|
alignItems: "baseline",
|
|
gap: "0.5rem",
|
|
}}
|
|
>
|
|
<h3 style={{ margin: "0 0 0.25rem" }}>
|
|
{username ? (
|
|
<Link href={`/admin/users/${a.userId}`}>{username}</Link>
|
|
) : (
|
|
<>User #{a.userId}</>
|
|
)}
|
|
</h3>
|
|
<span className="inline-block text-[0.72rem] font-bold px-2 py-0.5 rounded-full bg-[var(--color-primary)]/18 text-[var(--color-text)]">Rank {a.rankId}</span>
|
|
</div>
|
|
<p className="muted" style={{ marginTop: 0 }}>
|
|
{formatDate(a.createdAt)}
|
|
</p>
|
|
<p style={{ whiteSpace: "pre-wrap", margin: "0 0 0.75rem" }}>{a.content}</p>
|
|
<form action={dismissApplication}>
|
|
<input type="hidden" name="id" value={String(a.id)} />
|
|
<button type="submit" className="btn btn-danger">
|
|
Dismiss
|
|
</button>
|
|
</form>
|
|
</article>
|
|
);
|
|
})}
|
|
</div>
|
|
)}
|
|
</section>
|
|
</main>
|
|
);
|
|
}
|