{% extends "layout.html" %}
{% set active_id = "members" %}
{% from "_macros.html" import render_roles, render_pagination, render_event_organizer %}
{%- block title -%}
{{ _('Members') }}
{%- endblock -%}
{% block content %}

<h1>{{ _('Invitations') }}</h1>
<div class="my-4">
    {% if can_invite_users %}
    <a class="btn btn-outline-secondary my-1" href="{{ url_for('manage_admin_unit_member_invite', id=admin_unit.id) }}" role="button"><i class="fa fa-plus"></i> {{ _('Invite user') }}</a>
    {% endif %}
</div>
<ul class="list-group">
{% for invitation in invitations %}
    <li class="list-group-item">
        <div class="dropdown d-inline-block">
            <button class="btn btn-link dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">{{ invitation.email }}</button>
            <div class="dropdown-menu">
                <a class="dropdown-item" href="{{ url_for('manage_admin_unit_invitation_delete', id=invitation.id) }}">{{ _('Delete') }}&hellip;</a>
            </div>
        </div>
    </li>
{% endfor %}
</ul>

<h1>{{ _('Members') }}</h1>
<ul class="list-group">
{% for member in members %}
    <li class="list-group-item">
        <div class="dropdown d-inline-block">
            <button class="btn btn-link dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">{{ member.user.email }}</button>
            <div class="dropdown-menu">
                <a class="dropdown-item" href="{{ url_for('manage_admin_unit_member_update', id=member.id) }}">{{ _('Edit') }}</a>
                <a class="dropdown-item" href="{{ url_for('manage_admin_unit_member_delete', id=member.id) }}">{{ _('Delete') }}&hellip;</a>
            </div>
        </div>
        <small>{{ render_roles(member.roles)}}</small>
    </li>
{% endfor %}
</ul>

<div class="my-4">{{ render_pagination(pagination) }}</div>

{% endblock %}