<% if policy(@user).change_username? %>
  <%= render "admin_change_username" %>
<% else %>
  <!--Descriptive page name, messages and instructions-->
  <h2 class="heading"><%= t(".page_heading") %></h2>
  <%= error_messages_for :user %>
  <div class="caution notice">
    <p>
      <strong><%= t(".caution") %></strong>
      <%= t(".change_window", count: ArchiveConfig.USER_RENAME_LIMIT_DAYS) %>
      <% if @user.renamed_at %>
        <%= t(".last_renamed", renamed_at: l(@user.renamed_at)) %>
      <% end %>
    </p>
    <p>
      <%= t(".more_info_html",
            account_faq_link: link_to(t(".account_faq"), archive_faq_path("your-account", anchor: "namechange")),
            contact_support_link: link_to(t(".contact_support"), new_feedback_report_path)) %>
    </p>
  </div>
  <p class="note">
    <%= t(".new_pseud_instead_html", create_a_new_pseud_link: link_to(t(".create_a_new_pseud"), new_user_pseud_path(@user))) %>
  </p>
  <!--/descriptions-->

  <!--subnav-->
  <%= render "edit_header_navigation" %>
  <!--/subnav-->

  <!--main content-->

  <%= form_tag changed_username_user_path(@user), autocomplete: "off" do %>
    <legend><%= t(".legend") %></legend>
    <h3 class="landmark heading"><%= t(".heading") %></h3>
    <dl>
      <dt><%= t(".current_username") %></dt>
      <dd><p class="important informational"><%= @user.login %></p></dd>
      <dt><%= label_tag :new_login, t(".new_username") %></dt>
      <dd>
        <%= text_field_tag :new_login, @new_login, "aria-describedby": "new-login-field-description" %>
        <p class="footnote" id="new-login-field-description">
          <%= t(".username_requirements",
                minimum: ArchiveConfig.LOGIN_LENGTH_MIN,
                maximum: ArchiveConfig.LOGIN_LENGTH_MAX) %>
        </p>
      </dd>
      <dt><%= label_tag :password, t(".password") %></dt>
      <dd><%= password_field_tag :password, nil %></dd>
      <dt class="landmark"><%= t(".submit_landmark") %></dt>
      <dd class="submit actions">
        <%= submit_tag t(".submit"), data: { confirm: t(".confirm") } %>
      </dd>
    </dl>
  <% end %>
<% end %>
