import type { Field } from 'payload' import { CONSENT_CATEGORIES } from '../../modules/consent/categories.js' /** * Fields for the CookieSettings global — GDPR consent banner copy, editable * per locale. The privacy-policy link TARGET is NOT stored here: it comes from * the pages module (system page role 'privacyPolicy'), keeping one source of * truth. Only the link's visible text lives here (privacyLinkLabel). */ export const cookieSettingsFields: Field[] = [ { name: 'policyVersion', type: 'number', admin: { description: 'Raise by 1 when you add a tool or change the cookie policy — every visitor is asked for consent again.', position: 'sidebar', step: 1, }, defaultValue: 1, min: 1, required: true, }, { name: 'eyebrow', type: 'text', admin: { description: 'Small label above the banner title, e.g. "Privacy & cookies". Empty → not shown.', }, localized: true, }, { name: 'title', type: 'text', admin: { description: 'Banner heading, e.g. "We respect your privacy". Empty → not shown.', }, localized: true, }, { name: 'message', type: 'textarea', admin: { description: 'Main consent message shown in the banner.', }, localized: true, }, { name: 'settingsTitle', type: 'text', admin: { description: 'Heading for the detailed settings panel.', }, localized: true, }, { name: 'settingsDescription', type: 'textarea', admin: { description: 'Intro under the settings heading — what cookies are for and that the choice can be changed later.', }, localized: true, }, { name: 'alwaysActiveLabel', type: 'text', admin: { description: 'Badge next to the Necessary category, e.g. "Always active". Empty → a disabled switch/checkbox is shown instead.', }, localized: true, }, { name: 'privacyLinkLabel', type: 'text', admin: { description: 'Text of the privacy-policy link in the banner, e.g. "Privacy policy". The link target is the page assigned as Privacy Policy in Site Settings → System Pages. Empty → the page title is used.', }, localized: true, }, { name: 'buttons', type: 'group', admin: { description: 'Button labels.', }, fields: [ { name: 'acceptAll', type: 'text', localized: true }, { name: 'reject', type: 'text', localized: true }, { name: 'settings', type: 'text', localized: true }, { name: 'save', type: 'text', localized: true }, { name: 'back', type: 'text', localized: true }, { name: 'close', type: 'text', admin: { description: 'Screen-reader label of the ✕ button in the settings dialog.' }, localized: true, }, ], }, { name: 'categories', type: 'array', admin: { description: 'Per-category titles and descriptions.', }, fields: [ { name: 'key', type: 'select', options: CONSENT_CATEGORIES.map((c) => ({ label: c, value: c })), required: true, }, { name: 'title', type: 'text', localized: true }, { name: 'description', type: 'textarea', localized: true }, ], }, { name: 'cookies', type: 'array', admin: { description: 'Cookies the site uses — shown on the cookie policy page (). Fill it from a scan: ipal-consent-check → cookie-scan.', initCollapsed: true, }, fields: [ { type: 'row', fields: [ { name: 'name', type: 'text', admin: { width: '40%' }, required: true }, { name: 'provider', type: 'text', admin: { description: 'e.g. Google, this site', width: '30%' } }, { name: 'category', type: 'select', admin: { width: '30%' }, defaultValue: 'necessary', options: CONSENT_CATEGORIES.map((c) => ({ label: c, value: c })), required: true, }, ], }, { name: 'purpose', type: 'textarea', localized: true }, { name: 'duration', type: 'text', admin: { description: 'e.g. "2 years", "session"' }, localized: true }, ], labels: { plural: 'Cookies', singular: 'Cookie' }, }, ]