{% load custom_tags_core %}

{% get_filter_query_string request as filter_query_string %}

{% if is_paginated %}
    <nav>
        <ul class="pagination justify-content-center mb-2">
            {% if page_obj.has_previous %}
                <li class="page-item">
                    <a class="page-link" href="?{{ filter_query_string }}page={{ page_obj.previous_page_number }}">Anterior</a>
                </li>
            {% else %}
                <li class="page-item disabled">
                    <a class="page-link" href="#">Anterior</a>
                </li>
            {% endif %}
            
            {% for page in paginator.page_range %}
                {% get_status_page page paginator.num_pages page_obj.number as status_page %}

                {% if status_page is True %}
                    <li class="page-item {% if page == page_obj.number %}active{% endif %}">
                        <a class="page-link" href="?{{ filter_query_string }}page={{ page }}">{{ page }}</a>
                    </li>
                {% elif status_page is False %}
                    <li class="page-item disabled"><a class="page-link" href="#">…</a></li>
                {% endif %}
            {% endfor %}

            {% if page_obj.has_next %}
                <li class="page-item">
                    <a class="page-link" href="?{{ filter_query_string }}page={{ page_obj.next_page_number }}">Siguiente</a>
                </li>
            {% else %}
                <li class="page-item disabled">
                    <a class="page-link" href="#">Siguiente</a>
                </li>
            {% endif %}
        </ul>
    </nav>
{% endif %}

<p class="text-center mb-0">
    Mostrando {{ page_obj.start_index }} - {{ page_obj.end_index }} de {{ page_obj.paginator.count }} resultados en total.
</p>
