Add social login (Discord/Google) + batch-6 pages

Auth: NextAuth Discord + Google providers (enabled when env id+secret set);
OAuth signIn allowed only if a hotel account matches the email; jwt binds the
session to that account (id/rank/username). Login page gets social buttons.

Batch 6 (parallel agents): /friends (messenger_friendships), /guilds/[id]/forum
(threads), /admin/navigation (navigator config), /admin/maintenance (toggle
maintenance settings), /admin/alerts (alert_logs + send hotel alert via RCON).
Header (Friends) + admin nav (Alerts/Maintenance/Navigator) extended.

Verified: tsc exit 0, vitest 48/48, next build exit 0 (57 page routes).
This commit is contained in:
Simo committed 2026-06-28 14:13:41 +02:00
1 parent 73f0f54624
commit 486ce51559
12 files changed
+911 -3

No files matched your search

+185
View File
@@ -0,0 +1,185 @@
import { prisma } from "@/lib/prisma";
export const dynamic = "force-dynamic";
// navigator_flatcats — emulator-owned flat (private-room) categories shown in the
// navigator. The Prisma delegate exists because the table has a primary key.
type Flatcat = {
id: number;
caption: string;
captionSave: string;
minRank: number;
maxUserCount: number;
canTrade: string;
public: string;
listType: number;
orderNum: number;
};
// navigator_publics — emulator-owned public-room assignments. This table has no
// primary/unique key, so Prisma marks the model `@@ignore` and generates NO
// delegate (prisma.navigatorPublics does not exist). It must be read via raw SQL.
type PublicRow = {
public_cat_id: number;
room_id: number;
visible: string;
};
export default async function AdminNavigation() {
let flatcats: Flatcat[] = [];
try {
flatcats = await prisma.navigatorFlatcats.findMany({
select: {
id: true,
caption: true,
captionSave: true,
minRank: true,
maxUserCount: true,
canTrade: true,
public: true,
listType: true,
orderNum: true,
},
orderBy: [{ orderNum: "asc" }, { id: "asc" }],
});
} catch {
flatcats = [];
}
// Raw read because navigator_publics is an `@@ignore`d (keyless) model.
let publics: PublicRow[] = [];
try {
publics = await prisma.$queryRaw<PublicRow[]>`
SELECT public_cat_id, room_id, visible
FROM navigator_publics
ORDER BY public_cat_id ASC, room_id ASC
`;
} catch {
publics = [];
}
// Resolve the public-category names and room names referenced by the rows above
// so the read-only view is legible. Each lookup degrades to an empty map on error.
const catIds = Array.from(new Set(publics.map((p) => p.public_cat_id)));
const roomIds = Array.from(new Set(publics.map((p) => p.room_id)));
let catNameById = new Map<number, string>();
if (catIds.length) {
try {
const cats = await prisma.navigatorPubliccats.findMany({
where: { id: { in: catIds } },
select: { id: true, name: true },
});
catNameById = new Map(cats.map((c) => [c.id, c.name]));
} catch {
catNameById = new Map();
}
}
let roomNameById = new Map<number, string>();
if (roomIds.length) {
try {
const rooms = await prisma.rooms.findMany({
where: { id: { in: roomIds } },
select: { id: true, name: true },
});
roomNameById = new Map(rooms.map((r) => [r.id, r.name]));
} catch {
roomNameById = new Map();
}
}
return (
<main>
<h1>Navigator</h1>
<p className="muted" style={{ marginTop: 0 }}>
Read-only · the navigator config is owned by the emulator. Edit it in your
emulator tooling, not here.
</p>
{/* ── navigator_flatcats ───────────────────────────────── */}
<div className="card" style={{ padding: 0, overflowX: "auto", marginBottom: "1.5rem" }}>
<div style={{ padding: "1.1rem 1.25rem 0" }}>
<h3 style={{ margin: 0 }}>Flat categories</h3>
<p className="muted" style={{ margin: "0.25rem 0 0" }}>
<code>navigator_flatcats</code> · {flatcats.length} rows
</p>
</div>
<table>
<thead>
<tr>
<th>ID</th>
<th>Caption</th>
<th>Caption (save)</th>
<th>Min rank</th>
<th>Max users</th>
<th>Can trade</th>
<th>Public</th>
<th>List type</th>
<th>Order</th>
</tr>
</thead>
<tbody>
{flatcats.map((c) => (
<tr key={c.id}>
<td>{c.id}</td>
<td>{c.caption || "—"}</td>
<td>{c.captionSave || "—"}</td>
<td>{c.minRank}</td>
<td>{c.maxUserCount}</td>
<td>{c.canTrade === "1" ? "Yes" : "No"}</td>
<td>{c.public === "1" ? "Yes" : "No"}</td>
<td>{c.listType}</td>
<td>{c.orderNum}</td>
</tr>
))}
</tbody>
</table>
{flatcats.length === 0 ? (
<p className="muted" style={{ padding: "0 1.25rem 1.1rem" }}>
No flat categories found.
</p>
) : null}
</div>
{/* ── navigator_publics ────────────────────────────────── */}
<div className="card" style={{ padding: 0, overflowX: "auto" }}>
<div style={{ padding: "1.1rem 1.25rem 0" }}>
<h3 style={{ margin: 0 }}>Public rooms</h3>
<p className="muted" style={{ margin: "0.25rem 0 0" }}>
<code>navigator_publics</code> · {publics.length} rows
</p>
</div>
<table>
<thead>
<tr>
<th>Public cat</th>
<th>Room</th>
<th>Visible</th>
</tr>
</thead>
<tbody>
{publics.map((p, i) => (
<tr key={`${p.public_cat_id}-${p.room_id}-${i}`}>
<td>
{catNameById.get(p.public_cat_id) ?? "—"}{" "}
<span className="muted">#{p.public_cat_id}</span>
</td>
<td>
{roomNameById.get(p.room_id) || "(unnamed)"}{" "}
<span className="muted">#{p.room_id}</span>
</td>
<td>{p.visible === "1" ? "Yes" : "No"}</td>
</tr>
))}
</tbody>
</table>
{publics.length === 0 ? (
<p className="muted" style={{ padding: "0 1.25rem 1.1rem" }}>
No public-room assignments found.
</p>
) : null}
</div>
</main>
);
}