<h3 class="heading"><%= t("admin.admin_users.history.heading") %></h3>
<div class="wrapper">
  <table id="user_history" summary="<%= t("admin.admin_users.history.table.summary") %>">
    <caption><%= t("admin.admin_users.history.table.caption") %></caption>
    <thead>
    <tr>
      <th scope="col"><%= t("admin.admin_users.history.table.head.date") %></th>
      <th scope="col"><%= t("admin.admin_users.history.table.head.action") %></th>
      <th scope="col"><%= t("admin.admin_users.history.table.head.details") %></th>
    </tr>
    </thead>
    <tbody>
      <tr>
        <td><%= @user.current_sign_in_at.nil? ? "" : @user.current_sign_in_at %></td>
        <td><%= t("admin.admin_users.history.table.sign_in.current.action") %></td>
        <td>
          <% if @user.current_sign_in_at.nil? %>
            <%= t("admin.admin_users.history.table.sign_in.current.no_details") %>
          <% else %>
            <%= t("admin.admin_users.history.table.sign_in.details", ip: @user.current_sign_in_ip) %>
          <% end %>
        </td>
      </tr>
      <tr>
        <td><%= @user.last_sign_in_at.nil? ? "" : @user.last_sign_in_at %></td>
        <td><%= t("admin.admin_users.history.table.sign_in.last.action") %></td>
        <td>
          <% if @user.last_sign_in_at.nil? %>
            <%= t("admin.admin_users.history.table.sign_in.last.no_details") %>
          <% else %>
            <%= t("admin.admin_users.history.table.sign_in.details", ip: @user.last_sign_in_ip) %>
          <% end %>
        </td>
      </tr>
      <% unless @log_items.blank?
         @log_items.each do |item| %>
        <tr>
          <td><%= item.created_at %></td>
          <td><%= log_item_action_name(item) %><%= item.role&.name %><%= item.enddate %></td>
          <td><%= item.note %></td>
        </tr>
      <% end %>
    <% end %>
    <tr>
      <td><%= @user.created_at %></td>
      <td><%= t("admin.admin_users.history.table.creation.action") %></td>
      <td><%= t("admin.admin_users.history.table.creation.details") %></td>
    </tr>
    </tbody>
  </table>
</div>
