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

{% block title %}Administration > Games{% 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_event') }}">Gestion des événements</a></li>
      </ul>
    </nav>

    <div class="block">
        <h1 class="title">Gestion des événement</h1>
        <p class="subtitle">Liste des événements.</p>
    </div>

    <div class="block">
        <div class="is-grouped">
            <a class="button is-primary" href="{{ path('app_admin_event_add') }}">Ajouter un événement</a>
        </div>
    </div>

        <div class="block">
        <table id="datatable" {{ stimulus_controller('datatables') }} class="table is-striped is-hoverable is-fullwidth">
            <thead>
            <tr>
                <th>Nom</th>
                <th>Dates</th>
                <th>Actions</th>
            </tr>
            </thead>
            <tbody>
            {% for event in events %}
                <tr>
                    <td><a href="{{ path('app_admin_event_edit', {id: event.id}) }}">{{ event.name }}</a></td>
                    <td>du {{ event.startOn|date('d/m/Y H:i', app_timezone) }}<br/>au {{ event.endOn|date('d/m/Y H:i', app_timezone) }}</td>
                    <td>
                        <a class="button" href="{{ path('app_admin_event_edit', {id: event.id}) }}">Éditer</a>
                        <a class="button is-primary" href="{{ path('app_admin_event_config', {id: event.id}) }}">Configurer</a>
                        {% if event.published %}
                        <a class="button" href="{{ path('app_manage_planning', {id: event.id}) }}">Gérer</a>
                        {% else %}
                        <button class="button" disabled>Gérer</button>
                        {% endif %}
                        <a class="button is-danger" data-id="{{ path('app_admin_event_delete', {'id': event.id})}}" href="#" {{ stimulus_controller('admin_confirm') }}>Supprimer</a>
                    </td>
                </tr>
            {% endfor %}
            </tbody>

        </table>
    </div>

{% endblock %}
