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

{% block title %}Administration > Jeux{% 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_game') }}">Gestion des jeux</a></li>
      </ul>
    </nav>

    <div class="block">
        <h1 class="title">Gestion des jeux</h1>
        <p class="subtitle">Liste des jeux de rôle connus dans l'application.</p>
    </div>

    <div class="block">
        <div class="is-grouped">
            <a class="button is-primary" href="{{ path('app_admin_game_add') }}">Ajouter un jeu</a>
        </div>
    </div>

    <div class="block">
        <table id="datatable" {{ stimulus_controller('datatables') }} class="table is-striped is-hoverable is-fullwidth">
            <thead>
            <tr>
                <th>Nom du jeu</th>
                <th>Description</th>
                <th>Genres</th>
                <th>Validé?</th>
                <th>Actions</th>
            </tr>
            </thead>
            <tbody>
            {% for game in games %}
                <tr>
                    <td><a href="{{ path('app_admin_game_edit', {id: game.id}) }}">{{ game.name }}</a></td>
                    <td>{{ game.description }}</td>
                    <td>{% for genre in game.genre %}<span class="tag is-info is-light">{{ genre.genre }}</span> {% endfor %}</td>
                    <td>{% if game.isValidByAdmin %}<span class="icon"><twig:ux:icon name="bi:check"/></span>{% else %}<a href="{{ path('app_admin_game_valid', {id: game.id}) }}" class="button"  data-turbo="false">Valider</a>{%endif%}</td>
                    <td>
                        <a class="button" href="{{ path('app_admin_game_edit', {id: game.id}) }}">Éditer</a>
                        <a class="button is-danger" data-id="{{ path('app_admin_game_delete', {'id': game.id})}}" href="#" {{ stimulus_controller('admin_confirm') }}>Supprimer</a>
                    </td>
                </tr>
            {% endfor %}
            </tbody>

        </table>
    </div>


{% endblock %}
