import Link from "next/link"; import { getTranslations } from "next-intl/server"; import { StatusCard } from "@/components/admin/dashboard"; import { prisma } from "@/lib/prisma"; import { Package } from "lucide-react"; export const dynamic = "force-dynamic"; type CatalogPageRow = { id: number; caption: string; parentId: number; pageLayout: string; minRank: number; orderNum: number; visible: string; enabled: string; }; export default async function AdminCatalog() { const t = await getTranslations("pages.admin.catalog"); let pages: CatalogPageRow[] = []; try { pages = await prisma.catalogPages.findMany({ select: { id: true, caption: true, parentId: true, pageLayout: true, minRank: true, orderNum: true, visible: true, enabled: true, }, orderBy: [{ parentId: "asc" }, { orderNum: "asc" }, { id: "asc" }], take: 500, }); } catch { pages = []; } const captionById = new Map(); for (const p of pages) captionById.set(p.id, p.caption); const visibleCount = pages.filter( (p) => p.visible === "1" && p.enabled === "1", ).length; const hiddenCount = pages.length - visibleCount; const rootCount = pages.filter((p) => p.parentId <= 0).length; return (

{t("title")}

{t("subtitle")}

0 ? "warn" : "neutral"} icon="🚫" />

{t("pages")} ({pages.length})

{pages.length === 0 ? (

{t("noPages")}

) : (
{pages.map((p) => { const parentName = p.parentId > 0 ? captionById.get(p.parentId) : null; const hidden = p.visible !== "1" || p.enabled !== "1"; return ( ); })}
{t("colId")} {t("caption")} {t("colParent")} {t("colLayout")} {t("colMinRank")} {t("colOrder")} {t("colStatus")}
{p.id} {p.caption} {p.parentId <= 0 ? "—" : parentName ? `${parentName} (#${p.parentId})` : `#${p.parentId}`} {p.pageLayout} {p.minRank} {p.orderNum} {hidden ? t("statusHidden") : t("statusVisible")}
)}
); }