<h2><%= t("admin.poll_officers.index.title") %></h2>

<div class="row">
  <%= form_tag search_admin_officers_path, method: :get, remote: true  do %>
    <div class="small-12 medium-6 column">
      <%= text_field_tag :email, '', placeholder: t('admin.poll_officers.search.email_placeholder') %>
    </div>
    <div class="small-12 medium-6 column">
      <%= submit_tag t('admin.poll_officers.search.search'), class: 'button' %>
    </div>
  <% end %>
</div>

<div id="search-result" class="row"></div>

<h3><%= page_entries_info @officers %></h3>

<table id="officers">
  <% @officers.each do |officer| %>
    <tr>
      <td>
        <%= officer.name %>
      </td>
      <td>
        <%= officer.email %>
      </td>
      <td class="text-right">
        <% if officer.persisted? %>
          <%= link_to t('admin.poll_officers.officer.delete'),
                      admin_officer_path(officer),
                      method: :delete,
                      class: "button hollow alert"
          %>
        <% else %>
          <%= link_to t('admin.poll_officers.officer.add'),
                      { controller: "admin/poll/officers", action: :create,
                        user_id: officer.user_id },
                      method: :post,
                      class: "button success" %>
        <% end %>
      </td>
    </tr>
  <% end %>
</table>

<%= paginate @officers %>
