{% extends "dictionary/base.html" %}
{% load i18n %}

{% block title %}{{ title }}{% if request.GET.search.strip %} - {% trans "search" %}: {{ request.GET.search.strip }}{% endif %}{% if page_obj.number > 1 %} - {% trans "page" %} {{ page_obj.number }}{% endif %}{% endblock %}

{% block content %}
    <h1 class="h4"><strong>{% trans "following/blocked" context "titleblock" %}</strong></h1>

    <ul class="nav nav-tabs my-3">
        <li class="nav-item">
            <a class="nav-link {% if tab == "following" %}active{% endif %}" href="{% url 'people' %}">{% trans "following" context "people" %}</a>
        </li>
        <li class="nav-item">
            <a class="nav-link {% if tab == "blocked" %}active{% endif %}" href="{% url 'people-tab' 'blocked' %}">{% trans "blocked" context "people" %}</a>
        </li>
    </ul>

    <section class="mt-3">
        <form method="get" action="{{ request.path }}">
            <div class="input-group">
                <input name="search" type="text" class="form-control border-0 bg-light" placeholder="{% trans "search" %}" aria-label="{% trans "search" %}" value="{% firstof request.GET.search.strip %}">
                <div class="input-group-append">
                    <button class="btn btn-django-link" type="submit">{% trans "go" %}</button>
                </div>
            </div>
        </form>

        {% with object_list as authors %}
            {% if authors %}
                <ul class="list-group list-group-flush my-3">
                    {% if tab == "following" %}
                        {% for author in authors %}
                            <li class="list-group-item d-flex justify-content-between border-0" data-username="{{ author.username }}">
                                <a href="{{ author.get_absolute_url }}">{{ author.username }}</a>
                                <span class="follow-user-trigger"><a role="button" tabindex="0">{% trans "unfollow" %}</a></span>
                            </li>
                        {% endfor %}
                    {% elif tab == "blocked" %}
                        {% for author in authors %}
                            <li class="list-group-item d-flex justify-content-between border-0">
                                <a href="{{ author.get_absolute_url }}">{{ author.username }}</a>
                                <a role="button" tabindex="0" class="block-user-trigger" data-username="{{ author.username }}">{% trans "remove block" %}</a>
                            </li>
                        {% endfor %}
                    {% endif %}
                </ul>
                {% include "dictionary/includes/paginaton.html" with paginator=page_obj index="yes" %}
            {% else %}
                <div class="bg-light p-3 mt-3 rounded">{% trans "nothing here" %}</div>
            {% endif %}
        {% endwith %}
    </section>
{% endblock %}
