{% 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-lg-6">
            {% 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",
              "header_tag": "h3",
              "link_classes": "belirf",
              "layout": "hoz",
              "order": "bwd",
              "link_scope": "block"
            } %}
          </div>
        {% endfor %}
        </div>
      </div>
    {% endif %}

  </div>

{% endblock %}

{% block view_rows %}
  {# Views Rows #}
  {% set cards = [] %}

  {% for item in items %}

    {% set card %}

      {% embed "@molecules/tm-cards/modern-card/modern-card.twig" %}
        {# SETTINGS #}
        {% set show_itinerary = false %}
        {% set badge = item.badge %}
        {# FIELDS #}
        {% set img_url = item.img_url %}
        {% set img_alt = item.img_alt %}
        {% set title = item.title %}
        {% set content = '' %}
        {% set badge_text_top = item.badge_text_top %}
        {% set badge_text_bottom = item.badge_text_bottom %}
        {% set card_link = item.card_link %}
        {% set location = item.location %}
        {% set location_icon = "fc fc-tx" %}
        {% set tags = item.tags %}
        {% set visible_limit = "2" %}
        {% set show_itinerary = item.show_itinerary %}
        {% set oid = item.oid %}
        {% set header_tag_text = item.offer_type %}
        {% set header_tag_colour = item.offer_colour %}
      {% endembed %}

    {% endset %}

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

  {% endfor %}

  {# Pass the cards array and the rows scaffolding. #}
  <div class="view-content views-infinite-scroll-content-wrapper clearfix" data-drupal-views-infinite-scroll-content-wrapper>
    {% include "@organisms/tm-scaffold/rows-cols/rows-cols.twig" with {
      'batch': 4,
      'items': cards,
      'auto_height': true,
      'row_class': 'light-brd',
      'col_class': 'mb-4 col-sm-6 col-lg-3',
    } only %}
  </div>

{% endblock %}
