import './event-teasers-large.scss';
import {EventTeasersLargeData} from "./EventTeasersLargeData";
import {createElement} from "../../_global/scripts/helpers";
import {createButton} from "../../atoms/button/ButtonComponent";
import {createEventTeaserLarge} from "../../components/event-teaser-large/EventTeaserLargeComponent";

export const createEventTeasersLarge = ({
  headline = 'Gründung und Nachfolge',
  subheadline = 'Egal, ob Startup oder Unternehmensnachfolge – mit unseren Ressourcen legen Sie den Grundstein für eine erfolgreiche Unternehmenszukunft.',
  count = 9,
  widemode = false,
  events = EventTeasersLargeData,
  buttonLabel = 'Alle aktuellen Beteiligungen',
}) => {
  const section = createElement('section', ['event-teasers-large','variant-subtle-primary']);
  const hlContainer = createElement('div', ['container'], null, section);
  const hl = createElement('h2', [], headline, hlContainer);
  const shl = createElement('p', [], subheadline, hlContainer);
  const wrapper = createElement('div', ['overflow-wrapper'], null, section);
  const container = createElement('div', ['container'], null, wrapper);
  const row = createElement('div', ['row'], null, container);


  events.map((event, index) => {
    if (index < 6 && index < count) {
      const col = createElement('div', ['col'], null, row);
      const teaser = createEventTeaserLarge({
        event: event, widemode : widemode,
      })
      col.appendChild(teaser);
    }
  })

  if (count > 3) {
    const btnContainer = createElement('div', ['container'], null, section);
    const all = createElement('div', ['all-participations'], null, btnContainer);
    const btn = createButton({label:buttonLabel,
    iconPosition: 'icon-right',
    icon: 'pfeil-simple-rechts'});
    all.appendChild(btn);
  }

  return section;
}