import { getTranslations } from "next-intl/server"; import Link from "next/link"; import { ContentCard, EmptyState } from "@/components/public/ui"; import { prisma } from "@/lib/prisma"; import { siteSettings } from "@/lib/services/site-settings"; export const dynamic = "force-dynamic"; 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(); 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 (
{categories.length === 0 ? ( {t("empty")} ) : (
{categories.map((c) => { const id = String(c.id); const count = counts.get(id) ?? 0; const badgeSrc = badgesBase && c.badge ? `${badgesBase}/${c.badge}.gif` : ""; return (
{badgeSrc ? ( // eslint-disable-next-line @next/next/no-img-element {`${c.name} ) : ( 💎 )}

{c.name}

{t("rareCount", { count })}

{t("viewRares")}
); })}
)}
); }