import type { Field } from 'payload'

export const headerFields: Field[] = [
  {
    name: 'variant',
    type: 'select',
    required: true,
    defaultValue: 'default',
    options: [
      { label: 'Default (site)', value: 'default' },
      { label: 'Landing (minimal)', value: 'landing' },
    ],
  },
  {
    name: 'logo',
    type: 'upload',
    relationTo: 'media',
    required: true,
  },
  {
    name: 'navItems',
    label: 'Navigation',
    type: 'array',
    admin: {
      condition: (_, siblingData) => siblingData?.variant === 'default',
      initCollapsed: true,
    },
    fields: [
      { name: 'label', type: 'text', required: true },
      { name: 'href', type: 'text', required: true },
      {
        name: 'openInNewTab',
        type: 'checkbox',
        defaultValue: false,
      },
    ],
  },
  {
    name: 'landingCTA',
    label: 'Landing CTA',
    type: 'group',
    admin: {
      condition: (_, siblingData) => siblingData?.variant === 'landing',
    },
    fields: [
      { name: 'label', type: 'text', defaultValue: 'Send Request' },
      { name: 'href', type: 'text', defaultValue: '#send-request' },
      {
        name: 'ctaId',
        type: 'text',
        admin: {
          description: 'Optional HTML id attribute for tracking or scroll targeting (e.g. "header-book-now").',
        },
      },
    ],
  },
]
