import Link from "next/link"; import { prisma } from "@/lib/prisma"; import { BackLink } from "@/components/back-link"; import { ConfirmForm } from "@/components/confirm-form"; import { formatDate } from "@/lib/format"; import { createHarvestAction, toggleHarvestPublishedAction, deleteHarvestAction } from "../actions"; import { ApiCoreSyncPanel, ApiCoreSyncResult } from "@/components/apicore-sync-panel"; import { getLocale } from "@/i18n/locale"; import { getDictionary } from "@/i18n/get-dictionary"; export default async function AdminHarvestsPage(props: PageProps<"/admin/ernten">) { const t = getDictionary(await getLocale()); const searchParams = await props.searchParams; const error = searchParams.error; const harvests = await prisma.harvest.findMany({ orderBy: [{ year: "desc" }, { harvestDate: "desc" }], include: { _count: { select: { batches: true, products: true } } }, }); return (
{error}
) : null}| {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._count.batches === 0 && harvest._count.products === 0 ? (
|
{t.adminHarvestsPage.noHarvestsYet}
: null}