{% extends 'manage/users/master.twig' %}
{% from 'macros.twig' import pagination, container_title %}
{% from 'user/macros.twig' import user_profile_warning %}
{% from '_layout/input.twig' import input_text, input_csrf, input_select, input_hidden %}

{% block manage_content %}
    <form class="container container--lazy" action="{{ url('manage-users-warnings') }}" method="post">
        {{ container_title('<i class="fas fa-users fa-fw"></i> Filters') }}
        {{ input_text('lookup', null, warnings.user.username|default(''), 'text', 'Enter a username') }}
        <button class="input__button">Filter</button>
    </form>

    {% if warnings.notices|length > 0 %}
        <div class="warning">
            <div class="warning__content">
                {% for notice in warnings.notices %}
                    {{ notice }}
                {% endfor %}
            </div>
        </div>
    {% endif %}

    {% if warnings.user is not null %}
        <form class="container container--lazy" method="post" action="">
            {{ container_title('<i class="fas fa-user-shield fa-fw"></i> Warn ' ~ warnings.user.username) }}
            {{ input_csrf() }}
            {{ input_hidden('warning[user]', warnings.user.id) }}

            {{ input_select('warning[type]', warnings.types) }}
            {{ input_text('warning[note]', '', '', 'text', 'Public note') }}
            {{ input_select('warning[duration]', warnings.durations) }}
            {{ input_text('warning[duration_custom]', '', '', 'text', 'Custom Duration') }}
            <button class="input__button">Add</button><br>

            <textarea class="input__textarea" name="warning[private]" placeholder="Private note"></textarea>
        </form>
    {% endif %}

    <div class="container container--lazy">
        {{ container_title('<i class="fas fa-exclamation-circle fa-fw"></i> Warnings') }}
        {% set warnpag = pagination(warnings.pagination, url('manage-users-warnings', {'user': warnings.user.id|default(0)})) %}

        {{ warnpag }}

        <div class="profile__warnings__container">
            <div class="profile__warning profile__warning--extendo">
                <div class="profile__warning__background"></div>

                <div class="profile__warning__tools">
                    <div class="profile__warning__user">
                        <div class="profile__warning__user__username">
                            User
                        </div>
                        <div class="profile__warning__user__ip">
                            User IP
                        </div>
                    </div>

                    <div class="profile__warning__user">
                        <div class="profile__warning__user__username">
                            Issuer
                        </div>
                        <div class="profile__warning__user__ip">
                            Issuer IP
                        </div>
                    </div>
                </div>

                <div class="profile__warning__content">
                    <div class="profile__warning__type">
                        Type
                    </div>

                    <div class="profile__warning__created">
                        Created
                    </div>

                    <div class="profile__warning__duration">
                        Duration
                    </div>

                    <div class="profile__warning__note">
                        Note
                    </div>
                </div>
            </div>

            {% for warning in warnings.list %}
                {{ user_profile_warning(warning, true, true, csrf_token()) }}
            {% endfor %}
        </div>

        {{ warnpag }}
    </div>
{% endblock %}
