diff --git a/src/app/admin/inhalte/page.tsx b/src/app/admin/inhalte/page.tsx index 39adb93..37cead2 100644 --- a/src/app/admin/inhalte/page.tsx +++ b/src/app/admin/inhalte/page.tsx @@ -6,6 +6,8 @@ import { CONTENT_REGISTRY, type ContentFieldDef } from "@/lib/content-registry"; import { updateSiteContentAction } from "../actions"; import { getLocale } from "@/i18n/locale"; import { getDictionary } from "@/i18n/get-dictionary"; +import type { Dictionary } from "@/i18n/dictionary-type"; +import type { Locale } from "@/i18n/config"; const ROWS_BY_TYPE: Record = { text: 1, @@ -21,11 +23,155 @@ const ROWS_BY_TYPE: Record = { video: 0, }; -async function loadCurrentValues(): Promise> { +type CurrentValues = Map; + +async function loadCurrentValues(): Promise { const rows = await prisma.siteContent.findMany(); return new Map(rows.map((r) => [r.key, { valueDe: r.valueDe, valueEn: r.valueEn }])); } +/** Bild- und Video-Felder gehoeren zum "Bilder"-Bereich, alles andere + * (Text/Listen/Rechtstexte) zum "Text"-Bereich — siehe AdminInhaltePage. */ +function isImageOrVideoField(def: ContentFieldDef): boolean { + return def.type === "image" || def.type === "video"; +} + +function FieldEditor({ + def, + row, + locale, + t, +}: { + def: ContentFieldDef; + row: { valueDe: string; valueEn: string | null } | undefined; + locale: Locale; + t: Dictionary; +}) { + const rows = ROWS_BY_TYPE[def.type]; + const label = locale === "de" ? def.labelDe : def.labelEn; + + if (!def.localized) { + if (def.type === "image") { + return ; + } + if (def.type === "video") { + return ; + } + return ( +