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, AdminSwitch, AdminTextarea } from "@/components/admin-form"; import { AdminActionButton, AdminActionLink, AdminActionNote, AdminBadge, AdminEmptyState, AdminPageHeader, AdminRowActions, } from "@/components/admin-list"; import { createHarvestAction, toggleHarvestPublishedAction, deleteHarvestAction } from "../actions"; import { getLocale } from "@/i18n/locale"; import { getDictionary } from "@/i18n/get-dictionary"; export default async function AdminHarvestsPage() { const t = getDictionary(await getLocale()); const harvests = await prisma.harvest.findMany({ orderBy: [{ year: "desc" }, { harvestDate: "desc" }], include: { _count: { select: { batches: true, products: true } } }, }); return (
{harvests.map((harvest) => ( ))}
{t.adminHarvestsPage.colType} {t.adminHarvestsPage.colYear} {t.adminHarvestsPage.colHarvestDate} {t.adminHarvestsPage.colLocation} {t.adminHarvestsPage.colBatches} {t.adminHarvestsPage.colProducts} {t.adminHarvestsPage.colStatus}
{harvest.type} {harvest.year} {formatDate(harvest.harvestDate)} {harvest.location} {harvest._count.batches} {harvest._count.products} {harvest.isPublished ? ( {t.adminHarvestsPage.statusPublished} ) : ( {t.adminHarvestsPage.statusDraft} )} {t.adminHarvestsPage.edit}
{harvest.isPublished ? null : } {harvest.isPublished ? t.adminHarvestsPage.unpublish : t.adminHarvestsPage.publish}
{harvest._count.batches === 0 && harvest._count.products === 0 ? ( {t.adminHarvestsPage.delete} ) : ( // Statt den Knopf wortlos wegzulassen: der Grund steht da. {t.adminHarvestsPage.notDeletable} )}
{harvests.length === 0 ? : null}

{t.adminHarvestsPage.newHarvestHeading}

); }