import type { GlobalConfig } from 'payload' import { userMeetsRole } from '../../modules/access/index.js' import { lightboxNotificationFields, notificationsFields } from './fields.js' /** * Builds the Notifications global (shown as "Form messages") — localized action-result texts. Readable by * any authenticated panel user; server-side helpers read it with overrideAccess * so the frontend can resolve texts without a session. `lightbox` adds the * image-viewer labels (ipalKit `lightbox: true`). */ export function buildNotifications({ lightbox = false }: { lightbox?: boolean } = {}): GlobalConfig { return { slug: 'notifications', access: { read: () => true, // texts are public-facing (shown to end users) update: ({ req }) => userMeetsRole(req, 'editor'), }, admin: { group: { en: 'Forms', pl: 'Formularze' } }, fields: lightbox ? [...notificationsFields, lightboxNotificationFields] : notificationsFields, label: { en: 'Form messages', pl: 'Komunikaty formularzy' }, } }