{% extends "@core/views/_views-view-withwrapper.html.twig" %}

{% block view_header %}

  <div class="row mb-4">

    {% if offers_header.header_text %}
      <div class="col-md-6">
        {{ offers_header.header_text }}
      </div>
    {% endif %}

    {% if offers_header.header_nodes is iterable %}
      <div class="col-md-6">
        <div class="row">
        {% for pinned_offer in offers_header.header_nodes %}
          <div class="col-xs-6 col-sm-6 col-md-12 col-lg-6 mb-3">
            {% include "@molecules/tm-lb/link-block/link-block.twig" with {
              "image_src": pinned_offer.img_url,
              "image_alt": pinned_offer.img_alt,
              "block_link": pinned_offer.link,
              "title": pinned_offer.title|length > 30 ? pinned_offer.title|slice(0, 30) ~ '…' : pinned_offer.title,
              "image_fluid": false,
              "icon_right": "fas fa-chevron-right",
              "block_class": "bl-vf cbelianr no-vertical",
              "header_tag": "h4",
              "link_classes": "belirf",
              "layout": "hoz",
              "order": "bwd",
              "link_scope": "block"
            } %}
          </div>
        {% endfor %}
        </div>
      </div>
    {% endif %}

  </div>

{% endblock %}

{% block view_rows %}

  {% if rows -%}

    {% set cards = [] %}

    {% for item in items %}

      {% set card %}

        {% embed "@molecules/tm-cards/offer-card/offer-card.twig" %}
          {# SETTINGS #}
          {% set show_itinerary = false %}
          {% set badge = item.badge %}
          {# FIELDS #}
          {% set image = item.img %}
          {% set title = item.title %}
          {% set content = item.content %}
          {% set badge_graphic_image = item.badge_graphic_image %}
          {% set badge_text_top = item.badge_text_top %}
          {% set badge_text_bottom = item.badge_text_bottom %}
          {% set badge_color = item.badge_color %}
          {% set card_link = item.card_link %}
          {% set location = item.location %}
          {% set tags = item.tags %}
          {% set show_itinerary = item.show_itinerary %}
          {% set oid = item.oid %}
        {% endembed %}

      {% endset %}

      {% set cards = cards|merge([card]) %}

    {% endfor %}

    {# Pass the cards array and the rows scaffolding. #}
    {% include "@organisms/tm-scaffold/rows-cols/rows-cols.twig" with {
      'batch': 3,
      'items': cards,
      'auto_height': false,
    } only %}

  {% elseif empty -%}
    {{ empty }}
  {% endif %}

{% endblock %}
