Add remaining public + admin pages (parallel build, 26 files)
Built via two parallel agent workflows reading the real Prisma schema, then integrated + verified. Public: /shop (categories + storefront), /community hub, /rankings (top by credits), /staff, /photos (camera_web gallery), /help (categories + rules), /help/tickets (auth-gated user tickets + create), /settings (auth-gated, update motto via RCON). Admin: /admin/catalog (+[id] items), /admin/radio (shouts/apps/schedules + delete shout), /admin/teams (CRUD), /admin/permissions (read), /admin/wordfilter (CRUD + RCON push), /admin/ip (whitelist/blacklist CRUD), /admin/applications (list + dismiss), /admin/logs (chat/command/alert read), /admin/achievements (read). Server actions all staff-gated. Header + admin nav extended. Verified: tsc exit 0, vitest 48/48, next build exit 0 (33 routes); curl-probed every route — public 200/<main>, auth+admin correctly 307-redirect when unauthorized.
This commit is contained in:
1 parent
9a79acebe7
commit
e96b606e1e
27 files changed
+2400
No files matched your search
@@ -0,0 +1,149 @@
|
||||
import {
|
||||
addBlacklist,
|
||||
addWhitelist,
|
||||
deleteBlacklist,
|
||||
deleteWhitelist,
|
||||
} from "@/actions/admin-ip";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
type IpRow = {
|
||||
id: bigint;
|
||||
ipAddress: string;
|
||||
asn: string | null;
|
||||
createdAt: Date | null;
|
||||
};
|
||||
|
||||
function formatDate(d: Date | null): string {
|
||||
return d ? d.toISOString().slice(0, 16).replace("T", " ") : "";
|
||||
}
|
||||
|
||||
export default async function AdminIp() {
|
||||
let whitelist: IpRow[] = [];
|
||||
let blacklist: IpRow[] = [];
|
||||
|
||||
try {
|
||||
whitelist = await prisma.websiteIpWhitelist.findMany({
|
||||
orderBy: { id: "desc" },
|
||||
take: 200,
|
||||
});
|
||||
} catch {
|
||||
whitelist = [];
|
||||
}
|
||||
|
||||
try {
|
||||
blacklist = await prisma.websiteIpBlacklist.findMany({
|
||||
orderBy: { id: "desc" },
|
||||
take: 200,
|
||||
});
|
||||
} catch {
|
||||
blacklist = [];
|
||||
}
|
||||
|
||||
return (
|
||||
<main>
|
||||
<h1>IP Management</h1>
|
||||
|
||||
<div className="grid cols-2">
|
||||
{/* ── Whitelist ─────────────────────────────── */}
|
||||
<section>
|
||||
<h2>Whitelist</h2>
|
||||
|
||||
<form action={addWhitelist} className="card" style={{ marginBottom: "1rem" }}>
|
||||
<div style={{ display: "flex", gap: "0.5rem", flexWrap: "wrap" }}>
|
||||
<input
|
||||
name="ipAddress"
|
||||
placeholder="IP address"
|
||||
required
|
||||
style={{ flex: 1, minWidth: 140 }}
|
||||
/>
|
||||
<input name="asn" placeholder="ASN (optional)" style={{ width: 140 }} />
|
||||
<button type="submit" className="btn btn-secondary">
|
||||
Add
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>IP</th>
|
||||
<th>ASN</th>
|
||||
<th>Added</th>
|
||||
<th />
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{whitelist.map((w) => (
|
||||
<tr key={String(w.id)}>
|
||||
<td>{w.ipAddress}</td>
|
||||
<td className="muted">{w.asn ?? "—"}</td>
|
||||
<td className="muted">{formatDate(w.createdAt)}</td>
|
||||
<td>
|
||||
<form action={deleteWhitelist}>
|
||||
<input type="hidden" name="id" value={String(w.id)} />
|
||||
<button type="submit" className="btn btn-danger">
|
||||
Remove
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
{whitelist.length === 0 ? <p className="muted">No whitelisted IPs.</p> : null}
|
||||
</section>
|
||||
|
||||
{/* ── Blacklist ─────────────────────────────── */}
|
||||
<section>
|
||||
<h2>Blacklist</h2>
|
||||
|
||||
<form action={addBlacklist} className="card" style={{ marginBottom: "1rem" }}>
|
||||
<div style={{ display: "flex", gap: "0.5rem", flexWrap: "wrap" }}>
|
||||
<input
|
||||
name="ipAddress"
|
||||
placeholder="IP address"
|
||||
required
|
||||
style={{ flex: 1, minWidth: 140 }}
|
||||
/>
|
||||
<input name="asn" placeholder="ASN (optional)" style={{ width: 140 }} />
|
||||
<button type="submit" className="btn btn-danger">
|
||||
Add
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>IP</th>
|
||||
<th>ASN</th>
|
||||
<th>Added</th>
|
||||
<th />
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{blacklist.map((b) => (
|
||||
<tr key={String(b.id)}>
|
||||
<td>{b.ipAddress}</td>
|
||||
<td className="muted">{b.asn ?? "—"}</td>
|
||||
<td className="muted">{formatDate(b.createdAt)}</td>
|
||||
<td>
|
||||
<form action={deleteBlacklist}>
|
||||
<input type="hidden" name="id" value={String(b.id)} />
|
||||
<button type="submit" className="btn btn-danger">
|
||||
Remove
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
{blacklist.length === 0 ? <p className="muted">No blacklisted IPs.</p> : null}
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user