import type { CollectionConfig } from 'payload'
import { adminOrEditor, anyRole } from '@/access/roles'

export const SharedCTAs: CollectionConfig = {
  slug: 'shared-ctas',
  admin: {
    useAsTitle: 'title',
    defaultColumns: ['title', 'label', 'href', 'updatedAt'],
  },
  access: {
    read: anyRole,
    create: adminOrEditor,
    update: adminOrEditor,
    delete: adminOrEditor,
  },
  fields: [
    {
      name: 'title',
      type: 'text',
      required: true,
      admin: {
        placeholder: 'e.g. Navigation Book Now',
      },
    },
    {
      name: 'label',
      type: 'text',
      required: true,
    },
    {
      name: 'href',
      type: 'text',
      required: true,
    },
    {
      name: 'style',
      type: 'select',
      defaultValue: 'primary',
      options: [
        { label: 'Primary', value: 'primary' },
        { label: 'Outline', value: 'outline' },
      ],
    },
    {
      name: 'ctaId',
      type: 'text',
      admin: {
        description: 'Optional HTML id attribute for tracking or scroll targeting (e.g. "hero-book-now").',
      },
    },
  ],
}
