import { CollectionConfig } from 'payload'
import { hide, isAdminOrEmployee } from '@/collections/access/admin'

export const PopesPrayerIntentions: CollectionConfig = {
  slug: 'popePrayerIntentions',
  labels: {
    singular: {
      de: 'Gebetsanliegen des Papstes'
    },
    plural: {
      de: 'Gebetsanliegen des Papstes'
    }
  },
  fields: [
    {
      name: 'year',
      type: 'number',
      label: {
        de: "Jahr"
      },
      required: true,
      defaultValue: new Date().getFullYear(),
    },
    {
      name: 'month',
      type: 'select',
      label: {
        de: 'Monat'
      },
      options: [
        {
          label: 'Januar',
          value: '01',
        },
        {
          label: 'Februar',
          value: '02',
        },
        {
          label: 'März',
          value: '03',
        },
        {
          label: 'April',
          value: '04',
        },
        {
          label: 'Mai',
          value: '05',
        },
        {
          label: 'Juni',
          value: '06'
        },
        {
          label: 'Juli',
          value: '07',
        },
        {
          label: 'August',
          value: '08',
        },
        {
          label: 'September',
          value: '09',
        },
        {
          label: 'Oktober',
          value: '10',
        },
        {
          label: 'November',
          value: '11',
        },
        {
          label: 'Dezember',
          value: '12'
        }
      ],
      required: true,
      defaultValue: '01'
    },
    {
      type: 'text',
      name: 'title',
      label: {
        de: "Titel"
      },
      defaultValue: "Für ",
      required: true
    },
    {
      type: 'textarea',
      name: 'prayer',
      label: {
        de: "Gebet"
      },
      required: true
    }
  ],
  admin: {
    useAsTitle: 'title',
    hidden: hide
  },
  access: {
    read: () => true,
    create: isAdminOrEmployee(),
    update: isAdminOrEmployee(),
    delete: isAdminOrEmployee(),
  },
}