Files
anouma/globals/CookieSettings.ts

103 lines
3.5 KiB
TypeScript

import type { GlobalConfig } from "payload";
import { isAdmin } from "@/access";
/**
* Consent-category configuration shown in the public cookie banner
* (components/Analytics.tsx). Read access is intentionally public - the
* unauthenticated frontend needs the labels/descriptions and the
* enabled/disabled flags before a visitor has logged in anywhere.
*
* "necessary" deliberately has no `enabled` field at all, anywhere in this
* schema - there is no toggle to accidentally switch off, so it can never
* be disabled through the admin UI (see requirement: technically required
* functionality must not be disable-able by an admin).
*/
export const CookieSettings: GlobalConfig = {
slug: "cookie-settings",
label: "Cookie-Einstellungen",
admin: {
description: "Kategorien und Texte für den Cookie-Consent-Banner der Website.",
group: "Datenschutz",
},
access: {
read: () => true,
update: isAdmin,
},
fields: [
{
name: "consentVersion",
type: "text",
label: "Consent-Version",
required: true,
defaultValue: "1.0",
admin: {
description:
"Bei Änderung müssen alle Besucher erneut zustimmen - bereits gespeicherte Einwilligungen mit einer älteren Version werden ignoriert und der Banner erscheint erneut.",
},
},
{
type: "group",
name: "necessary",
label: "Notwendig",
admin: { description: "Immer aktiv - technisch erforderlich, kann nicht deaktiviert werden." },
fields: [
{ name: "label", type: "text", label: "Bezeichnung", required: true, defaultValue: "Notwendig" },
{
name: "description",
type: "textarea",
label: "Beschreibung",
required: true,
defaultValue: "Für den Betrieb der Website technisch erforderlich (z. B. Login, Sitzung). Kann nicht deaktiviert werden.",
},
],
},
{
type: "group",
name: "preferences",
label: "Präferenzen",
fields: [
{ name: "label", type: "text", label: "Bezeichnung", required: true, defaultValue: "Präferenzen" },
{
name: "description",
type: "textarea",
label: "Beschreibung",
required: true,
defaultValue: "Speichert Einstellungen wie z. B. bevorzugte Anzeigeoptionen.",
},
{
name: "enabled",
type: "checkbox",
label: "Kategorie aktiv",
defaultValue: true,
admin: { description: "Wenn deaktiviert, wird diese Kategorie im Banner nicht mehr angeboten." },
},
],
},
{
type: "group",
name: "statistics",
label: "Statistik",
fields: [
{ name: "label", type: "text", label: "Bezeichnung", required: true, defaultValue: "Statistik" },
{
name: "description",
type: "textarea",
label: "Beschreibung",
required: true,
defaultValue: "Anonymisierte, datensparsame Reichweitenmessung (Seitenaufrufe, Ereignisse) ohne personenbezogene Profile.",
},
{
name: "enabled",
type: "checkbox",
label: "Kategorie aktiv",
defaultValue: true,
admin: {
description:
"Globaler Schalter für die gesamte Reichweitenmessung. Wenn deaktiviert, wird diese Kategorie im Banner nicht mehr angeboten und Messdaten werden serverseitig abgelehnt - auch bei einer noch gespeicherten alten Zustimmung.",
},
},
],
},
],
};