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

+82
View File
@@ -0,0 +1,82 @@
import { notFound } from "next/navigation";
import { prisma } from "@/lib/prisma";
import { BackLink } from "@/components/back-link";
import { updateShippingTierAction } from "../../actions";
import { getLocale } from "@/i18n/locale";
import { getDictionary } from "@/i18n/get-dictionary";
export default async function AdminVersandEditPage(props: PageProps<"/admin/versand/[id]">) {
const t = getDictionary(await getLocale());
const { id } = await props.params;
const { error } = await props.searchParams;
const tier = await prisma.shippingTier.findUnique({ where: { id } });
if (!tier) notFound();
return (
<div className="max-w-md">
<BackLink href="/admin/versand" label={t.adminShippingEditPage.backToShipping} />
<h1 className="text-2xl text-forest mb-8">{t.adminShippingEditPage.title}</h1>
{error ? (
<p className="mb-6 text-sm text-red-700 bg-red-50 border border-red-200 px-4 py-3">{error}</p>
) : null}
<form action={updateShippingTierAction} className="space-y-4 bg-background border border-ink/10 p-6">
<input type="hidden" name="id" value={tier.id} />
<div className="grid grid-cols-2 gap-4">
<Field
name="minQuantity"
label={t.adminShippingEditPage.minQuantityLabel}
type="number"
defaultValue={String(tier.minQuantity)}
required
/>
<Field
name="maxQuantity"
label={t.adminShippingEditPage.maxQuantityLabel}
type="number"
defaultValue={tier.maxQuantity !== null ? String(tier.maxQuantity) : ""}
/>
</div>
<Field
name="priceCents"
label={t.adminShippingEditPage.priceLabel}
type="number"
defaultValue={String(tier.priceCents)}
required
/>
<button type="submit" className="bg-forest text-cream px-6 py-2 text-sm">
{t.adminShippingEditPage.save}
</button>
</form>
</div>
);
}
function Field({
name,
label,
type = "text",
defaultValue,
required = false,
}: {
name: string;
label: string;
type?: string;
defaultValue?: string;
required?: boolean;
}) {
return (
<label className="block text-sm">
<span className="text-ink/70">{label}</span>
<input
name={name}
type={type}
defaultValue={defaultValue}
required={required}
min={0}
className="mt-1 w-full border border-ink/20 bg-background px-3 py-2"
/>
</label>
);
}
+59
View File
@@ -0,0 +1,59 @@
import { BackLink } from "@/components/back-link";
import { createShippingTierAction } from "../../actions";
import { getLocale } from "@/i18n/locale";
import { getDictionary } from "@/i18n/get-dictionary";
export default async function AdminVersandNewPage(props: PageProps<"/admin/versand/neu">) {
const t = getDictionary(await getLocale());
const { error } = await props.searchParams;
return (
<div className="max-w-md">
<BackLink href="/admin/versand" label={t.adminShippingNewPage.backToShipping} />
<h1 className="text-2xl text-forest mb-8">{t.adminShippingNewPage.title}</h1>
{error ? (
<p className="mb-6 text-sm text-red-700 bg-red-50 border border-red-200 px-4 py-3">{error}</p>
) : null}
<form action={createShippingTierAction} className="space-y-4 bg-background border border-ink/10 p-6">
<div className="grid grid-cols-2 gap-4">
<Field name="minQuantity" label={t.adminShippingNewPage.minQuantityLabel} type="number" required placeholder="0" />
<Field name="maxQuantity" label={t.adminShippingNewPage.maxQuantityLabel} type="number" placeholder="3" />
</div>
<Field name="priceCents" label={t.adminShippingNewPage.priceLabel} type="number" required placeholder="700" />
<button type="submit" className="bg-forest text-cream px-6 py-2 text-sm">
{t.adminShippingNewPage.create}
</button>
</form>
</div>
);
}
function Field({
name,
label,
type = "text",
placeholder,
required = false,
}: {
name: string;
label: string;
type?: string;
placeholder?: string;
required?: boolean;
}) {
return (
<label className="block text-sm">
<span className="text-ink/70">{label}</span>
<input
name={name}
type={type}
placeholder={placeholder}
required={required}
min={0}
className="mt-1 w-full border border-ink/20 bg-background px-3 py-2"
/>
</label>
);
}
+73
View File
@@ -0,0 +1,73 @@
import Link from "next/link";
import { prisma } from "@/lib/prisma";
import { BackLink } from "@/components/back-link";
import { ConfirmForm } from "@/components/confirm-form";
import { formatPrice } from "@/lib/format";
import { deleteShippingTierAction } from "../actions";
import { getLocale } from "@/i18n/locale";
import { getDictionary } from "@/i18n/get-dictionary";
export default async function AdminVersandPage(props: PageProps<"/admin/versand">) {
const t = getDictionary(await getLocale());
const { error } = await props.searchParams;
const tiers = await prisma.shippingTier.findMany({ orderBy: { minQuantity: "asc" } });
return (
<div>
<BackLink href="/admin" label={t.adminShippingPage.backToDashboard} />
<div className="flex items-center justify-between mb-4">
<h1 className="text-2xl text-forest">{t.adminShippingPage.title}</h1>
<Link href="/admin/versand/neu" className="bg-forest text-cream px-5 py-2 text-sm">
{t.adminShippingPage.newTier}
</Link>
</div>
<p className="text-sm text-ink/70 mb-8 max-w-2xl">{t.adminShippingPage.intro}</p>
{error ? (
<p className="mb-6 text-sm text-red-700 bg-red-50 border border-red-200 px-4 py-3">{error}</p>
) : null}
<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.adminShippingPage.colQuantity}</th>
<th className="p-4">{t.adminShippingPage.colPrice}</th>
<th className="p-4" />
</tr>
</thead>
<tbody className="divide-y divide-ink/10">
{tiers.map((tier) => (
<tr key={tier.id} className="transition-colors hover:bg-ink/[0.03]">
<td className="p-4 text-forest">
{tier.maxQuantity === null
? t.adminShippingPage.quantityFrom(tier.minQuantity)
: t.adminShippingPage.quantityRange(tier.minQuantity, tier.maxQuantity)}
</td>
<td className="p-4">{formatPrice(tier.priceCents)}</td>
<td className="p-4">
<div className="flex items-center gap-3 whitespace-nowrap">
<Link href={`/admin/versand/${tier.id}`} className="text-forest underline">
{t.adminShippingPage.edit}
</Link>
<ConfirmForm
action={deleteShippingTierAction}
confirmMessage={t.adminShippingPage.deleteConfirm}
>
<input type="hidden" name="id" value={tier.id} />
<button type="submit" className="text-red-700 underline">
{t.adminShippingPage.delete}
</button>
</ConfirmForm>
</div>
</td>
</tr>
))}
</tbody>
</table>
{tiers.length === 0 ? <p className="p-6 text-ink/65">{t.adminShippingPage.noTiersYet}</p> : null}
</div>
</div>
);
}