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,171 @@
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { siteSettings } from "@/lib/services/site-settings";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
type RareRow = {
|
||||
id: bigint;
|
||||
name: string;
|
||||
creditValue: string | null;
|
||||
currencyValue: string | null;
|
||||
currencyType: string;
|
||||
furnitureIcon: string;
|
||||
itemId: number | null;
|
||||
};
|
||||
|
||||
function prettyCurrency(type: string): string {
|
||||
switch (type) {
|
||||
case "0":
|
||||
case "duckets":
|
||||
return "Duckets";
|
||||
case "5":
|
||||
case "diamonds":
|
||||
return "Diamonds";
|
||||
case "-1":
|
||||
case "credits":
|
||||
return "Credits";
|
||||
default:
|
||||
return type.charAt(0).toUpperCase() + type.slice(1);
|
||||
}
|
||||
}
|
||||
|
||||
export default async function RareCategoryPage({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ category: string }>;
|
||||
}) {
|
||||
const { category } = await params;
|
||||
|
||||
let categoryId: bigint;
|
||||
try {
|
||||
categoryId = BigInt(category);
|
||||
} catch {
|
||||
notFound();
|
||||
}
|
||||
|
||||
let cat: { id: bigint; name: string; badge: string } | null = null;
|
||||
try {
|
||||
cat = await prisma.websiteRareValueCategories.findUnique({
|
||||
where: { id: categoryId! },
|
||||
select: { id: true, name: true, badge: true },
|
||||
});
|
||||
} catch {
|
||||
cat = null;
|
||||
}
|
||||
|
||||
if (!cat) notFound();
|
||||
|
||||
let rares: RareRow[] = [];
|
||||
try {
|
||||
rares = await prisma.websiteRareValues.findMany({
|
||||
where: { categoryId: categoryId! },
|
||||
orderBy: { name: "asc" },
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
creditValue: true,
|
||||
currencyValue: true,
|
||||
currencyType: true,
|
||||
furnitureIcon: true,
|
||||
itemId: true,
|
||||
},
|
||||
});
|
||||
} catch {
|
||||
rares = [];
|
||||
}
|
||||
|
||||
const [iconsBase, badgesBase] = await Promise.all([
|
||||
siteSettings.get("furniture_icons_path", ""),
|
||||
siteSettings.get("badges_path", ""),
|
||||
]);
|
||||
const iconBase = iconsBase ?? "";
|
||||
const badgeBase = badgesBase ?? "";
|
||||
const badgeSrc = badgeBase && cat.badge ? `${badgeBase}/${cat.badge}.gif` : "";
|
||||
|
||||
return (
|
||||
<main>
|
||||
<p style={{ margin: "0 0 0.75rem" }}>
|
||||
<Link href="/rares">← All rares</Link>
|
||||
</p>
|
||||
|
||||
<div
|
||||
className="hero"
|
||||
style={{ display: "flex", alignItems: "center", gap: "1rem" }}
|
||||
>
|
||||
{badgeSrc ? (
|
||||
// eslint-disable-next-line @next/next/no-img-element
|
||||
<img src={badgeSrc} alt={`${cat.name} badge`} width={48} height={48} />
|
||||
) : null}
|
||||
<div>
|
||||
<h1 style={{ margin: 0 }}>{cat.name}</h1>
|
||||
<p className="muted" style={{ marginBottom: 0 }}>
|
||||
{rares.length} {rares.length === 1 ? "rare" : "rares"} in this category
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{rares.length === 0 ? (
|
||||
<p className="muted">No rares listed in this category yet.</p>
|
||||
) : (
|
||||
<div className="card" style={{ padding: 0, overflowX: "auto" }}>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th style={{ width: 56 }}></th>
|
||||
<th>Rare</th>
|
||||
<th>Credits</th>
|
||||
<th>Currency</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rares.map((r) => {
|
||||
const iconSrc =
|
||||
iconBase && r.furnitureIcon ? `${iconBase}/${r.furnitureIcon}` : "";
|
||||
return (
|
||||
<tr key={String(r.id)}>
|
||||
<td>
|
||||
{iconSrc ? (
|
||||
// eslint-disable-next-line @next/next/no-img-element
|
||||
<img
|
||||
src={iconSrc}
|
||||
alt=""
|
||||
width={40}
|
||||
height={40}
|
||||
style={{ objectFit: "contain" }}
|
||||
/>
|
||||
) : (
|
||||
<span
|
||||
className="avatar"
|
||||
style={{ display: "inline-block", width: 40, height: 40 }}
|
||||
/>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
<strong>{r.name}</strong>
|
||||
</td>
|
||||
<td>
|
||||
{r.creditValue && r.creditValue !== "" ? (
|
||||
`${r.creditValue} credits`
|
||||
) : (
|
||||
<span className="muted">—</span>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
{r.currencyValue && r.currencyValue !== "" ? (
|
||||
`${r.currencyValue} ${prettyCurrency(r.currencyType)}`
|
||||
) : (
|
||||
<span className="muted">—</span>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -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