import { prisma } from "@/lib/prisma"; import { BackLink } from "@/components/back-link"; import { ConfirmForm } from "@/components/confirm-form"; import { formatDate } from "@/lib/format"; import { Button } from "@/components/ui"; import { AdminField, AdminSelect } from "@/components/admin-form"; import { AdminActionButton, AdminActionLink, AdminActionNote, AdminEmptyState, AdminPageHeader, AdminRowActions, } from "@/components/admin-list"; import { createBatchAction, deleteBatchAction } 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, _count: { select: { products: true, orderItems: true } } }, }), prisma.harvest.findMany({ orderBy: [{ year: "desc" }] }), ]); return (
{batches.map((batch) => ( ))}
{t.adminBatchesPage.colBatch} {t.adminBatchesPage.colHarvest} {t.adminBatchesPage.colFillDate} {t.adminBatchesPage.colBestBefore} {t.adminBatchesPage.colTotalGlasses} {t.adminBatchesPage.colRemaining}
{batch.code} {batch.harvest.type} {batch.harvest.year} {formatDate(batch.fillDate)} {formatDate(batch.bestBeforeDate)} {batch.glassCount} {batch.remainingGlasses} {t.adminBatchesPage.edit} {batch._count.products === 0 && batch._count.orderItems === 0 ? ( {t.adminBatchesPage.delete} ) : ( // Statt den Knopf wortlos wegzulassen: der Grund steht da. {t.adminBatchesPage.notDeletable} )}
{batches.length === 0 ? : null}

{t.adminBatchesPage.newBatchHeading}

{harvests.map((h) => ( ))}
); }