Decouple admin from public max-w-7xl via (site) route group.

Public chrome and width live only under (site). /admin and /client inherit the root layout alone, so housekeeping width is no longer tied to the public template.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
SimoandCursor committed 2026-07-15 21:12:52 +02:00
1 parent a1dc7ff0a7
commit 367f69a439
60 files changed
+29 -30

No files matched your search

+194
View File
@@ -0,0 +1,194 @@
import Link from "next/link";
import { notFound } from "next/navigation";
import { getTranslations } from "next-intl/server";
import { ContentCard, EmptyState } from "@/components/public/ui";
import { prisma } from "@/lib/prisma";
import { siteSettings } from "@/lib/services/site-settings";
export const revalidate = 300;
type RareRow = {
id: bigint;
name: string;
creditValue: string | null;
currencyValue: string | null;
currencyType: string;
furnitureIcon: string;
itemId: number | null;
};
type CurrencyTranslator = (key: string) => string;
function prettyCurrency(type: string, t: CurrencyTranslator): string {
switch (type) {
case "0":
case "duckets":
return t("duckets");
case "5":
case "diamonds":
return t("diamonds");
case "-1":
case "credits":
return t("credits");
default:
return type.charAt(0).toUpperCase() + type.slice(1);
}
}
export default async function RareCategoryPage({
params,
}: {
params: Promise<{ category: string }>;
}) {
const t = await getTranslations("pages.rareCategory");
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 style={{ display: "grid", gap: "1.5rem" }}>
<ContentCard
icon={badgeSrc ? undefined : "💎"}
title={
<span
style={{
display: "inline-flex",
alignItems: "center",
gap: "0.6rem",
}}
>
{badgeSrc ? (
// eslint-disable-next-line @next/next/no-img-element
<img
src={badgeSrc}
alt={`${cat.name} badge`}
width={32}
height={32}
/>
) : null}
{cat.name}
</span>
}
subtitle={t("rareCount", { count: rares.length })}
action={
<Link className="btn btn-outline" href="/rares">
{t("allRares")}
</Link>
}
padded={rares.length === 0}
>
{rares.length === 0 ? (
<EmptyState icon="💎">{t("empty")}</EmptyState>
) : (
<div style={{ padding: "0.25rem 1rem 0.75rem", overflowX: "auto" }}>
<table>
<thead>
<tr>
<th style={{ width: 56 }}></th>
<th>{t("colRare")}</th>
<th>{t("colCredits")}</th>
<th>{t("colCurrency")}</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 !== "" ? (
t("creditsValue", { value: r.creditValue })
) : (
<span className="muted">—</span>
)}
</td>
<td>
{r.currencyValue && r.currencyValue !== "" ? (
`${r.currencyValue} ${prettyCurrency(r.currencyType, t)}`
) : (
<span className="muted">—</span>
)}
</td>
</tr>
);
})}
</tbody>
</table>
</div>
)}
</ContentCard>
</main>
);
}
+100
View File
@@ -0,0 +1,100 @@
import Link from "next/link";
import { getTranslations } from "next-intl/server";
import { ContentCard, EmptyState } from "@/components/public/ui";
import { prisma } from "@/lib/prisma";
import { siteSettings } from "@/lib/services/site-settings";
export const revalidate = 300;
export const metadata = { title: "Rare values" };
type CategoryRow = {
id: bigint;
name: string;
badge: string;
priority: number;
};
export default async function RareValuesPage() {
const t = await getTranslations("pages.rares");
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 style={{ display: "grid", gap: "1.5rem" }}>
<ContentCard icon="💎" title={t("title")} subtitle={t("subtitle")} />
{categories.length === 0 ? (
<ContentCard padded={false}>
<EmptyState icon="💎">{t("empty")}</EmptyState>
</ContentCard>
) : (
<div className="card-grid sm-2 lg-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="content-card hover-lift"
style={{ color: "inherit", textDecoration: "none" }}
>
<div className="content-card-head">
{badgeSrc ? (
// eslint-disable-next-line @next/next/no-img-element
<img
src={badgeSrc}
alt={`${c.name} badge`}
width={36}
height={36}
style={{ flexShrink: 0 }}
/>
) : (
<span className="content-card-icon" aria-hidden>
💎
</span>
)}
<div className="content-card-head-text">
<p className="content-card-title">{c.name}</p>
<p className="content-card-subtitle">
{t("rareCount", { count })}
</p>
</div>
</div>
<div className="content-card-body">
<span className="btn btn-outline">{t("viewRares")}</span>
</div>
</Link>
);
})}
</div>
)}
</main>
);
}