import { notFound } from "next/navigation"; import { prisma } from "@/lib/prisma"; import { asStringArray } from "@/lib/json-array"; import { BackLink } from "@/components/back-link"; import { Button } from "@/components/ui"; import { AdminImageField } from "@/components/admin-image-field"; import { AdminField, AdminFieldset, AdminFormPanel } from "@/components/admin-form"; import { updateBatchAction } from "../../actions"; import { getLocale } from "@/i18n/locale"; import { getDictionary } from "@/i18n/get-dictionary"; export default async function AdminBatchEditPage(props: PageProps<"/admin/chargen/[id]">) { const t = getDictionary(await getLocale()); const tb = t.adminBatchEditPage; const { id } = await props.params; const rawBatch = await prisma.batch.findUnique({ where: { id }, include: { harvest: true } }); if (!rawBatch) notFound(); const batch = { ...rawBatch, images: asStringArray(rawBatch.images) }; return (

{tb.title}

{batch.code} ยท {batch.harvest.type} {batch.harvest.year}

{tb.save}}>
{/* Zwei einzeln setzbare Slots statt einer Liste: die Position entscheidet, welche Kachel auf /charge/[code] gefuellt wird. Beide tragen denselben Feldnamen "images" und werden in dieser Reihenfolge uebermittelt (siehe imageSlots() in admin/actions/harvests-batches.ts). Ein leerer Slot faellt auf das entsprechende Erntebild zurueck. */}
); }