Rollen-Farben statt reiner Markenfarben, damit hell und dunkel aus einem Satz Klassen entstehen: - heading (Ueberschriften, Links, Rahmen): hell Waldgruen, dunkel Creme - surface (abgesetzte Flaeche): hell Creme, dunkel angehobenes Dunkelgruen - forest bleibt die dunkle Markenflaeche (Hero, Baender, Knoepfe, Admin-Leiste), cream der helle Text darauf - honey-deep als fester Honigton fuer Flaechen; honey-dark (Text) wird im Dunkelmodus heller und bleibt lesbar Codemod ueber src: text-/border-forest -> *-heading, bg-cream -> bg-surface, bg-honey-dark -> bg-honey-deep. Im hellen Modus haben die Rollen exakt die bisherigen Werte - das Erscheinungsbild bleibt gleich. Umschalter (components/theme-toggle.tsx) Automatisch -> Hell -> Dunkel in Kopfzeile, Mobilmenue und Admin-Leiste. Die Wahl liegt im Cookie "theme" (nur light/dark, geprueft in lib/theme.ts); der Server setzt data-theme schon beim Ausliefern, nichts blitzt hell auf. "Automatisch" folgt der Systemeinstellung. Gewaehlter und automatischer Dunkelblock in globals.css werden per Test auf Gleichheit geprueft. Logo, Biene und Select-Pfeil nutzen die Rollenfarben. In der Kopfzeile steht "Honig entdecken" zwischen 1280 und 1535 px nicht mehr doppelt neben "Shop" (sonst stiess die Navigation an), der Slogan erscheint erst ab 1680 px. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
90 lines
3.7 KiB
TypeScript
90 lines
3.7 KiB
TypeScript
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,
|
|
AdminHint,
|
|
AdminSwitch,
|
|
AdminTextarea,
|
|
} from "@/components/admin-form";
|
|
import { updateHarvestAction, toggleHarvestPublishedAction } from "../../actions";
|
|
import { getLocale } from "@/i18n/locale";
|
|
import { getDictionary } from "@/i18n/get-dictionary";
|
|
|
|
export default async function AdminHarvestEditPage(props: PageProps<"/admin/ernten/[id]">) {
|
|
const t = getDictionary(await getLocale());
|
|
const th = t.adminHarvestEditPage;
|
|
const { id } = await props.params;
|
|
const rawHarvest = await prisma.harvest.findUnique({ where: { id } });
|
|
if (!rawHarvest) notFound();
|
|
const harvest = { ...rawHarvest, images: asStringArray(rawHarvest.images) };
|
|
|
|
const harvestDateValue = harvest.harvestDate.toISOString().slice(0, 10);
|
|
|
|
return (
|
|
<div className="max-w-2xl">
|
|
<BackLink href="/admin/ernten" label={th.backToHarvests} />
|
|
<h1 className="text-2xl text-heading mb-8">{th.title}</h1>
|
|
|
|
{harvest.isPublished ? null : (
|
|
<div className="mb-6 flex flex-col justify-between gap-3 border border-honey/40 bg-honey/5 px-4 py-3 sm:flex-row sm:items-center">
|
|
<p className="text-sm text-honey-dark">{th.draftNotice}</p>
|
|
<form action={toggleHarvestPublishedAction}>
|
|
<input type="hidden" name="id" value={harvest.id} />
|
|
<input type="hidden" name="isPublished" value="on" />
|
|
<Button type="submit" className="whitespace-nowrap px-5 py-2.5">
|
|
{th.publishNow}
|
|
</Button>
|
|
</form>
|
|
</div>
|
|
)}
|
|
|
|
<AdminFormPanel action={updateHarvestAction} actions={<Button type="submit">{th.save}</Button>}>
|
|
<input type="hidden" name="id" value={harvest.id} />
|
|
<AdminFieldset legend={th.sectionDetails}>
|
|
<div className="grid grid-cols-2 items-end gap-4">
|
|
<AdminField name="type" label={th.typeLabel} defaultValue={harvest.type} required />
|
|
<AdminField name="year" label={th.yearLabel} type="number" defaultValue={String(harvest.year)} required />
|
|
</div>
|
|
<div className="grid items-end gap-4 sm:grid-cols-2">
|
|
<AdminField
|
|
name="harvestDate"
|
|
label={th.harvestDateLabel}
|
|
type="date"
|
|
defaultValue={harvestDateValue}
|
|
required
|
|
/>
|
|
<AdminField name="location" label={th.locationLabel} defaultValue={harvest.location} />
|
|
</div>
|
|
<AdminTextarea
|
|
name="description"
|
|
label={th.descriptionLabel}
|
|
defaultValue={harvest.description}
|
|
rows={4}
|
|
required
|
|
/>
|
|
</AdminFieldset>
|
|
|
|
{/* Siehe Kommentar im Chargen-Formular: zwei benannte Slots statt
|
|
einer Liste, damit sich das zweite Bild auch ohne erstes setzen
|
|
laesst. Slot 1 erscheint zusaetzlich auf /ernten und der
|
|
Ernten-Detailseite. */}
|
|
<AdminFieldset legend={th.imagesLabel}>
|
|
<AdminImageField name="images" label={th.image1Label} initialValue={harvest.images[0] ?? ""} />
|
|
<AdminImageField name="images" label={th.image2Label} initialValue={harvest.images[1] ?? ""} />
|
|
</AdminFieldset>
|
|
|
|
<AdminFieldset legend={th.sectionVisibility} last>
|
|
<AdminSwitch name="isPublished" label={th.isPublishedLabel} defaultChecked={harvest.isPublished} />
|
|
<AdminHint>{th.isPublishedHint}</AdminHint>
|
|
</AdminFieldset>
|
|
</AdminFormPanel>
|
|
</div>
|
|
);
|
|
}
|