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, syncHarvestsFromApiCoreAction, deleteHarvestAction, } from "../actions"; 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 { synced, updated, skipped, failed, syncError, batchSynced, batchSkipped, batchFailed, batchLoadError, error } = await props.searchParams; const harvests = await prisma.harvest.findMany({ orderBy: [{ year: "desc" }, { harvestDate: "desc" }], include: { _count: { select: { batches: true, products: true } } }, }); return (
{error}
) : null} {synced !== undefined ? ({t.adminHarvestsPage.syncResult(Number(synced), Number(updated ?? 0), Number(skipped ?? 0), Number(failed ?? 0))}
) : null} {syncError !== undefined ? ({t.adminHarvestsPage.syncError} ({syncError})
) : null} {batchSynced !== undefined ? ({t.adminHarvestsPage.batchSyncResult(Number(batchSynced), Number(batchSkipped ?? 0), Number(batchFailed ?? 0))}
) : null} {batchLoadError !== undefined ? ({t.adminHarvestsPage.batchSyncError} ({batchLoadError})
) : 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}{t.adminHarvestsPage.syncIntro}