import Link from "next/link"; import { getTranslations } from "next-intl/server"; import { StatusCard } from "@/components/admin/dashboard"; import { prisma } from "@/lib/prisma"; export const dynamic = "force-dynamic"; const PAID_STATUS = new Set(["completed", "paid", "success", "approved"]); function statusState(status: string | null | undefined): "ok" | "danger" | undefined { if (!status) return undefined; const s = status.toLowerCase(); if (PAID_STATUS.has(s)) return "ok"; if (s === "failed" || s === "denied" || s === "refunded" || s === "cancelled" || s === "canceled") return "danger"; return undefined; } export default async function AdminShop() { const t = await getTranslations("pages.admin.shop"); let packages: Awaited> = []; try { packages = await prisma.websiteShopArticles.findMany({ orderBy: [{ position: "asc" }, { name: "asc" }], take: 500, }); } catch { packages = []; } let orders: Awaited> = []; try { orders = await prisma.websitePaypalTransactions.findMany({ orderBy: { createdAt: "desc" }, take: 50, }); } catch { orders = []; } const paidOrders = orders.filter((o) => statusState(o.status) === "ok").length; return (

{t("title")}

{t("newPackage")}

{t("subtitle")} (website_shop_articles). {t("tableHint")}

0 ? "ok" : "neutral"} icon="๐Ÿ’ณ" />

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

{packages.length === 0 ? (

{t("noPackages")}

) : (
{packages.map((p) => ( ))}
# {t("colName")} {t("colPrice")} {t("colCredits")} {t("colDuckets")} {t("colDiamonds")} {t("colRank")} {t("colPosition")}
{String(p.id)} {p.name} {p.costs} {p.credits ?? "โ€”"} {p.duckets ?? "โ€”"} {p.diamonds ?? "โ€”"} {p.giveRank ?? "โ€”"} {p.position}
)}

{t("recentOrders")} ({orders.length})

{t("ordersHint")} (website_paypal_transactions).

{orders.length === 0 ? (

{t("noOrders")}

) : (
{orders.map((o) => { const state = statusState(o.status); return ( ); })}
{t("colTransaction")} {t("colUser")} {t("colDescription")} {t("colAmount")} {t("colStatus")} {t("colDate")}
{o.transactionId} {o.userId} {o.description ?? "โ€”"} {o.amount} {o.currency} {o.status ? ( {o.status} ) : ( โ€” )} {o.createdAt ? o.createdAt.toISOString().slice(0, 10) : "โ€”"}
)}
); }