<%- title t('.title', resource: devise_i18n_fix_model_name_case(resource.model_name.human, i18n_key: 'registrations.edit.title')) %>

<h2><%= t('.title', resource: devise_i18n_fix_model_name_case(resource.model_name.human, i18n_key: 'registrations.edit.title')) %></h2>

<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
  <%= render 'devise/shared/error_messages', resource: resource %>

  <% syncing_identities = current_user.identities.select(&:syncing)
  if syncing_identities.any? %>
    <p>
      <%= it('users.update_sync_warning', providers: syncing_identities.map(&:pretty_provider).to_sentence, edit_sign_in_link: user_edit_sign_in_path, count: syncing_identities.count) %>
    </p>
  <% end %>

  <div class="form-control">
    <%= f.label :name %>
    <br>
    <%= f.text_field :name, size: 50, maxlength: 50, required: :required %>
  </div>

  <div><%= f.label :email %><br>
  <%= f.email_field :email, autocomplete: 'email' %></div>

  <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
    <div><%= t('.currently_waiting_confirmation_for_email', email: resource.unconfirmed_email) %></div>
  <% end %>

  <% if UserRestrictionService.new(current_user).allow_posting_profile? %>
    <div class="form-control">
      <%= f.label :profile %>
      <%= with_user_text_preview_for_form(form: f, markup_name: :profile_markup) do
        f.text_area :profile
      end %>
    </div>
  <% end %>

  <div>
    <label><%= t('activerecord.attributes.user.locale') %></label><br>
    <select name="user[locale_id]">
      <option value="" <% if @user.locale_id.nil? %> selected<% end %>><%= t('users.locale_prompt') %></option>
      <% Locale.ui_available.each do |locale| %>
        <option value="<%= locale.id %>" <% if @user.locale_id == locale.id %> selected<% end %>><%= locale.display_text(in_locale: request_locale) %></option>
      <% end %>
      <option disabled>---</option>
      <% Locale.all.each do |locale| %>
        <option value="<%= locale.id %>"<% if @user.locale_id == locale.id %> selected<% end %>><%= locale.display_text(in_locale: request_locale) %></option>
      <% end %>
    </select>
  </div>

  <div class="form-control">
    <%= f.label :preferred_markup %>
    <span class="label-note">
      <%= t('users.preferred_markup_description') %>
    </span><br>
    <%= f.radio_button(:preferred_markup, 'html') %>HTML<br>
    <%= f.radio_button(:preferred_markup, 'markdown') %><%= link_to 'Markdown', 'http://daringfireball.net/projects/markdown/basics', {target: 'markup_choice'} %>
  </div>

  <div>
    <%= f.label :show_ads %><br>
    <%= f.check_box(:show_ads) %><label for="user_show_ads"><%= t('users.show_ads_description', site_name: site_name) %></label>
  </div>

  <div>
    <%= f.label :show_sensitive %><br>
    <%= f.check_box(:show_sensitive) %><label for="user_show_sensitive"><%= t('users.show_sensitive_description') %></label>
  </div>

  <div>
    <%= f.label :filter_locale_default %><br>
    <%= f.check_box :filter_locale_default %><%= f.label :filter_locale_default, t('users.filter_locale_default_description') %>
  </div>

  <p><%= f.submit t('.update') %></p>
<% end %>
