<div class="page-header d-print-none">
  <div class="row align-items-center">
    <div class="col">
      <h2 class="page-title"><%= title %></h2>
    </div>
    <div class="col-auto ms-auto">
      <a href="/admin/flyers/new" class="btn btn-primary">Add Flyer</a>
    </div>
  </div>
</div>
<div class="card">
  <%- include('../../partials/adminPaginationTop') %>
  <div class="table-responsive">
    <table class="table table-vcenter card-table">
      <thead>
        <tr>
          <th>Image</th>
          <th>Title</th>
          <th>Order</th>
          <th>Created</th>
          <th>Status</th>
          <th class="w-1"></th>
        </tr>
      </thead>
      <tbody>
        <% if (flyers.length === 0) { %>
        <tr><td colspan="6" class="text-center text-secondary">No flyers yet</td></tr>
        <% } %>
        <% flyers.forEach(function(flyer) { %>
        <tr>
          <td><img src="<%= flyer.imageUrl %>" alt="" style="height:48px;border-radius:4px;"></td>
          <td><%= flyer.title %></td>
          <td><%= flyer.sortOrder %></td>
          <td><%- include('../../partials/adminDateTime', { value: flyer.createdAt }) %></td>
          <td><span class="badge bg-<%= flyer.isActive ? 'success' : 'secondary' %>"><%= flyer.isActive ? 'Active' : 'Inactive' %></span></td>
          <td>
            <div class="btn-list flex-nowrap">
            <a href="/admin/flyers/<%= flyer._id %>/edit" class="btn btn-sm btn-action-icon" title="Edit"><i class="ti ti-pencil"></i></a>
            <form action="/admin/flyers/<%= flyer._id %>/delete" method="post" class="d-inline delete-form"
              data-delete-title="Delete flyer?"
              data-delete-message="This will permanently remove &quot;<%= flyer.title %>&quot; from the home carousel."
              data-delete-consequences="Flyer removed from mobile home screen|Uploaded image file deleted|Action recorded in Audit Logs with full snapshot">
              <button type="submit" class="btn btn-sm btn-action-icon btn-outline-danger" title="Delete"><i class="ti ti-trash"></i></button>
            </form>
            </div>
          </td>
        </tr>
        <% }); %>
      </tbody>
    </table>
  </div>
  <%- include('../../partials/adminPaginationBottom') %>
</div>
