import type { Block } from 'payload'

export const ImageTextBlock: Block = {
  slug: 'image-text-block',
  labels: {
    singular: 'Bild & Text',
    plural: 'Bild & Text',
  },
  fields: [
    {
      name: 'image',
      type: 'upload',
      relationTo: 'media',
      required: true,
      label: 'Bild',
    },
    {
      name: 'imagePosition',
      type: 'select',
      defaultValue: 'left',
      label: 'Bildposition',
      options: [
        { label: 'Links', value: 'left' },
        { label: 'Rechts', value: 'right' },
      ],
    },
    {
      name: 'headline',
      type: 'text',
      label: 'Überschrift',
      localized: true,
    },
    {
      name: 'content',
      type: 'richText',
      label: 'Inhalt',
      localized: true,
    },
    {
      name: 'cta',
      type: 'group',
      label: 'Call-to-Action',
      fields: [
        {
          name: 'text',
          type: 'text',
          label: 'Button-Text',
          localized: true,
        },
        {
          name: 'link',
          type: 'text',
          label: 'Link',
        },
      ],
    },
  ],
}
