<%- include('../layout', { title: "Berechtigungen" }) %>

<h1 class="mb-3">Berechtigungen</h1>

<form method="POST" action="/admin/permissions/create" class="d-flex gap-2 mb-3">
  <input name="name" class="form-control" placeholder="Neue Berechtigung">
  <button class="btn btn-success">Anlegen</button>
</form>

<table class="table table-striped table-hover">
  <thead>
    <tr>
      <th>ID</th>
      <th>Name</th>
      <th>Löschen</th>
    </tr>
  </thead>

  <tbody>
    <% permissions.forEach(p => { %>
      <tr>
        <td><%= p.id %></td>
        <td><%= p.name %></td>
        <td>
          <form method="POST" action="/admin/permissions/delete">
            <input type="hidden" name="id" value="<%= p.id %>">
            <button class="btn btn-sm btn-danger">Löschen</button>
          </form>
        </td>
      </tr>
    <% }) %>
  </tbody>
</table>

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