{% extends 'bulma.html.twig' %}

{% block title %}Administration > Utilisateurs{% endblock %}

{% block content %}

    <nav class="breadcrumb has-arrow-separator" aria-label="breadcrumbs">
      <ul>
        <li><a href="{{ path('app_main') }}">Accueil</a></li>
        <li><a href="{{ path('app_admin') }}">Administration</a></li>
        <li class="is-active"><a href="{{ path('app_admin_gm') }}">Gestion des meneur(euse)s de jeu</a></li>
      </ul>
    </nav>

    <div class="block">
        <h1 class="title">Gestion des meneur(euse)s de jeu</h1>
        <p class="subtitle">Liste des MJ enregistré(e)s dans l'application.</p>
    </div>

    <div class="block">
        <div class="is-grouped">
            <a class="button is-primary" href="{{ path('app_admin_gamemaster_add') }}">Ajouter un(e) meneur(euse) de jeu</a>
            <a class="button" data-turbo="false" href="{{ path('app_admin_gamemaster_link') }}">Associer les MJ à leurs comptes</a>
        </div>
    </div>

    <div class="block">
        <table id="datatable" {{ stimulus_controller('datatables') }} class="table is-striped is-hoverable is-fullwidth">
            <thead>
            <tr>
                <th>Identité</th>
                <th>Email</th>
                <th>Compte lié</th>
                <th>Actions</th>
            </tr>
            </thead>
            <tbody>
            {% for gamemaster in gamemasters %}
                <tr>
                    <td><a href="{{ path('app_admin_gamemaster_edit', {id: gamemaster.id}) }}">{{ gamemaster.preferedName }}</a></td>
                    <td><span class="icon-text">{{ gamemaster.email }}</span></td>
                    <td>{% if gamemaster.getLinkToUser %}<a href="{{ path('app_admin_user_edit', {id: gamemaster.getLinkToUser.id}) }}" class="button">Éditer le compte lié{% else %}aucun{% endif %}</a></td>
                    <td>
                        <a class="button" href="{{ path('app_admin_gamemaster_edit', {id: gamemaster.id}) }}">Éditer</a>
                        <a class="button is-danger" data-id="{{ path('app_admin_gamemaster_delete', {'id': gamemaster.id})}}" href="#" {{ stimulus_controller('admin_confirm') }}>Supprimer</a>
                    </td>
                </tr>
            {% endfor %}
            </tbody>

        </table>
    </div>


{% endblock %}
