<div id="accounts-table">
  {{ if .accounts }}
  <table class="table is-striped is-fullwidth">
    <thead>
      <tr>
        <th>Host</th>
        <th>Utilisateur</th>
        <th>Actif</th>
        <th>Token</th>
        <th>Expire</th>
        <th>Actions</th>
      </tr>
    </thead>
    <tbody>
      {{ range .accounts }}
      <tr>
        <td>{{ .Host }}</td>
        <td>{{ .Username }}</td>
        <td>{{ if .IsActive }}✅{{ else }}❌{{ end }}</td>
        <td><code>{{ .AccessToken | printf "%.12s..." }}</code></td>
        <td>{{ .ExpiresAt.Format "02/01/2006 15:04" }}</td>
        <td>
          <div class="buttons">
            <a class="button is-danger is-light"
               hx-get="/godownloader/settings/delete?id={{ .ID }}"
              >Supprimer</a>
            <a class="button is-info is-light"
               hx-get="/godownloader/settings/toggle?id={{ .ID }}"
               hx-target="#accounts-table"
               hx-swap="outerHTML">
              {{ if .IsActive }}Désactiver{{ else }}Activer{{ end }}
            </a>
          </div>
        </td>
      </tr>
      {{ end }}
    </tbody>
  </table>
  {{ else }}
    <p>Aucun compte enregistré.</p>
  {{ end }}
</div>
