{% extends 'manage/users/master.twig' %}
{% from 'macros.twig' import pagination, container_title, avatar %}

{% set users_pagination = pagination(manage_users_pagination, url('manage-users')) %}

{% block manage_content %}
    <div class="container manage__users">
        {{ container_title('<i class="fas fa-users fa-fw"></i> Users') }}

        {% if users_pagination|trim|length > 0 %}
            <div class="manage__users__pagination">
                {{ users_pagination }}
            </div>
        {% endif %}

        <div class="manage__users__collection">
            {% for user in manage_users %}
                <div class="manage__user-item{% if user.isDeleted %} manage__user-item--deleted{% endif %}" style="--accent-colour: {{ user.colour }}">
                    <a href="{{ url('manage-user', {'user': user.id}) }}" class="manage__user-item__background"></a>

                    <div class="manage__user-item__container">
                        <div class="manage__user-item__avatar">{{ avatar(user.id, 40, user.username) }}</div>
                        <div class="manage__user-item__info">
                            <div class="manage__user-item__name">
                                {{ user.username }}
                            </div>
                            <div class="manage__user-item__details">
                                <div class="manage__user-item__detail">
                                    <i class="fas fa-user-plus fa-fw"></i>
                                    <time datetime="{{ user.createdTime|date('c') }}" title="{{ user.createdTime|date('r') }}">{{ user.createdTime|time_format }}</time> /
                                    <span>{{ user.registerRemoteAddress }}</span>
                                </div>
                                <div class="manage__user-item__detail">
                                    <i class="fas fa-user-clock fa-fw"></i>
                                    <time datetime="{{ user.activeTime|date('c') }}" title="{{ user.activeTime|date('r') }}">{{ user.activeTime|time_format }}</time> /
                                    <span>{{ user.lastRemoteAddress }}</span>
                                </div>
                                {% if user.isDeleted %}
                                    <div class="manage__user-item__detail">
                                        <i class="fas fa-trash-alt fa-fw"></i>
                                        <time datetime="{{ user.deletedTime|date('c') }}" title="{{ user.deletedTime|date('r') }}">{{ user.deletedTime|time_format }}</time>
                                    </div>
                                {% endif %}
                            </div>
                        </div>
                        <div class="manage__user-item__actions">
                            <a href="{{ url('user-profile', {'user': user.id}) }}" class="manage__user-item__action" title="Profile">
                                <i class="fas fa-user fa-fw"></i>
                            </a>
                        </div>
                    </div>
                </div>
            {% endfor %}
        </div>

        {% if users_pagination|trim|length > 0 %}
            <div class="manage__users__pagination">
                {{ users_pagination }}
            </div>
        {% endif %}
    </div>
{% endblock %}
