Add admin Articles (CRUD) + Bans resources
- Articles: list / new / edit / delete (websiteArticles), unique-slug generation via slugify() (pure, unit-tested); staff-gated server actions. - Bans: list active bans (ban_expire > now), create ban (writes the bans row + RCON disconnect) with type/duration/reason, lift ban; staff-gated actions. - Admin nav extended (Articles, Bans). Verified: tsc exit 0, vitest 48/48, next build exit 0 (7 /admin routes).
This commit is contained in:
1 parent
9f81096f05
commit
5861d9f1f5
9 files changed
+310
-1
No files matched your search
@@ -0,0 +1,41 @@
|
||||
import Link from "next/link";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function AdminArticles() {
|
||||
const articles = await prisma.websiteArticles.findMany({
|
||||
orderBy: { createdAt: "desc" },
|
||||
select: { id: true, title: true, slug: true, createdAt: true },
|
||||
take: 50,
|
||||
});
|
||||
|
||||
return (
|
||||
<main>
|
||||
<div style={{ display: "flex", alignItems: "center", gap: "1rem" }}>
|
||||
<h1 style={{ flex: 1 }}>Articles</h1>
|
||||
<Link href="/admin/articles/new">+ New article</Link>
|
||||
</div>
|
||||
<table style={{ width: "100%", borderCollapse: "collapse" }}>
|
||||
<thead>
|
||||
<tr style={{ textAlign: "left", color: "var(--muted)" }}>
|
||||
<th>Title</th>
|
||||
<th>Slug</th>
|
||||
<th>Created</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{articles.map((a) => (
|
||||
<tr key={String(a.id)} style={{ borderTop: "1px solid var(--border)" }}>
|
||||
<td>
|
||||
<Link href={`/admin/articles/${a.id}`}>{a.title}</Link>
|
||||
</td>
|
||||
<td className="muted">{a.slug}</td>
|
||||
<td className="muted">{a.createdAt ? a.createdAt.toISOString().slice(0, 10) : ""}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user