{{ define "admin_users.pages.tmpl" }}
<h1 class="title">Gestion des utilisateurs</h1>
<button class="button is-primary" 
        hx-get="/admin/user/new" 
        hx-target="#editForm" 
        hx-swap="innerHTML">
  ➕ Créer un utilisateur
</button>
<table class="table is-fullwidth is-striped">
  <thead>
    <tr>
      <th>ID</th>
      <th>Email</th>
      <th>Role</th>
      <th>Actif</th>
      <th>Actions</th>
    </tr>
  </thead>
  <tbody id="userList">
    {{ range .Users }}
    <tr>
      <td>{{ .ID }}</td>
      <td>{{ .Email }}</td>
      <td>{{ .Role }}</td>
      <td>{{ if .IsActive }}✅{{ else }}❌{{ end }}</td>
      <td>
        <button class="button is-small is-info" hx-get="/admin/user/{{ .ID }}/edit" hx-target="#editForm" hx-swap="innerHTML">✏️ Modifier</button>
        <button class="button is-small is-danger" hx-delete="/api/user/delete/{{ .ID }}" hx-confirm="Confirmer suppression ?" hx-target="#userList" hx-swap="outerHTML">🗑️ Supprimer</button>
      </td>
    </tr>
    {{ end }}
  </tbody>
</table>

<hr>
<div id="editForm"></div>
{{ end }}
