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

{% set users_pagination = pagination(manage_users_pagination, '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.info.isDeleted %} manage__user-item--deleted{% endif %}" style="--accent-colour: {{ user.colour }}">
                    <a href="{{ url('manage-user', {'user': user.info.id}) }}" class="manage__user-item__background"></a>

                    <div class="manage__user-item__container">
                        <div class="manage__user-item__avatar">{{ avatar(user.info.id, 40, user.info.name) }}</div>
                        <div class="manage__user-item__info">
                            <div class="manage__user-item__name">
                                {{ user.info.name }}
                            </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.info.createdTime|date('c') }}" title="{{ user.info.createdTime|date('r') }}">{{ user.info.createdTime|time_format }}</time> /
                                    <span>{{ user.info.registerRemoteAddressRaw }}</span>
                                </div>
                                {% if user.info.hasLastActive %}
                                    <div class="manage__user-item__detail">
                                        <i class="fas fa-user-clock fa-fw"></i>
                                        <time datetime="{{ user.info.lastActiveTime|date('c') }}" title="{{ user.info.lastActiveTime|date('r') }}">{{ user.info.lastActiveTime|time_format }}</time> /
                                        <span>{{ user.info.lastRemoteAddressRaw }}</span>
                                    </div>
                                {% endif %}
                                {% if user.info.isDeleted %}
                                    <div class="manage__user-item__detail">
                                        <i class="fas fa-trash-alt fa-fw"></i>
                                        <time datetime="{{ user.info.deletedTime|date('c') }}" title="{{ user.info.deletedTime|date('r') }}">{{ user.info.deletedTime|time_format }}</time>
                                    </div>
                                {% endif %}
                            </div>
                        </div>
                        <div class="manage__user-item__actions">
                            <a href="{{ url('user-profile', {'user': user.info.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 %}
