feat: Wabenhain Honig-Shop Anwendung

Vollstaendige Next.js/Prisma-E-Commerce-Anwendung fuer eine Imkerei:
Shop, Warenkorb, Stripe-Checkout, Kundenkonto mit 2FA, Admin-Bereich
(Produkte, Ernten, Chargen, Bestellungen, Gutscheine, admin-editierbare
Website-Inhalte), i18n (DE/EN), Rate-Limiting/CSP/Audit-Log-Haertung,
PostgreSQL- und MySQL-Unterstuetzung ueber austauschbare Prisma-
Treiber-Adapter, Unit-/Komponenten-/E2E-Tests.
This commit is contained in:
Nick Szaunig committed 2026-08-17 14:30:28 +02:00
1 parent 5c76fcc266
commit c7927f2883
240 files changed
+26096 -137

No files matched your search

+110
View File
@@ -0,0 +1,110 @@
import Link from "next/link";
import { prisma } from "@/lib/prisma";
import { BackLink } from "@/components/back-link";
import { formatDate } from "@/lib/format";
import { createBatchAction } from "../actions";
import { getLocale } from "@/i18n/locale";
import { getDictionary } from "@/i18n/get-dictionary";
export default async function AdminBatchesPage() {
const t = getDictionary(await getLocale());
const [batches, harvests] = await Promise.all([
prisma.batch.findMany({
orderBy: { fillDate: "desc" },
include: { harvest: true },
}),
prisma.harvest.findMany({ orderBy: [{ year: "desc" }] }),
]);
return (
<div>
<BackLink href="/admin" label={t.adminBatchesPage.backToDashboard} />
<h1 className="text-2xl text-forest mb-8">{t.adminBatchesPage.title}</h1>
<div className="overflow-x-auto bg-background border border-ink/10">
<table className="w-full text-sm">
<thead className="text-left text-ink/65 border-b border-ink/10">
<tr>
<th className="p-4">{t.adminBatchesPage.colBatch}</th>
<th className="p-4">{t.adminBatchesPage.colHarvest}</th>
<th className="p-4">{t.adminBatchesPage.colFillDate}</th>
<th className="p-4">{t.adminBatchesPage.colBestBefore}</th>
<th className="p-4">{t.adminBatchesPage.colTotalGlasses}</th>
<th className="p-4">{t.adminBatchesPage.colRemaining}</th>
<th className="p-4" />
</tr>
</thead>
<tbody className="divide-y divide-ink/10">
{batches.map((batch) => (
<tr key={batch.id} className="transition-colors hover:bg-ink/[0.03]">
<td className="p-4 text-forest">{batch.code}</td>
<td className="p-4">
{batch.harvest.type} {batch.harvest.year}
</td>
<td className="p-4">{formatDate(batch.fillDate)}</td>
<td className="p-4">{formatDate(batch.bestBeforeDate)}</td>
<td className="p-4">{batch.glassCount}</td>
<td className="p-4">{batch.remainingGlasses}</td>
<td className="p-4">
<Link href={`/admin/chargen/${batch.id}`} className="text-forest underline">
{t.adminBatchesPage.edit}
</Link>
</td>
</tr>
))}
</tbody>
</table>
{batches.length === 0 ? <p className="p-6 text-ink/65">{t.adminBatchesPage.noBatchesYet}</p> : null}
</div>
<div className="mt-10 bg-background border border-ink/10 p-6 max-w-xl">
<h2 className="text-lg text-forest mb-4">{t.adminBatchesPage.newBatchHeading}</h2>
<form action={createBatchAction} className="space-y-4">
<div className="grid grid-cols-2 gap-4">
<label className="block text-sm">
<span className="text-ink/70">{t.adminBatchesPage.codeLabel}</span>
<input
name="code"
required
placeholder={t.adminBatchesPage.codePlaceholder}
className="mt-1 w-full border border-ink/20 bg-background px-3 py-2"
/>
</label>
<label className="block text-sm">
<span className="text-ink/70">{t.adminBatchesPage.harvestLabel}</span>
<select name="harvestId" required className="mt-1 w-full border border-ink/20 bg-background px-3 py-2">
{harvests.map((h) => (
<option key={h.id} value={h.id}>
{h.type} {h.year}
</option>
))}
</select>
</label>
</div>
<div className="grid grid-cols-2 gap-4">
<label className="block text-sm">
<span className="text-ink/70">{t.adminBatchesPage.fillDateLabel}</span>
<input name="fillDate" type="date" required className="mt-1 w-full border border-ink/20 bg-background px-3 py-2" />
</label>
<label className="block text-sm">
<span className="text-ink/70">{t.adminBatchesPage.bestBeforeDateLabel}</span>
<input name="bestBeforeDate" type="date" required className="mt-1 w-full border border-ink/20 bg-background px-3 py-2" />
</label>
</div>
<div className="grid grid-cols-2 gap-4">
<label className="block text-sm">
<span className="text-ink/70">{t.adminBatchesPage.glassCountLabel}</span>
<input name="glassCount" type="number" required className="mt-1 w-full border border-ink/20 bg-background px-3 py-2" />
</label>
<label className="block text-sm">
<span className="text-ink/70">{t.adminBatchesPage.remainingGlassesLabel}</span>
<input name="remainingGlasses" type="number" required className="mt-1 w-full border border-ink/20 bg-background px-3 py-2" />
</label>
</div>
<button type="submit" className="bg-forest text-cream px-6 py-2 text-sm">
{t.adminBatchesPage.create}
</button>
</form>
</div>
</div>
);
}