Reapply "Add missing admin action files and navigation links"

This reverts commit 4d515bc400.
This commit is contained in:
Simo committed 2026-07-11 20:52:56 +02:00
1 parent 96ed768f14
commit 5b4228261a
338 files changed
+28143 -5948

No files matched your search

+24 -19
View File
@@ -49,12 +49,8 @@ export default async function AdminVouchers() {
const usedUp = v.maxUses > 0 && v.useCount >= v.maxUses;
return !expired && !usedUp;
}).length;
const expiredCount = vouchers.filter(
(v) => v.expiresAt && v.expiresAt.getTime() <= now,
).length;
const usedUpCount = vouchers.filter(
(v) => v.maxUses > 0 && v.useCount >= v.maxUses,
).length;
const expiredCount = vouchers.filter((v) => v.expiresAt && v.expiresAt.getTime() <= now).length;
const usedUpCount = vouchers.filter((v) => v.maxUses > 0 && v.useCount >= v.maxUses).length;
return (
<main>
@@ -70,12 +66,7 @@ export default async function AdminVouchers() {
<div className="grid grid-cols-[repeat(auto-fit,minmax(180px,1fr))] gap-3.5 mb-6">
<StatusCard label={t("vouchers")} value={vouchers.length} icon="🎟️" />
<StatusCard
label={t("active")}
value={active}
state={active > 0 ? "ok" : "neutral"}
icon="✅"
/>
<StatusCard label={t("active")} value={active} state={active > 0 ? "ok" : "neutral"} icon="✅" />
<StatusCard
label={t("usedUp")}
value={usedUpCount}
@@ -110,11 +101,15 @@ export default async function AdminVouchers() {
<input name="expiresAt" type="datetime-local" />
</label>
</div>
<button type="submit" className="btn btn-primary">{t("form.create")}</button>
<button type="submit" className="btn btn-primary">
{t("form.create")}
</button>
</form>
<section className="mt-6">
<h2 className="admin-section-title">{t("title")} ({vouchers.length})</h2>
<h2 className="admin-section-title">
{t("title")} ({vouchers.length})
</h2>
<div className="admin-card">
<table>
<thead>
@@ -143,15 +138,25 @@ export default async function AdminVouchers() {
</td>
<td>
{expired ? (
<span className="inline-block text-[0.72rem] font-bold px-2 py-0.5 rounded-full bg-red-500/22 text-[var(--color-text)]">{t("statusExpired")}</span>
<span className="inline-block text-[0.72rem] font-bold px-2 py-0.5 rounded-full bg-red-500/22 text-[var(--color-text)]">
{t("statusExpired")}
</span>
) : usedUp ? (
<span className="inline-block text-[0.72rem] font-bold px-2 py-0.5 rounded-full bg-[var(--color-primary)]/18 text-[var(--color-text)]">{t("statusUsedUp")}</span>
<span className="inline-block text-[0.72rem] font-bold px-2 py-0.5 rounded-full bg-[var(--color-primary)]/18 text-[var(--color-text)]">
{t("statusUsedUp")}
</span>
) : (
<span className="inline-block text-[0.72rem] font-bold px-2 py-0.5 rounded-full bg-green-600/20 text-[var(--color-text)]">{t("statusActive")}</span>
<span className="inline-block text-[0.72rem] font-bold px-2 py-0.5 rounded-full bg-green-600/20 text-[var(--color-text)]">
{t("statusActive")}
</span>
)}
</td>
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">{fmtDate(v.expiresAt)}</td>
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">{fmtDate(v.createdAt)}</td>
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">
{fmtDate(v.expiresAt)}
</td>
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">
{fmtDate(v.createdAt)}
</td>
<td>
<form action={deleteVoucher}>
<input type="hidden" name="id" value={v.id.toString()} />