{% extends 'website/main.template.html.twig' %}
{% from 'utils.html.twig' import ico, imgUpload %}
{% block category_css %}
{% if category is defined %}
{% include 'website/includes/css-category.html.twig' %}
{% endif %}
{% endblock %}
{% block body %}
{% include 'website/includes/search-section.html.twig' %}
{# TITLE - CATEGORIES #}
{% if category is defined %}
{# TITLE - CATEGORIES - IMAGE #}
{% if category.image is not null %}
<section class="category-banner">
{# BANNER #}
<div class="banner-img">
{{ imgUpload(category.image, enum('AbstractEnum::PATH_OTHERS'), 'category-cover', category.category) }}
</div>
<div class="container">
<div class="wrap category-banner-color">
<h1 class="title">{{ category.category }}</h1>
<nav class="migalhas">
<a href="{{ path('home') }}">{{ getLanguage('home', 'product') }}</a> / 
<a href="{{ path('home') }}#categories-container">{{ getLanguage('categories', 'product') }}</a> / 
<span>{{ category.category }}</span>
</nav>
{% if category.description %}
<div class="desc">{{ category.description|raw }}</div>
{% endif %}
</div>
</div>
</section>
{# TITLE - CATEGORIES - NO IMAGE #}
{% else %}
{% embed 'website/includes/page-title.html.twig' with { pageTitle: category.category }%}
{% block migalhas %}
<a href="{{ path('home') }}">{{ getLanguage('home', 'product') }}</a> / 
<a href="{{ path('home') }}#categories-container">{{ getLanguage('categories', 'product') }}</a> / 
<span>{{ category.category }}</span>
{% endblock %}
{% endembed %}
{% endif %}
{# TITLE - SEARCH STRING #}
{% elseif search is defined %}
{% set emptySearch = search %}
{% embed 'website/includes/page-title.html.twig' %}
{% block header %}
<h1>{{ getLanguage('results_for', 'product') }} <em>“{{ search }}”</em></h1>
{% endblock %}
{% block migalhas %}
<a href="{{ path('home') }}">{{ getLanguage('home', 'product') }}</a> / <span>{{ getLanguage('search_results', 'product') }}</span>
{% endblock %}
{% endembed %}
{% endif %}
{# COUPON #}
{% if productCoupon is defined and productCoupon %}
<div class="coupon-success coupon-category">
<p>
{{ getLanguage('coupon_code', 'product') }}
<strong>{{ productCoupon.key }}</strong>
{{ getLanguage('successfully_applied', 'product') }}.
</p>
</div>
{% endif %}
<div class="{{ hasResult ? 'bg-alt' }}">
<div class="container">
<div class="results">
{# CONTEM ITENS #}
{% if hasResult %}
{% set firstShow = 6 %}
{% for section in dataSearch %}
{% set secLabel = section.name|lower %}
{% if section.items|length > 0 %}
<section class="js--results-section"
data-status="initial"
data-route="{{
path('productListSearchOrder', {
couponKey: (productCoupon is defined and productCoupon ? productCoupon.key : '')
})
}}"
data-tipo="{{ section.enum }}"
data-search="{{ search }}"
data-label="{{ secLabel }}"
data-init-offset="{{ section.items|length }}"
data-total="{{ section.total ?? '' }}"
data-category="{{ (category is defined)? category.id }}">
<header>
<h2>{{ ico(section.ico) }} {{ section.name }} ({{ section.total ?? '' }})</h2>
<div class="ordenacao">
<i class="loader">{{ ico('loader-wish') }}</i>
<select class="custom-select search-combo">
<option value="{{ enum('ProductOfferEnum::ORDER_BY') }}">
{{ getLanguage('order_by', 'product') }}
</option>
<option value="{{ enum('ProductOfferEnum::LOWEST_PRICE') }}">
{{ getLanguage('lowest_price', 'product') }}
</option>
<option value="{{ enum('ProductOfferEnum::BIGGEST_PRICE') }}">
{{ getLanguage('biggest_price', 'product') }}
</option>
<option value="{{ enum('ProductOfferEnum::MOST_RELEVANT') }}">
{{ getLanguage('most_relevant', 'product') }}
</option>
</select>
</div>
</header>
<div class="products-list js--results-container">
{% include 'website/product/product-results-items.html.twig' with {'items': section.items } %}
</div>
<div class="content-loader">
<i class="loader">{{ ico('loader-wish') }}</i>
</div>
<div class="todos">
{% if section.total > firstShow %}
<button type="button" class="js--search-load-more" data-label="{{ secLabel }}">
<span>{{ getLanguage('loading', 'util') }} …</span>
<span>{{ getLanguage('see_more', 'product') }}</span>
</button>
{% endif %}
</div>
</section>
{% endif %}
{% endfor %}
{# VAZIO #}
{% else %}
<div class="box-aviso">
<div class="aviso-img">
<div class="img-ico">
{{ ico('no-results') }}
</div>
</div>
<h2 class="titulo-aviso">
<span>
{{ getLanguage('not_find', 'product') }} {{ search }} … 
</span>
<img src="{{ cdn }}img/emoji_crying.png">
</h2>
<p class="sub">{{ getLanguage('check_if_word', 'product') }}</p>
<a href="{{ path('home') }}" class="btn-acao">
<i class="fas fa-arrow-left ico-left"></i>
{{ getLanguage('back_to_home', 'product') }}
</a>
</div>
{% endif %}
</div>
</div>
</div>
{% endblock %}