<div id="c-user-name-change-requests">
  <h1>Name Change Request</h1>
  
  <section>
    <p><%= @change_request.original_name %> is requesting to change their name to <%= @change_request.desired_name %>.</p>
  </section>
  
  <section>
    <h2>Reason</h2>
    <p><%= @change_request.change_reason %></p>
  </section>

  <section>
    <h2>Feedback</h2>
    <ul>
      <% @change_request.feedback.each do |feedback| %>
        <li class="feedback-category-<%= feedback.category %>">
          <p><%= feedback.body %></p>
          <p class="author">Submitted by <%= feedback.creator.name %> <%= time_ago_in_words_tagged feedback.created_at %></p>
        </li>
      <% end %>
    </ul>
  </section>

  <section>
    <h2>Statistics</h2>
    <ul>
      <li>Level: <%= @change_request.user.level_string %></li>
      <li>Uploads: <%= link_to @change_request.user.post_upload_count, posts_path("user:#{@change_request.user.name}") %></li>
      <li>Updates: <%= link_to @change_request.user.post_update_count, post_versions_path(:search => {:updater_id => @change_request.user.id}) %></li>
      <li>Notes: <%= link_to @change_request.user.note_update_count, note_versions_path(:search => {:updater_id => @change_request.user.id}) %></li>
      <li>Favorites: <%= @change_request.user.favorite_count %></li>
    </ul>
  </section>
  
  <% if @change_request.rejected? %>
    <section>
      <h2>Request was rejected</h2>
    </section>
  
  <% elsif @change_request.approved? %>
    <section>
      <h2>Request was approved by <%= @change_request.approver.name %></h2>
    </section>
  
  <% elsif CurrentUser.user.is_admin? %>
    <section>
      <h2>Options</h2>
      <%= form_tag(approve_user_name_change_request_path(@change_request)) do %>
        <%= submit_tag "Approve" %>
      <% end %>

      <%= form_tag(reject_user_name_change_request_path(@change_request), :class => "simple_form") do %>
        <div class="input">
          <label>Reason</label>
          <%= text_field_tag "reason" %>
        </div>
        
        <div class="input">
          <%= submit_tag "Reject" %>
        </div>
      <% end %>
    </section>
  <% end %>
  
  <section>
    <%= form_tag(user_name_change_request_path(@change_request), :method => :delete) do %>
      <%= submit_tag "Delete" %>
    <% end %>
  </section>
</div>

