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

export const Locations: CollectionConfig = {
  slug: 'locations',
  labels: {
    singular: {
      de: 'Standort'
    },
    plural: {
      de: 'Standorte'
    }
  },
  fields: [
    {
      name: 'name',
      label: {
        de: 'Name'
      },
      type: 'text',
      unique: true,
      required: true,
    },
    {
      name: 'address',
      label: {
        de: 'Addresse'
      },
      type: 'textarea'
    },
    {
      name: 'coordinates',
      type: 'point',
      label: {
        de: 'Koordinaten'
      }
    },
    {
      name: 'notes',
      type: 'textarea',
      label: {
        de: "Hinweise"
      }
    },
    {
      name: 'barrierFree',
      type: 'checkbox',
      label: {
        de: "Barrierefrei"
      },
      defaultValue: false
    }
  ],
  admin: {
    useAsTitle: 'name'
  },
  access: {
    read: () => true,
    update: isAdminOrEmployee(),
    delete: isAdmin(),
  },
}