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

export const Churches: CollectionConfig = {
  slug: 'church',
  labels: {
    singular: {
      de: 'Kirche',
    },
    plural: {
      de: 'Kirchen',
    },
  },
  fields: [
    {
      name: 'name',
      label: {
        de: 'Name',
      },
      type: 'text',
      required: true,
    },
    {
      name: 'address',
      label: {
        de: 'Addresse',
      },
      type: 'textarea',
      required: true,
    },
  ],
  admin: {
    useAsTitle: 'name',
  },
  access: {
    read: () => true,
    create: isAdminOrEmployee(),
    update: isAdminOrEmployee(),
    delete: isAdminOrEmployee(),
  },
}
