<%= render 'buyers/accounts/menu' %>

<h2>User <%= h @user.display_name %> of buyer account <%= h @user.account.org_name %></h2>

<div class="operations">
  <%= link_to 'Edit', edit_resource_path(@user), :class => 'action edit' %>
  <% if @user.can_be_destroyed? -%>
    <%= delete_button_for resource_path(@user), data: {:confirm => "Are you sure you want to destroy user #{@user.username}?" } %>
  <% end -%>
</div>

<table class="list mini">

  <tr>
    <th>Name</th>
    <td><%= h @user.display_name %></td>
  </tr>

  <tr>
    <th>Created on</th>
    <td><%= h @user.created_at.to_s(:long) %></td>
  </tr>

  <% unless @user.last_login_at.blank? -%>
    <tr>
      <th>Last logged in on</th>
      <td><%= h @user.last_login_at.to_s(:long) %></td>
    </tr>
  <% end -%>

  <tr>
    <th>Role</th>
    <td><%= h @user.role %></td>
  </tr>

  <tr>
    <th>State</th>
    <td>
      <%= @user.active? ? image_tag('tick.png') : image_tag('cross.png') %>
      <%= h @user.state %>
      <%= button_to_toggle_suspend_buyer_user(@user) %>
    </td>
  </tr>

  <%= fields_definitions_rows(@user,["name"]) %>

</table>
