<%- include('../partials/header') %>
<%- include('../partials/adm-nav') %>

<section class="panel">
  <div class="panel-head">
    <h2>Liste des rôles</h2>
    <a href="/adm/roles/nouveau" class="btn btn-primary">Nouveau rôle</a>
  </div>

  <% if (roles.length === 0) { %>
    <p class="empty">Aucun rôle défini. <a href="/adm/roles/nouveau">Créer un rôle</a>.</p>
  <% } else { %>
    <div class="table-wrap">
      <table>
        <thead>
          <tr>
            <th>Nom</th>
            <th>Description</th>
            <th></th>
          </tr>
        </thead>
        <tbody>
          <% roles.forEach(function(role) { %>
            <tr>
              <td><strong><%= role.nom %></strong></td>
              <td><%= role.description || '—' %></td>
              <td class="actions">
                <a href="/adm/roles/<%= role.id %>/modifier" class="btn btn-ghost">Modifier</a>
                <form method="POST" action="/adm/roles/<%= role.id %>?_method=DELETE" onsubmit="return confirm('Supprimer ce rôle ?');">
                  <button type="submit" class="btn btn-danger">Supprimer</button>
                </form>
              </td>
            </tr>
          <% }) %>
        </tbody>
      </table>
    </div>
  <% } %>
</section>

<%- include('../partials/footer') %>
