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>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user