This commit is contained in:
1 parent
8efd032cc6
commit
df38dccbf1
735 files changed
+128321
-120870
No files matched your search
+140
-131
@@ -1,142 +1,151 @@
|
||||
import { Package } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { notFound } from "next/navigation";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { deleteShopArticle, updateShopArticle } from "@/actions/admin-shop";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
import { Package } from "lucide-react";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export default async function EditShopArticle({ params }: { params: Promise<{ id: string }> }) {
|
||||
const t = await getTranslations("pages.admin.shop");
|
||||
export default async function EditShopArticle({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ id: string }>;
|
||||
}) {
|
||||
const t = await getTranslations("pages.admin.shop");
|
||||
|
||||
const { id } = await params;
|
||||
let pkg: Awaited<ReturnType<typeof prisma.websiteShopArticles.findUnique>> = null;
|
||||
try {
|
||||
pkg = await prisma.websiteShopArticles.findUnique({ where: { id: BigInt(id) } });
|
||||
} catch {
|
||||
notFound();
|
||||
}
|
||||
if (!pkg) notFound();
|
||||
const { id } = await params;
|
||||
let pkg: Awaited<ReturnType<typeof prisma.websiteShopArticles.findUnique>> =
|
||||
null;
|
||||
try {
|
||||
pkg = await prisma.websiteShopArticles.findUnique({
|
||||
where: { id: BigInt(id) },
|
||||
});
|
||||
} catch {
|
||||
notFound();
|
||||
}
|
||||
if (!pkg) notFound();
|
||||
|
||||
return (
|
||||
<main>
|
||||
<div className="flex items-center gap-3 mb-6">
|
||||
<div className="w-10 h-10 rounded-xl bg-gradient-to-br from-[var(--admin-accent)]/20 to-[var(--admin-accent)]/5 grid place-items-center">
|
||||
<Package size={20} className="text-[var(--admin-accent)]" />
|
||||
</div>
|
||||
<div>
|
||||
<h1 className="m-0 text-xl font-extrabold text-[var(--admin-text)]">{t("editPackageTitle")}</h1>
|
||||
<Link
|
||||
href="/admin/shop"
|
||||
className="text-xs text-[var(--admin-text-muted)] hover:text-[var(--admin-accent)]"
|
||||
>
|
||||
← {t("backToShop")}
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
return (
|
||||
<main>
|
||||
<div className="flex items-center gap-3 mb-6">
|
||||
<div className="w-10 h-10 rounded-xl bg-gradient-to-br from-[var(--admin-accent)]/20 to-[var(--admin-accent)]/5 grid place-items-center">
|
||||
<Package size={20} className="text-[var(--admin-accent)]" />
|
||||
</div>
|
||||
<div>
|
||||
<h1 className="m-0 text-xl font-extrabold text-[var(--admin-text)]">
|
||||
{t("editPackageTitle")}
|
||||
</h1>
|
||||
<Link
|
||||
href="/admin/shop"
|
||||
className="text-xs text-[var(--admin-text-muted)] hover:text-[var(--admin-accent)]"
|
||||
>
|
||||
← {t("backToShop")}
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form action={updateShopArticle} className="admin-card">
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<input type="hidden" name="id" value={String(pkg.id)} />
|
||||
<input
|
||||
name="name"
|
||||
defaultValue={pkg.name}
|
||||
placeholder={t("form.namePlaceholder")}
|
||||
required
|
||||
maxLength={255}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="info"
|
||||
defaultValue={pkg.info}
|
||||
placeholder={t("form.infoPlaceholder")}
|
||||
maxLength={255}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="icon"
|
||||
defaultValue={pkg.iconUrl}
|
||||
placeholder={t("form.iconPlaceholder")}
|
||||
maxLength={255}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="color"
|
||||
defaultValue={pkg.color}
|
||||
placeholder={t("form.colorPlaceholder")}
|
||||
maxLength={255}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="costs"
|
||||
type="number"
|
||||
min={0}
|
||||
defaultValue={pkg.costs}
|
||||
placeholder={t("form.costsPlaceholder")}
|
||||
required
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="credits"
|
||||
type="number"
|
||||
min={0}
|
||||
defaultValue={pkg.credits ?? undefined}
|
||||
placeholder={t("form.creditsPlaceholder")}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="duckets"
|
||||
type="number"
|
||||
min={0}
|
||||
defaultValue={pkg.duckets ?? undefined}
|
||||
placeholder={t("form.ducketsPlaceholder")}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="diamonds"
|
||||
type="number"
|
||||
min={0}
|
||||
defaultValue={pkg.diamonds ?? undefined}
|
||||
placeholder={t("form.diamondsPlaceholder")}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="giveRank"
|
||||
type="number"
|
||||
min={0}
|
||||
defaultValue={pkg.giveRank ?? undefined}
|
||||
placeholder={t("form.giveRankPlaceholder")}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="badges"
|
||||
defaultValue={pkg.badges ?? ""}
|
||||
placeholder={t("form.badgesPlaceholder")}
|
||||
maxLength={255}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="position"
|
||||
type="number"
|
||||
min={0}
|
||||
defaultValue={pkg.position}
|
||||
placeholder={t("form.positionPlaceholder")}
|
||||
className="w-full"
|
||||
/>
|
||||
</div>
|
||||
<div className="mt-6 flex gap-2">
|
||||
<button type="submit" className="btn btn-primary">
|
||||
{t("form.save")}
|
||||
</button>
|
||||
<form action={deleteShopArticle}>
|
||||
<input type="hidden" name="id" value={String(pkg.id)} />
|
||||
<button type="submit" className="btn btn-danger">
|
||||
{t("form.deletePackage")}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</form>
|
||||
</main>
|
||||
);
|
||||
<form action={updateShopArticle} className="admin-card">
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<input type="hidden" name="id" value={String(pkg.id)} />
|
||||
<input
|
||||
name="name"
|
||||
defaultValue={pkg.name}
|
||||
placeholder={t("form.namePlaceholder")}
|
||||
required
|
||||
maxLength={255}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="info"
|
||||
defaultValue={pkg.info}
|
||||
placeholder={t("form.infoPlaceholder")}
|
||||
maxLength={255}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="icon"
|
||||
defaultValue={pkg.iconUrl}
|
||||
placeholder={t("form.iconPlaceholder")}
|
||||
maxLength={255}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="color"
|
||||
defaultValue={pkg.color}
|
||||
placeholder={t("form.colorPlaceholder")}
|
||||
maxLength={255}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="costs"
|
||||
type="number"
|
||||
min={0}
|
||||
defaultValue={pkg.costs}
|
||||
placeholder={t("form.costsPlaceholder")}
|
||||
required
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="credits"
|
||||
type="number"
|
||||
min={0}
|
||||
defaultValue={pkg.credits ?? undefined}
|
||||
placeholder={t("form.creditsPlaceholder")}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="duckets"
|
||||
type="number"
|
||||
min={0}
|
||||
defaultValue={pkg.duckets ?? undefined}
|
||||
placeholder={t("form.ducketsPlaceholder")}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="diamonds"
|
||||
type="number"
|
||||
min={0}
|
||||
defaultValue={pkg.diamonds ?? undefined}
|
||||
placeholder={t("form.diamondsPlaceholder")}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="giveRank"
|
||||
type="number"
|
||||
min={0}
|
||||
defaultValue={pkg.giveRank ?? undefined}
|
||||
placeholder={t("form.giveRankPlaceholder")}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="badges"
|
||||
defaultValue={pkg.badges ?? ""}
|
||||
placeholder={t("form.badgesPlaceholder")}
|
||||
maxLength={255}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="position"
|
||||
type="number"
|
||||
min={0}
|
||||
defaultValue={pkg.position}
|
||||
placeholder={t("form.positionPlaceholder")}
|
||||
className="w-full"
|
||||
/>
|
||||
</div>
|
||||
<div className="mt-6 flex gap-2">
|
||||
<button type="submit" className="btn btn-primary">
|
||||
{t("form.save")}
|
||||
</button>
|
||||
<form action={deleteShopArticle}>
|
||||
<input type="hidden" name="id" value={String(pkg.id)} />
|
||||
<button type="submit" className="btn btn-danger">
|
||||
{t("form.deletePackage")}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</form>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
+106
-84
@@ -1,92 +1,114 @@
|
||||
import { Package } from "lucide-react";
|
||||
import Link from "next/link";
|
||||
import { getTranslations } from "next-intl/server";
|
||||
import { createShopArticle } from "@/actions/admin-shop";
|
||||
import { Package } from "lucide-react";
|
||||
|
||||
export default async function NewShopArticle() {
|
||||
const t = await getTranslations("pages.admin.shop");
|
||||
const t = await getTranslations("pages.admin.shop");
|
||||
|
||||
return (
|
||||
<main>
|
||||
<div className="flex items-center gap-3 mb-6">
|
||||
<div className="w-10 h-10 rounded-xl bg-gradient-to-br from-[var(--admin-accent)]/20 to-[var(--admin-accent)]/5 grid place-items-center">
|
||||
<Package size={20} className="text-[var(--admin-accent)]" />
|
||||
</div>
|
||||
<div>
|
||||
<h1 className="m-0 text-xl font-extrabold text-[var(--admin-text)]">{t("newPackageTitle")}</h1>
|
||||
<Link
|
||||
href="/admin/shop"
|
||||
className="text-xs text-[var(--admin-text-muted)] hover:text-[var(--admin-accent)]"
|
||||
>
|
||||
← {t("backToShop")}
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
return (
|
||||
<main>
|
||||
<div className="flex items-center gap-3 mb-6">
|
||||
<div className="w-10 h-10 rounded-xl bg-gradient-to-br from-[var(--admin-accent)]/20 to-[var(--admin-accent)]/5 grid place-items-center">
|
||||
<Package size={20} className="text-[var(--admin-accent)]" />
|
||||
</div>
|
||||
<div>
|
||||
<h1 className="m-0 text-xl font-extrabold text-[var(--admin-text)]">
|
||||
{t("newPackageTitle")}
|
||||
</h1>
|
||||
<Link
|
||||
href="/admin/shop"
|
||||
className="text-xs text-[var(--admin-text-muted)] hover:text-[var(--admin-accent)]"
|
||||
>
|
||||
← {t("backToShop")}
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form action={createShopArticle} className="admin-card">
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<input
|
||||
name="name"
|
||||
placeholder={t("form.namePlaceholder")}
|
||||
required
|
||||
maxLength={255}
|
||||
className="w-full"
|
||||
/>
|
||||
<input name="info" placeholder={t("form.infoPlaceholder")} maxLength={255} className="w-full" />
|
||||
<input name="icon" placeholder={t("form.iconPlaceholder")} maxLength={255} className="w-full" />
|
||||
<input name="color" placeholder={t("form.colorPlaceholder")} maxLength={255} className="w-full" />
|
||||
<input
|
||||
name="costs"
|
||||
type="number"
|
||||
min={0}
|
||||
placeholder={t("form.costsPlaceholder")}
|
||||
required
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="credits"
|
||||
type="number"
|
||||
min={0}
|
||||
placeholder={t("form.creditsPlaceholder")}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="duckets"
|
||||
type="number"
|
||||
min={0}
|
||||
placeholder={t("form.ducketsPlaceholder")}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="diamonds"
|
||||
type="number"
|
||||
min={0}
|
||||
placeholder={t("form.diamondsPlaceholder")}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="giveRank"
|
||||
type="number"
|
||||
min={0}
|
||||
placeholder={t("form.giveRankPlaceholder")}
|
||||
className="w-full"
|
||||
/>
|
||||
<input name="badges" placeholder={t("form.badgesPlaceholder")} maxLength={255} className="w-full" />
|
||||
<input
|
||||
name="position"
|
||||
type="number"
|
||||
min={0}
|
||||
placeholder={t("form.positionPlaceholder")}
|
||||
defaultValue={0}
|
||||
className="w-full"
|
||||
/>
|
||||
</div>
|
||||
<div className="mt-6 text-right">
|
||||
<button type="submit" className="btn btn-primary">
|
||||
{t("form.create")}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</main>
|
||||
);
|
||||
<form action={createShopArticle} className="admin-card">
|
||||
<div className="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||
<input
|
||||
name="name"
|
||||
placeholder={t("form.namePlaceholder")}
|
||||
required
|
||||
maxLength={255}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="info"
|
||||
placeholder={t("form.infoPlaceholder")}
|
||||
maxLength={255}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="icon"
|
||||
placeholder={t("form.iconPlaceholder")}
|
||||
maxLength={255}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="color"
|
||||
placeholder={t("form.colorPlaceholder")}
|
||||
maxLength={255}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="costs"
|
||||
type="number"
|
||||
min={0}
|
||||
placeholder={t("form.costsPlaceholder")}
|
||||
required
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="credits"
|
||||
type="number"
|
||||
min={0}
|
||||
placeholder={t("form.creditsPlaceholder")}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="duckets"
|
||||
type="number"
|
||||
min={0}
|
||||
placeholder={t("form.ducketsPlaceholder")}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="diamonds"
|
||||
type="number"
|
||||
min={0}
|
||||
placeholder={t("form.diamondsPlaceholder")}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="giveRank"
|
||||
type="number"
|
||||
min={0}
|
||||
placeholder={t("form.giveRankPlaceholder")}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="badges"
|
||||
placeholder={t("form.badgesPlaceholder")}
|
||||
maxLength={255}
|
||||
className="w-full"
|
||||
/>
|
||||
<input
|
||||
name="position"
|
||||
type="number"
|
||||
min={0}
|
||||
placeholder={t("form.positionPlaceholder")}
|
||||
defaultValue={0}
|
||||
className="w-full"
|
||||
/>
|
||||
</div>
|
||||
<div className="mt-6 text-right">
|
||||
<button type="submit" className="btn btn-primary">
|
||||
{t("form.create")}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
+164
-146
@@ -7,160 +7,178 @@ 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;
|
||||
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");
|
||||
const t = await getTranslations("pages.admin.shop");
|
||||
|
||||
let packages: Awaited<ReturnType<typeof prisma.websiteShopArticles.findMany>> = [];
|
||||
try {
|
||||
packages = await prisma.websiteShopArticles.findMany({
|
||||
orderBy: [{ position: "asc" }, { name: "asc" }],
|
||||
take: 500,
|
||||
});
|
||||
} catch {
|
||||
packages = [];
|
||||
}
|
||||
let packages: Awaited<
|
||||
ReturnType<typeof prisma.websiteShopArticles.findMany>
|
||||
> = [];
|
||||
try {
|
||||
packages = await prisma.websiteShopArticles.findMany({
|
||||
orderBy: [{ position: "asc" }, { name: "asc" }],
|
||||
take: 500,
|
||||
});
|
||||
} catch {
|
||||
packages = [];
|
||||
}
|
||||
|
||||
let orders: Awaited<ReturnType<typeof prisma.websitePaypalTransactions.findMany>> = [];
|
||||
try {
|
||||
orders = await prisma.websitePaypalTransactions.findMany({
|
||||
orderBy: { createdAt: "desc" },
|
||||
take: 50,
|
||||
});
|
||||
} catch {
|
||||
orders = [];
|
||||
}
|
||||
let orders: Awaited<
|
||||
ReturnType<typeof prisma.websitePaypalTransactions.findMany>
|
||||
> = [];
|
||||
try {
|
||||
orders = await prisma.websitePaypalTransactions.findMany({
|
||||
orderBy: { createdAt: "desc" },
|
||||
take: 50,
|
||||
});
|
||||
} catch {
|
||||
orders = [];
|
||||
}
|
||||
|
||||
const paidOrders = orders.filter((o) => statusState(o.status) === "ok").length;
|
||||
const paidOrders = orders.filter(
|
||||
(o) => statusState(o.status) === "ok",
|
||||
).length;
|
||||
|
||||
return (
|
||||
<main>
|
||||
<div style={{ display: "flex", alignItems: "center", gap: "1rem" }}>
|
||||
<h1 style={{ flex: 1 }}>{t("title")}</h1>
|
||||
<Link href="/admin/shop/new" className="btn btn-primary">
|
||||
{t("newPackage")}
|
||||
</Link>
|
||||
</div>
|
||||
<p className="muted" style={{ marginTop: "-0.4rem" }}>
|
||||
{t("subtitle")} (<code>website_shop_articles</code>). {t("tableHint")}
|
||||
</p>
|
||||
return (
|
||||
<main>
|
||||
<div style={{ display: "flex", alignItems: "center", gap: "1rem" }}>
|
||||
<h1 style={{ flex: 1 }}>{t("title")}</h1>
|
||||
<Link href="/admin/shop/new" className="btn btn-primary">
|
||||
{t("newPackage")}
|
||||
</Link>
|
||||
</div>
|
||||
<p className="muted" style={{ marginTop: "-0.4rem" }}>
|
||||
{t("subtitle")} (<code>website_shop_articles</code>). {t("tableHint")}
|
||||
</p>
|
||||
|
||||
<div className="grid grid-cols-[repeat(auto-fit,minmax(180px,1fr))] gap-3.5 mb-6">
|
||||
<StatusCard label={t("packages")} value={packages.length} icon="🛍️" />
|
||||
<StatusCard label={t("recentOrders")} value={orders.length} icon="🧾" />
|
||||
<StatusCard
|
||||
label={t("paidOrders")}
|
||||
value={paidOrders}
|
||||
state={paidOrders > 0 ? "ok" : "neutral"}
|
||||
icon="💳"
|
||||
/>
|
||||
</div>
|
||||
<div className="grid grid-cols-[repeat(auto-fit,minmax(180px,1fr))] gap-3.5 mb-6">
|
||||
<StatusCard label={t("packages")} value={packages.length} icon="🛍️" />
|
||||
<StatusCard label={t("recentOrders")} value={orders.length} icon="🧾" />
|
||||
<StatusCard
|
||||
label={t("paidOrders")}
|
||||
value={paidOrders}
|
||||
state={paidOrders > 0 ? "ok" : "neutral"}
|
||||
icon="💳"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<section className="mt-6">
|
||||
<h2>
|
||||
{t("packages")} ({packages.length})
|
||||
</h2>
|
||||
{packages.length === 0 ? (
|
||||
<p className="muted">{t("noPackages")}</p>
|
||||
) : (
|
||||
<div style={{ overflowX: "auto" }}>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>{t("colName")}</th>
|
||||
<th>{t("colPrice")}</th>
|
||||
<th>{t("colCredits")}</th>
|
||||
<th>{t("colDuckets")}</th>
|
||||
<th>{t("colDiamonds")}</th>
|
||||
<th>{t("colRank")}</th>
|
||||
<th>{t("colPosition")}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{packages.map((p) => (
|
||||
<tr key={String(p.id)}>
|
||||
<td className="muted">{String(p.id)}</td>
|
||||
<td>
|
||||
<Link href={`/admin/shop/${p.id}`}>{p.name}</Link>
|
||||
</td>
|
||||
<td>{p.costs}</td>
|
||||
<td className="muted">{p.credits ?? "—"}</td>
|
||||
<td className="muted">{p.duckets ?? "—"}</td>
|
||||
<td className="muted">{p.diamonds ?? "—"}</td>
|
||||
<td className="muted">{p.giveRank ?? "—"}</td>
|
||||
<td className="muted">{p.position}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
<section className="mt-6">
|
||||
<h2>
|
||||
{t("packages")} ({packages.length})
|
||||
</h2>
|
||||
{packages.length === 0 ? (
|
||||
<p className="muted">{t("noPackages")}</p>
|
||||
) : (
|
||||
<div style={{ overflowX: "auto" }}>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th>{t("colName")}</th>
|
||||
<th>{t("colPrice")}</th>
|
||||
<th>{t("colCredits")}</th>
|
||||
<th>{t("colDuckets")}</th>
|
||||
<th>{t("colDiamonds")}</th>
|
||||
<th>{t("colRank")}</th>
|
||||
<th>{t("colPosition")}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{packages.map((p) => (
|
||||
<tr key={String(p.id)}>
|
||||
<td className="muted">{String(p.id)}</td>
|
||||
<td>
|
||||
<Link href={`/admin/shop/${p.id}`}>{p.name}</Link>
|
||||
</td>
|
||||
<td>{p.costs}</td>
|
||||
<td className="muted">{p.credits ?? "—"}</td>
|
||||
<td className="muted">{p.duckets ?? "—"}</td>
|
||||
<td className="muted">{p.diamonds ?? "—"}</td>
|
||||
<td className="muted">{p.giveRank ?? "—"}</td>
|
||||
<td className="muted">{p.position}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<section className="mt-6">
|
||||
<h2>
|
||||
{t("recentOrders")} ({orders.length})
|
||||
</h2>
|
||||
<p className="muted" style={{ marginTop: "-0.4rem" }}>
|
||||
{t("ordersHint")} (<code>website_paypal_transactions</code>).
|
||||
</p>
|
||||
{orders.length === 0 ? (
|
||||
<p className="muted">{t("noOrders")}</p>
|
||||
) : (
|
||||
<div style={{ overflowX: "auto" }}>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{t("colTransaction")}</th>
|
||||
<th>{t("colUser")}</th>
|
||||
<th>{t("colDescription")}</th>
|
||||
<th>{t("colAmount")}</th>
|
||||
<th>{t("colStatus")}</th>
|
||||
<th>{t("colDate")}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{orders.map((o) => {
|
||||
const state = statusState(o.status);
|
||||
return (
|
||||
<tr key={String(o.id)}>
|
||||
<td>
|
||||
<code>{o.transactionId}</code>
|
||||
</td>
|
||||
<td className="muted">{o.userId}</td>
|
||||
<td className="muted">{o.description ?? "—"}</td>
|
||||
<td>
|
||||
{o.amount} {o.currency}
|
||||
</td>
|
||||
<td>
|
||||
{o.status ? (
|
||||
<span
|
||||
className={`inline-block text-[0.72rem] font-bold px-2 py-0.5 rounded-full ${state === "ok" ? "bg-[var(--admin-success-subtle)] text-[var(--admin-text)]" : state === "danger" ? "bg-[var(--admin-error-subtle)] text-[var(--admin-text)]" : "bg-[var(--admin-accent)]/18 text-[var(--admin-text)]"}`}
|
||||
>
|
||||
{o.status}
|
||||
</span>
|
||||
) : (
|
||||
<span className="muted">—</span>
|
||||
)}
|
||||
</td>
|
||||
<td className="muted">{o.createdAt ? o.createdAt.toISOString().slice(0, 10) : "—"}</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
<section className="mt-6">
|
||||
<h2>
|
||||
{t("recentOrders")} ({orders.length})
|
||||
</h2>
|
||||
<p className="muted" style={{ marginTop: "-0.4rem" }}>
|
||||
{t("ordersHint")} (<code>website_paypal_transactions</code>).
|
||||
</p>
|
||||
{orders.length === 0 ? (
|
||||
<p className="muted">{t("noOrders")}</p>
|
||||
) : (
|
||||
<div style={{ overflowX: "auto" }}>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{t("colTransaction")}</th>
|
||||
<th>{t("colUser")}</th>
|
||||
<th>{t("colDescription")}</th>
|
||||
<th>{t("colAmount")}</th>
|
||||
<th>{t("colStatus")}</th>
|
||||
<th>{t("colDate")}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{orders.map((o) => {
|
||||
const state = statusState(o.status);
|
||||
return (
|
||||
<tr key={String(o.id)}>
|
||||
<td>
|
||||
<code>{o.transactionId}</code>
|
||||
</td>
|
||||
<td className="muted">{o.userId}</td>
|
||||
<td className="muted">{o.description ?? "—"}</td>
|
||||
<td>
|
||||
{o.amount} {o.currency}
|
||||
</td>
|
||||
<td>
|
||||
{o.status ? (
|
||||
<span
|
||||
className={`inline-block text-[0.72rem] font-bold px-2 py-0.5 rounded-full ${state === "ok" ? "bg-[var(--admin-success-subtle)] text-[var(--admin-text)]" : state === "danger" ? "bg-[var(--admin-error-subtle)] text-[var(--admin-text)]" : "bg-[var(--admin-accent)]/18 text-[var(--admin-text)]"}`}
|
||||
>
|
||||
{o.status}
|
||||
</span>
|
||||
) : (
|
||||
<span className="muted">—</span>
|
||||
)}
|
||||
</td>
|
||||
<td className="muted">
|
||||
{o.createdAt
|
||||
? o.createdAt.toISOString().slice(0, 10)
|
||||
: "—"}
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user