{% import "macros/product.html.twig" as productMacros %}
{% extends 'base.html.twig' %}
{% block title %}
{{"general.category"|trans ~ " triwu_u" }}
{% endblock %}
{% block mainClass %}pt-32{% endblock %}
{% block login %}{% endblock login %}
{% block content %}
{% include 'components/header/categories.html.twig' %}
<aside id="sidebar-mobile" class="z-20 fixed text-sm block w-full tablet:hidden bg-white p-4 overflow-x-auto whitespace-nowrap border-b border-gray-700">
<ul class="flex">
{% for categoryItem in categories %}
{%if (category is defined and category is not null and categoryItem.id == category.id )%}
<li class="">
{# Verificar si la categoría actual es la misma que la del ítem en el loop #}
{# Verificar si la categoría tiene subcategorías #}
{% set hasSubcategories = categoryItem.subcategories is not empty %}
{# Solo mostrar el detalle si la categoría tiene subcategorías #}
{% if hasSubcategories %}
{#
<li
class="cursor-pointer p-2 rounded no-arrow text-xs
{% if isCurrentCategory %}
text-black font-bold hover:text-white
{% else %}
text-black hover:text-white no-arrow
{% endif %}
">
<a href="{{ path('product_category_show', {'slug': categoryItem.slug}) }}"
class="uppercase">
{{ categoryItem.name | upper }}
</a>
</li>
#}
{% for subcategoryB in categoryItem.subcategories %}
{% set isCurrentSubCategory = false%}
{% if (subcategory is defined and subcategory is not null and subcategoryB.id == subcategory.id) %}
{% set isCurrentSubCategory = true%}
{%endif%}
<li class="text-sm hover:bg-primary/10 {% if isCurrentSubCategory %}!bg-primary/10{%endif%}" >
<a href="{{ path('product_category_show', {'slug': categoryItem.slug,'subcategorySlug': subcategoryB.slug}) }}"
class="block p-2 rounded text-xs
{% if (subcategory is defined and subcategory is not null and subcategoryB.id == subcategory.id) %}
text-primary hover:text-primary
{% else %}
text-black hover:text-primary
{% endif %}
">
{{ subcategoryB.name | capitalize }}
</a>
</li>
{% endfor %}
{% else %}
{#
<a href="{{ path('product_category_show', {'slug': categoryItem.slug}) }}"
class="block p-2 rounded text-xs
{% if isCurrentCategory %}
text-primary font-bold hover:text-primary
{% else %}
text-black hover:text-primary no-arrow
{% endif %}
uppercase">
{{ categoryItem.name | upper }}
</a>
#}
{% endif %}
</li>
{%endif%}
{% endfor %}
</ul>
</aside>
<div class="flex ">
<!-- Menú vertical de categorías -->
<aside id="sidebar-desktop" class="w-auto hidden desktop:block desktop:w-auto tablet:block tablet:w-auto bg-white p-4 overflow-y-auto h-screen sticky top-0 border-r border-gray-700">
<ul class="list-none">
{% for categoryItem in categories %}
{% set isCurrentCategory = null %}
{%if (category is defined and category is not null )%}
{% set isCurrentCategory = (categoryItem.id == category.id)%}
{%endif%}
{% if hasSubcategories is defined%}{%else%}<a href="{{ path('product_category_show', {'slug': categoryItem.slug}) }}">{%endif%}
<li class="pb-2 pt-2 border-b border-gray-300 hover:bg-primary/10 {% if isCurrentCategory %}!bg-primary/10{%endif%}">
{# Verificar si la categoría actual es la misma que la del ítem en el loop #}
{# Verificar si la categoría tiene subcategorías #}
{% set hasSubcategories = categoryItem.subcategories is not empty %}
{# Solo mostrar el detalle si la categoría tiene subcategorías #}
{% if hasSubcategories %}
<div class="group">
<a href="{{ path('product_category_show', {'slug': categoryItem.slug}) }}" >
<div class="cursor-pointer p-2 rounded text-xs {% if isCurrentCategory %} text-primary font-bold hover:text-primary
{% else %}text-black hover:text-primary {% endif %}
">
<span class="uppercase">
{{ categoryItem.name | upper }}
</span>
</div>
</a>
<ul class="ml-4 {% if isCurrentCategory %}block{%else%}hidden{%endif%}">
{% for subcategoryB in categoryItem.subcategories %}
<li class="text-sm">
<a href="{{ path('product_category_show', {'slug': categoryItem.slug,'subcategorySlug': subcategoryB.slug}) }}"
class="block p-2 rounded text-xs
{% if (subcategory is defined and subcategory is not null and subcategoryB.id == subcategory.id) %}
text-primary hover:text-primary
{% else %}
text-black hover:text-primary
{% endif %}
">
{{ subcategoryB.name | capitalize }}
</a>
</li>
{% endfor %}
</ul>
</div>
{% else %}
<a href="{{ path('product_category_show', {'slug': categoryItem.slug}) }}"
class="block p-2 rounded text-xs
{% if isCurrentCategory %}
text-primary font-bold hover:text-primary
{% else %}
text-black hover:text-primary no-arrow
{% endif %}
uppercase">
{{ categoryItem.name | upper }}
</a>
{% endif %}
</li>{% if hasSubcategories is defined%}{%else%}</a>{%endif%}
{% endfor %}
</ul>
</aside>
<section class="mobile:mt-20 relative tablet:max-w-screen-xl mx-auto mb-12 px-edge ">
<section class="space-y-3 pt-2">
{% if subcategory is defined and subcategory is not null %}
<h5><a href="{{ path('app_index') }}" class="hover:text-primary">{{'general.categorias' | trans}}</a> > <a href="{{ path('product_category_show', {'slug': category.slug}) }}" class="hover:text-primary">{{category.name | capitalize}}</a> > <a href="{{ path('product_category_show', {'slug': category.slug,'subcategorySlug': subcategory.slug}) }}" class="text-primary">{{subcategory.name | capitalize}}</a></h5>
{%else%}
<h5><a href="{{ path('app_index') }}" class="hover:text-primary">{{'general.categorias' | trans}}</a> > <a href="{{ path('product_category_show', {'slug': category.slug}) }}" class="text-primary">{{category.name | capitalize}}</a></h5>
{%endif%}
<h3 class="text-2xl tablet:text-3xl">
<span class="font-bold">{{ subcategory is defined and subcategory is not null ? subcategory.name : category.name }}</span>
</h3>
{#
{{ form_start(searchForm) }}
{{ form_row(searchForm.province) }}
<button type="submit">Filtrar</button>
{{ form_end(searchForm) }}
#}
<div class="pb-edge grid gap-3 grid-cols-1 tablet:grid-cols-2 laptop:grid-cols-3 tablet:gap-6 relative z-10">
{% for product in products %}
{{ productMacros.productCard(product,groupsProducts) }}
{% endfor %}
</div>
</section>
</section>
</div>
<div id="ConfirmProduct" data-modal="confirmProduct" tabindex="-1" aria-hidden="true" class="modal-app">
<div class="modal-app__backdrop"></div>
<div class="modal-app__container">
<div class="modal-app__content">
<header>
<h3 class="text-xl font-bold desktop:text-2xl">
{{ "product.confirm.title" | trans }}
</h3>
</header>
<main class="leading-5 mt-3 mb-4">
<p>{{ "product.confirm.desc" | trans }} </p>
</main>
<a href="{{ path('app_product_add_to_shopping_cart', {'id': '#', 'isIndividual': false, 'newCart': true}) }}" class="ConfirmButton btn btn--primary btn--md btn-buy product-card__price-block__btn">
{{ "product.confirm.btn" | trans }}
</a>
<button id="CloseConfirmProduct" type="button" class="btn btn--md w-full mt-1">
{{ "product.confirm.cancel" | trans }}
</button>
</div>
</div>
</div>
{% endblock %}