import Link from "next/link"; import { getTranslations } from "next-intl/server"; import { notFound } from "next/navigation"; import { prisma } from "@/lib/prisma"; export const dynamic = "force-dynamic"; type CatalogPageRow = { id: number; caption: string; parentId: number; pageLayout: string; minRank: number; visible: string; enabled: string; clubOnly: string; vipOnly: string; }; type CatalogItemRow = { id: number; catalogName: string; itemIds: string; amount: number; costCredits: number; costPoints: number; pointsType: number; limitedStack: number; limitedSells: number; orderNumber: number; clubOnly: string; }; export default async function AdminCatalogPage({ params, }: { params: Promise<{ id: string }>; }) { const t = await getTranslations("pages.admin.catalog"); const { id } = await params; const pageId = Number(id); if (!Number.isInteger(pageId)) notFound(); let page: CatalogPageRow | null = null; try { page = await prisma.catalogPages.findUnique({ where: { id: pageId }, select: { id: true, caption: true, parentId: true, pageLayout: true, minRank: true, visible: true, enabled: true, clubOnly: true, vipOnly: true, }, }); } catch { page = null; } if (!page) notFound(); let items: CatalogItemRow[] = []; try { items = await prisma.catalogItems.findMany({ where: { pageId }, select: { id: true, catalogName: true, itemIds: true, amount: true, costCredits: true, costPoints: true, pointsType: true, limitedStack: true, limitedSells: true, orderNumber: true, clubOnly: true, }, orderBy: [{ orderNumber: "asc" }, { id: "asc" }], take: 500, }); } catch { items = []; } const hidden = page.visible !== "1" || page.enabled !== "1"; return (

← {t("title")}

{page.caption}

{t("pageLabel", { id: page.id })} · {t("layoutLabel", { layout: page.pageLayout })} · {t("minRankLabel", { rank: page.minRank })} ·{" "} {hidden ? t("statusHidden") : t("statusVisible")} {page.parentId > 0 ? ` · ${t("parentLabel", { id: page.parentId })}` : ""} {page.clubOnly === "1" ? ` · ${t("hcOnly")}` : ""} {page.vipOnly === "1" ? ` · ${t("vipOnly")}` : ""}

{t("items")}

{items.length === 0 ? (

{t("noItems")}

) : ( {items.map((it) => ( ))}
{t("colId")} {t("catalogName")} {t("itemIds")} {t("amount")} {t("colCostCredits")} {t("colCostPoints")} {t("colLimited")} {t("colOrder")}
{it.id} {it.catalogName} {it.clubOnly === "1" ? ( · {t("hc")} ) : null} {it.itemIds} {it.amount} {it.costCredits > 0 ? ( {it.costCredits} ) : ( — )} {it.costPoints > 0 ? `${it.costPoints} (${t("typeLabel", { type: it.pointsType })})` : "—"} {it.limitedStack > 0 ? `${it.limitedSells}/${it.limitedStack}` : "—"} {it.orderNumber}
)}

{t("itemCount", { count: items.length })}

); }