import type { Block } from 'payload'
import { blockMetaFields } from '@/fields/blockMeta'
import { richTextEditor } from '@/fields/richTextEditor'

export const CTABannerV1: Block = {
  slug: 'ctaBannerV1',
  labels: { singular: 'CTA Banner', plural: 'CTA Banners' },
  fields: [
    { name: 'headline', type: 'richText', required: true, editor: richTextEditor },
    { name: 'body', type: 'richText', editor: richTextEditor },
    {
      name: 'style',
      type: 'select',
      defaultValue: 'primary',
      options: [
        { label: 'Primary', value: 'primary' },
        { label: 'Secondary', value: 'secondary' },
        { label: 'Outline', value: 'outline' },
      ],
    },
    {
      name: 'ctas',
      type: 'array',
      maxRows: 4,
      fields: [
        { name: 'label', type: 'text', required: true, defaultValue: 'Send Request' },
        { name: 'href', type: 'text', required: true, defaultValue: '#send-request' },
        {
          name: 'style',
          type: 'select',
          defaultValue: 'primary',
          options: [
            { label: 'Primary', value: 'primary' },
            { label: 'Secondary', value: 'secondary' },
            { label: 'Outline', value: 'outline' },
          ],
        },
        {
          name: 'ctaId',
          type: 'text',
          admin: {
            description: 'Optional HTML id attribute for tracking or scroll targeting (e.g. "hero-book-now").',
          },
        },
      ],
    },
    ...blockMetaFields,
  ],
}
