import type { CollectionConfig } from 'payload'

export const KulturSeiten: CollectionConfig = {
    slug: 'kultur-seiten',
    labels: {
        singular: 'Kulturseite',
        plural: 'Kulturseiten',
    },
    admin: {
        useAsTitle: 'titel',
        group: 'Donauschwaben',
        defaultColumns: ['titel', 'kategorie', 'updatedAt'],

    },
    access: {
        read:   () => true,
        create: ({ req }) => ['admin', 'editor'].includes(req.user?.role ?? ''),
        update: ({ req }) => ['admin', 'editor'].includes(req.user?.role ?? ''),
        delete: ({ req }) => req.user?.role === 'admin',
    },
    fields: [
        {
            name: 'titel',
            type: 'text',
            localized: true,
            required: true,
            label: { de: 'Titel', en: 'Title', hu: 'Cím' },
        },
        {
            name: 'slug',
            type: 'text',
            localized: true,
            required: true,
        },
        {
            name: 'inhalt',
            type: 'richText',
            localized: true,
            label: { de: 'Inhalt', en: 'Content', hu: 'Tartalom' },
        },
        {
            name: 'bild',
            type: 'upload',
            relationTo: 'media',
            label: { de: 'Headerbild', en: 'Header Image', hu: 'Fejléckép' },
        },
    ],
}