<%= form_with(path: user_do_ban_path) do |f| %>
  <% if @user.banned? && @user.non_locked_scripts.none? %>
    <p>(User already banned.)</p>
  <% else %>
    <% if @user.banned? %>
      <p>
        <%= @user.name %> has already been banned, but you can still deleted their non-locked scripts.
      </p>
    <% end %>
    <p>
      <% if @user.banned? %>
        <label>Why are you deleting <%= @user.name %>'s scripts?</label>
      <% else %>
        <label>Why are you banning <%= @user.name %>?</label>
      <% end %>
    </p>

    <div class="form-control radio-group">
      <% Report::NON_SCRIPT_REASONS.each do |reason| %>
        <div>
          <%= f.radio_button(:reason, reason, required: true) %> <%= f.label :reason, it("reports.reason.#{reason}", antifeature_link: help_antifeatures_path), class: 'radio-label', value: reason %>
        </div>
      <% end %>
    </div>

    <%= f.text_area :explanation, placeholder: t('reports.explanation_placeholder'), rows: 5, cols: 100, maxlength: 500 %>

    <% if @user.non_locked_scripts.any? %>
      <p><%= @user.name %> has <%= @user.non_locked_scripts.count %> non-locked scripts:</p>
      <ul>
        <% @user.non_locked_scripts.each do |script| %>
          <li><%= link_to script.name(request_locale), script %></li>
        <% end %>
      </ul>
      <p>
        <% unless @user.banned? %>
          <input type="radio" required id="delete_type_0" name="delete_type" value="" checked> <label for="delete_type_0">Don't delete</label><br>
        <% end %>
        <% (Script.delete_types.keys - ['redirect']).each do |k| %>
          <input type="radio" required id="delete_type_<%= k %>" name="delete_type" value="<%= k %>" <% if @user.banned? && k == 'keep' %> checked<% end %>>
          <label for="delete_type_<%= k %>"><%= t("scripts.delete_update_behaviours.#{k}") %></label><br>
        <% end %>
      </p>
    <% end %>
    <% if @user.comments.not_deleted.any? %>
      <p>
        <input type="checkbox" name="delete_comments" id="delete_comments" value="1"> <label for="delete_comments">Delete user's <%= link_to "#{@user.comments.not_deleted.count} #{'comment'.pluralize(@user.comments.not_deleted.count)}", discussions_path(user: @user.id) %></label>
      </p>
    <% end %>
    <input type="submit" value="Ban">
  <% end %>
<% end %>
