import type { Block } from 'payload'

export const ContactFormBlock: Block = {
  slug: 'contact-form-block',
  labels: {
    singular: 'Kontaktformular',
    plural: 'Kontaktformulare',
  },
  fields: [
    {
      name: 'form',
      type: 'relationship',
      relationTo: 'forms',
      required: true,
      label: 'Formular',
      admin: {
        description: 'Wählen Sie ein Formular aus der Formulare-Sammlung',
      },
    },
    {
      name: 'headline',
      type: 'text',
      defaultValue: 'Kontakt',
      label: 'Überschrift',
      localized: true,
    },
    {
      name: 'description',
      type: 'textarea',
      label: 'Beschreibung',
      localized: true,
    },
    {
      name: 'successMessage',
      type: 'textarea',
      defaultValue: 'Vielen Dank! Wir melden uns schnellstmöglich.',
      label: 'Erfolgsmeldung',
      localized: true,
    },
    {
      name: 'showContactInfo',
      type: 'checkbox',
      defaultValue: true,
      label: 'Kontaktinformationen anzeigen',
    },
    {
      name: 'showPhone',
      type: 'checkbox',
      defaultValue: true,
      label: 'Telefon anzeigen',
      admin: {
        condition: (_, siblingData) => siblingData?.showContactInfo,
      },
    },
    {
      name: 'showAddress',
      type: 'checkbox',
      defaultValue: true,
      label: 'Adresse anzeigen',
      admin: {
        condition: (_, siblingData) => siblingData?.showContactInfo,
      },
    },
    {
      name: 'showSocials',
      type: 'checkbox',
      defaultValue: true,
      label: 'Social Media anzeigen',
      admin: {
        condition: (_, siblingData) => siblingData?.showContactInfo,
      },
    },
  ],
}
