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

export const DonationForms: CollectionConfig = {
  slug: 'donation-form',
  labels: {
    singular: {
      de: 'Spendenformular'
    },
    plural: {
      de: 'Spendenformulare'
    }
  },
  fields: [
    {
      name: 'photo',
      type: 'upload',
      relationTo: 'media',
      label: {
        de: 'Bild'
      },
      required: true
    },
    {
      name: 'text',
      type: 'richText',
      required: true
    },
    {
      name: 'url',
      type: 'text',
      label: {
        de: 'Link zum Spendenformular'
      },
      required: true
    }
  ],
  admin: {
    hidden: hide
  },
  access: {
    read: () => true,
    create: isAdminOrEmployee(),
    update: isAdminOrEmployee(),
    delete: isAdminOrEmployee(),
  },
}