<h2>Admin Roles</h2>

<div class="row">
  <div class="col-12">

    <%= paginate @users %>

    <table class="table">
      <thead>
        <tr>
          <th scope="col">ID</th>
          <th scope="col">Profile</th>
          <th scope="col">Roles</th>
        </tr>
      </thead>
      <tbody>
        <% @users.each do |user| %>
          <tr>
            <td><%= user.id %></td>
            <td><%= link_to "@#{user.username}", user.path %></td>
            <td>
              <ul>
                <% user.roles.pluck(:name, :resource_type, :resource_id).each do |role| %>
                  <li><%= role[0] %><%= ": #{role[1]}" if role[1] %><%= "/#{role[2]}" if role[2] %></li>
                <% end %>
              </ul>
            </td>
          </tr>
        <% end %>
      </tbody>
    </table>

    <%= paginate @users %>

  </div>
</div>
