import type { GlobalConfig } from 'payload'

export const Geschichte: GlobalConfig = {
    slug: 'geschichte',
    label: {
        de: 'Geschichte',
        en: 'History',
        hu: 'Történelem',
    },
    admin: {
        group: 'Donauschwaben',
    },
    access: {
        read:   () => true,
        update: ({ req }) => ['admin', 'editor'].includes(req.user?.role ?? ''),
    },
    fields: [
        {
            name: 'titel',
            type: 'text',
            localized: true,
            required: true,
            label: {
                de: 'Titel',
                en: 'Title',
                hu: 'Cím',
            },
        },
        {
            name: 'einleitung',
            type: 'textarea',
            localized: true,
            label: {
                de: 'Einleitung',
                en: 'Introduction',
                hu: 'Bevezetés',
            },
        },
        {
            name: 'inhalt',
            type: 'richText',
            localized: true,
            label: {
                de: 'Inhalt',
                en: 'Content',
                hu: 'Tartalom',
            },
        },
        {
            name: 'bild',
            type: 'upload',
            relationTo: 'media',
            localized: false,
            label: {
                de: 'Headerbild',
                en: 'Header Image',
                hu: 'Fejléckép',
            },
        },
    ],
}