Add niche admin + public expansions + self-host Nunito font (batches 3-4)
Built via two more parallel agent workflows (read schema -> return files), integrated + verified. Admin: /admin/emulator (emulator_settings + emulator_texts key/value editor), /admin/badges (give-badge via RCON), /admin/rare-values (CRUD), /admin/housekeeping (CRUD), /admin/email-templates (CRUD), /admin/photos (moderation). Public: /rares (+[category]), /leaderboard (credits/diamonds/duckets), /guilds (+[id] members), /redeem (voucher -> sendCurrency). Expanded: /u/[username] now shows badges + photos + guestbook (post form); /news/[slug] now shows reactions + comments (comment form). Reactions tallied in JS (Prisma groupBy typing avoided). Self-hosted Nunito via next/font/google wired to --font-nunito (the atom theme font, no runtime external fetch). Header + admin nav extended. Verified: tsc exit 0, vitest 48/48, next build exit 0.
This commit is contained in:
1 parent
e96b606e1e
commit
e8be0461d8
28 files changed
+2347
-5
No files matched your search
@@ -0,0 +1,96 @@
|
||||
import Link from "next/link";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { siteSettings } from "@/lib/services/site-settings";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
type CategoryRow = {
|
||||
id: bigint;
|
||||
name: string;
|
||||
badge: string;
|
||||
priority: number;
|
||||
};
|
||||
|
||||
export default async function RareValuesPage() {
|
||||
let categories: CategoryRow[] = [];
|
||||
try {
|
||||
categories = await prisma.websiteRareValueCategories.findMany({
|
||||
orderBy: [{ priority: "asc" }, { name: "asc" }],
|
||||
select: { id: true, name: true, badge: true, priority: true },
|
||||
});
|
||||
} catch {
|
||||
categories = [];
|
||||
}
|
||||
|
||||
// Per-category rare counts (grouped so we avoid N queries).
|
||||
const counts = new Map<string, number>();
|
||||
try {
|
||||
const grouped = await prisma.websiteRareValues.groupBy({
|
||||
by: ["categoryId"],
|
||||
_count: { _all: true },
|
||||
});
|
||||
for (const g of grouped) {
|
||||
counts.set(String(g.categoryId), g._count._all);
|
||||
}
|
||||
} catch {
|
||||
// leave counts empty -> shown as 0
|
||||
}
|
||||
|
||||
const badgesBase = (await siteSettings.get("badges_path", "")) ?? "";
|
||||
|
||||
return (
|
||||
<main>
|
||||
<div className="hero">
|
||||
<h1 style={{ margin: 0 }}>Rare values</h1>
|
||||
<p className="muted" style={{ marginBottom: 0 }}>
|
||||
Get an overview of all of the rares on the hotel, grouped by category.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{categories.length === 0 ? (
|
||||
<p className="muted">We currently have no rares listed here.</p>
|
||||
) : (
|
||||
<div className="grid cols-3">
|
||||
{categories.map((c) => {
|
||||
const id = String(c.id);
|
||||
const count = counts.get(id) ?? 0;
|
||||
const badgeSrc = badgesBase && c.badge ? `${badgesBase}/${c.badge}.gif` : "";
|
||||
return (
|
||||
<Link
|
||||
key={id}
|
||||
href={`/rares/${id}`}
|
||||
className="card hover"
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
gap: "0.85rem",
|
||||
textDecoration: "none",
|
||||
color: "inherit",
|
||||
}}
|
||||
>
|
||||
{badgeSrc ? (
|
||||
// eslint-disable-next-line @next/next/no-img-element
|
||||
<img
|
||||
src={badgeSrc}
|
||||
alt={`${c.name} badge`}
|
||||
width={40}
|
||||
height={40}
|
||||
style={{ flexShrink: 0 }}
|
||||
/>
|
||||
) : (
|
||||
<span className="avatar" style={{ width: 40, height: 40, flexShrink: 0 }} />
|
||||
)}
|
||||
<span style={{ display: "flex", flexDirection: "column" }}>
|
||||
<strong>{c.name}</strong>
|
||||
<span className="muted">
|
||||
{count} {count === 1 ? "rare" : "rares"}
|
||||
</span>
|
||||
</span>
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user