<div class="grid">
  <%= render Components::Backend::Card.new(title: "identities") do %>
    <%= form_with url: backend_identities_path, method: :get, local: true do |f| %>
      <div class="form-row">
        <%= f.search_field :search, value: params[:search], placeholder: "search by name, email, slack id..." %>
        <%= render Components::Backend::ActionButton.new(hotkey: "↵") { "search" } %>
        <% if params[:search].present? %>
          <%= link_to backend_identities_path do %>
            <%= render Components::Backend::ActionButton.new { "CLR" } %>
          <% end %>
        <% end %>
      </div>
    <% end %>
    <% if params[:search].present? %>
      <p>found <%= pluralize(@identities.total_count, 'identity') %> matching "<%= params[:search] %>"</p>
    <% end %>
    <hr>
    <div class="table-container" data-navigable-list>
      <table>
        <thead>
          <tr>
            <th>name</th>
            <th>email</th>
            <th>status</th>
            <th>ysws</th>
          </tr>
        </thead>
        <tbody>
          <% @identities.each do |identity| %>
            <tr data-navigable-item>
              <td><%= link_to backend_identity_path(identity) do %><%= render identity %><% end %></td>
              <td><%= identity.primary_email %></td>
              <td><span class="badge <%= identity.verification_status == 'verified' ? 'success' : 'pending' %>"><%= identity.verification_status %></span></td>
              <td><%= identity.ysws_eligible.nil? ? "?" : render_checkbox(identity.ysws_eligible) %></td>
            </tr>
          <% end %>
        </tbody>
      </table>
    </div>
    <%= paginate @identities, params: { search: params[:search] } %>
  <% end %>
</div>
