feat(admin): items_base browser and AdminPageShell on core pages
CI / check (push) Successful in 21s
Deploy / release (push) Skipped
Deploy / deploy (push) Successful in 59s
CI / deploy (push) Failing after 9s

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
SimoandCursor committed 2026-07-30 20:41:31 +02:00
1 parent 7138ae4445
commit 98613af875
42 files changed
+2196 -698

No files matched your search

+106 -98
View File
@@ -1,7 +1,9 @@
import { Store } from "lucide-react";
import Link from "next/link";
import { redirect } from "next/navigation";
import { getTranslations } from "next-intl/server";
import { cancelMarketplaceListing } from "@/actions/admin-marketplace";
import { AdminPageShell } from "@/components/admin/admin-page-shell";
import { AdminSimplePager } from "@/components/admin/admin-simple-pager";
import { StatusCard } from "@/components/admin/dashboard";
import { Button } from "@/components/ui/button";
@@ -69,109 +71,115 @@ export default async function AdminMarketplacePage({
const usernameById = new Map(users.map((u) => [u.id, u.username]));
return (
<main>
{loadError ? (
<div className="mb-4 rounded-lg bg-[var(--admin-error-subtle)] p-3 text-xs text-[var(--admin-error)]">
{t("loadError")}
<AdminPageShell icon={Store} title={t("title")} subtitle={t("subtitle")}>
<main>
{loadError ? (
<div className="mb-4 rounded-lg bg-[var(--admin-error-subtle)] p-3 text-xs text-[var(--admin-error)]">
{t("loadError")}
</div>
) : null}
<div className="mb-4 flex flex-wrap gap-2">
<Button
variant={filter === "active" ? "default" : "ghost"}
size="sm"
asChild
>
<Link href="/admin/marketplace?filter=active">
{t("filterActive")}
</Link>
</Button>
<Button
variant={filter === "sold" ? "default" : "ghost"}
size="sm"
asChild
>
<Link href="/admin/marketplace?filter=sold">{t("filterSold")}</Link>
</Button>
</div>
) : null}
<div className="mb-4 flex flex-wrap gap-2">
<Button
variant={filter === "active" ? "default" : "ghost"}
size="sm"
asChild
>
<Link href="/admin/marketplace?filter=active">
{t("filterActive")}
</Link>
</Button>
<Button
variant={filter === "sold" ? "default" : "ghost"}
size="sm"
asChild
>
<Link href="/admin/marketplace?filter=sold">{t("filterSold")}</Link>
</Button>
</div>
<div className="grid grid-cols-[repeat(auto-fit,minmax(180px,1fr))] gap-3.5 mb-6">
<StatusCard
label={t("activeListings")}
value={activeCount}
icon="🏪"
/>
<StatusCard label={t("soldListings")} value={soldCount} icon="✅" />
</div>
<div className="grid grid-cols-[repeat(auto-fit,minmax(180px,1fr))] gap-3.5 mb-6">
<StatusCard label={t("activeListings")} value={activeCount} icon="🏪" />
<StatusCard label={t("soldListings")} value={soldCount} icon="✅" />
</div>
<section>
<h2 className="admin-section-title">
{filter === "sold" ? t("soldListings") : t("activeListings")} ({total}
)
</h2>
{rows.length === 0 ? (
<div className="admin-empty">{t("empty")}</div>
) : (
<div className="admin-card overflow-x-auto" style={{ padding: 0 }}>
<table>
<thead>
<tr>
<th>{t("colId")}</th>
<th>{t("colItem")}</th>
<th>{t("colSeller")}</th>
<th>{t("colPrice")}</th>
<th>{t("colListed")}</th>
{filter === "sold" ? <th>{t("colSold")}</th> : null}
{canEdit && filter === "active" ? (
<th>{t("colActions")}</th>
) : null}
</tr>
</thead>
<tbody>
{rows.map((row) => (
<tr key={row.id}>
<td className="muted">{row.id}</td>
<td>
<code>{row.itemId}</code>
</td>
<td>
<Link href={`/admin/users/show/${row.userId}`}>
{usernameById.get(row.userId) ?? `#${row.userId}`}
</Link>
</td>
<td>{row.price}</td>
<td className="muted">
{formatDate(new Date(row.timestamp * 1000))}
</td>
{filter === "sold" ? (
<td className="muted">
{formatDate(
row.soldTimestamp
? new Date(row.soldTimestamp * 1000)
: null,
)}
</td>
) : null}
<section>
<h2 className="admin-section-title">
{filter === "sold" ? t("soldListings") : t("activeListings")} (
{total})
</h2>
{rows.length === 0 ? (
<div className="admin-empty">{t("empty")}</div>
) : (
<div className="admin-card overflow-x-auto" style={{ padding: 0 }}>
<table>
<thead>
<tr>
<th>{t("colId")}</th>
<th>{t("colItem")}</th>
<th>{t("colSeller")}</th>
<th>{t("colPrice")}</th>
<th>{t("colListed")}</th>
{filter === "sold" ? <th>{t("colSold")}</th> : null}
{canEdit && filter === "active" ? (
<td>
<form action={cancelMarketplaceListing}>
<input type="hidden" name="id" value={row.id} />
<Button type="submit" variant="ghost" size="sm">
{t("cancel")}
</Button>
</form>
</td>
<th>{t("colActions")}</th>
) : null}
</tr>
))}
</tbody>
</table>
</div>
)}
<AdminSimplePager
page={pagination.page}
lastPage={pagination.lastPage}
total={total}
basePath="/admin/marketplace"
params={filter === "sold" ? { filter: "sold" } : undefined}
/>
</section>
</main>
</thead>
<tbody>
{rows.map((row) => (
<tr key={row.id}>
<td className="muted">{row.id}</td>
<td>
<code>{row.itemId}</code>
</td>
<td>
<Link href={`/admin/users/show/${row.userId}`}>
{usernameById.get(row.userId) ?? `#${row.userId}`}
</Link>
</td>
<td>{row.price}</td>
<td className="muted">
{formatDate(new Date(row.timestamp * 1000))}
</td>
{filter === "sold" ? (
<td className="muted">
{formatDate(
row.soldTimestamp
? new Date(row.soldTimestamp * 1000)
: null,
)}
</td>
) : null}
{canEdit && filter === "active" ? (
<td>
<form action={cancelMarketplaceListing}>
<input type="hidden" name="id" value={row.id} />
<Button type="submit" variant="ghost" size="sm">
{t("cancel")}
</Button>
</form>
</td>
) : null}
</tr>
))}
</tbody>
</table>
</div>
)}
<AdminSimplePager
page={pagination.page}
lastPage={pagination.lastPage}
total={total}
basePath="/admin/marketplace"
params={filter === "sold" ? { filter: "sold" } : undefined}
/>
</section>
</main>
</AdminPageShell>
);
}