<%
  define_admin_breadcrumbs do
    add_admin_breadcrumb('竞赛列表', admins_competitions_path)
    add_admin_breadcrumb(@competition.name)
  end
%>

<div class="box search-form-container flex-column mb-0 pb-0 competition-prize-user-form">
  <ul class="nav nav-tabs w-100 search-form-tabs">
    <li class="nav-item">
      <%= link_to '报名列表', admins_competition_enroll_lists_path(@competition), class: "nav-link search-form-tab" %>
    </li>
    <li class="nav-item">
      <%= link_to '获奖证书审批', admins_competition_competition_prize_users_path(@competition), class: "nav-link search-form-tab active" %>
    </li>
  </ul>

  <div class="d-flex">
    <%= form_tag(admins_competition_competition_prize_users_path(unsafe_params), method: :get, class: 'search-form mt-3 flex-1 d-flex align-items-end', remote: true) do %>
      <div class="form-group mb-0 mr-3">
        <label for="status">奖项：</label>
        <% prize_options = [['不限', '']] + @competition.competition_prizes.map{ |p| [p.name, p.id] } %>
        <%= select_tag(:prize_id, options_for_select(prize_options), class: 'form-control') %>
      </div>

      <% auth_options = [['不限', ''], %w(未认证 not_authed), %w(待认证 authing), %w(已认证 authed)] %>
      <div class="form-group mb-0 mr-3">
        <label for="status">实名认证状态：</label>
        <%= select_tag(:real_name_auth, options_for_select(auth_options), class: 'form-control') %>
      </div>
      <div class="form-group mb-0 mr-3">
        <label for="status">职业认证状态：</label>
        <%= select_tag(:professional_auth, options_for_select(auth_options), class: 'form-control') %>
      </div>

      <div class="form-group mb-0 mr-3">
        <label for="status">职业：</label>
        <%- identity_options = [['不限', ''], %w(教师 0), %w(学生 1)] %>
        <%= select_tag(:identity, options_for_select(identity_options), class: 'form-control') %>
      </div>

      <div class="form-group mb-0 mr-3">
        <label for="status">审批状态：</label>
        <%- status_options = [['不限', ''], %w(未审批 pending), %w(已审批 approved)] %>
        <%= select_tag(:status, options_for_select(status_options), class: 'form-control') %>
      </div>

      <%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '战队/学校名称检索') %>

      <%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
      <%= link_to '清除', admins_competition_competition_prize_users_path(@competition), class: "btn btn-default",'data-disable-with': '清除中...' %>
    <% end %>

    <div class="mt-3 d-flex align-items-end">
      <%= link_to '导出', admins_competition_competition_prize_users_path(competition_id: @competition.id, format: :xlsx), class: 'btn btn-primary' %>
      <%#= javascript_void_link '导出', class: 'btn btn-primary', 'data-url': admins_competition_competition_prize_users_path(competition_id: @competition.id, format: :xlsx) %>
    </div>

  </div>
</div>

<div class="box admin-list-container competition-prize-user-list-container">
  <%= render(partial: 'admins/competition_prize_users/shared/list', locals: { prize_users: @prize_users }) %>
</div>