import type { CollectionConfig } from "payload"; import { isAdmin } from "@/access"; export const WEEKDAYS = [ { label: "Montag", value: "monday" }, { label: "Dienstag", value: "tuesday" }, { label: "Mittwoch", value: "wednesday" }, { label: "Donnerstag", value: "thursday" }, { label: "Freitag", value: "friday" }, { label: "Samstag", value: "saturday" }, { label: "Sonntag", value: "sunday" }, ] as const; export const Availability: CollectionConfig = { slug: "availability", labels: { singular: "Verfügbarkeit", plural: "Verfügbarkeiten", }, admin: { useAsTitle: "weekday", defaultColumns: ["weekday", "startTime", "endTime", "active"], group: "Buchungen", description: "Wiederkehrende wöchentliche Arbeitszeiten für Buchungsanfragen. Kein Eintrag = an diesem Tag nicht verfügbar.", }, access: { read: () => true, create: isAdmin, update: isAdmin, delete: isAdmin, }, fields: [ { name: "weekday", type: "select", label: "Wochentag", required: true, options: [...WEEKDAYS], }, { type: "row", fields: [ { name: "startTime", type: "date", label: "Start", required: true, admin: { date: { pickerAppearance: "timeOnly", displayFormat: "HH:mm" }, width: "50%" }, }, { name: "endTime", type: "date", label: "Ende", required: true, admin: { date: { pickerAppearance: "timeOnly", displayFormat: "HH:mm" }, width: "50%" }, }, ], }, { name: "active", type: "checkbox", label: "Aktiv", defaultValue: true, admin: { description: "Deaktivieren statt löschen, um eine Zeitspanne vorübergehend auszusetzen.", }, }, ], };