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

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

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

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

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

<%= paginate @managers %>
