obdev/app/views/users/index.html.erb

51 lines
1.6 KiB
Plaintext

<div class="container mt-5">
<div class="row">
<div class="col-12">
<h1 class="mb-4 text-center">Users</h1>
</div>
<div class="col-12 mb-4">
<table class="table">
<thead class="table-light">
<tr>
<th>Name</th>
<th>Email</th>
<th>Company</th>
<th>Permissions</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<% @users.each do |user| %>
<tr>
<td><%= user.first_name %> <%= user.last_name %></td>
<td><%= user.email %></td>
<td><%= user.company %></td>
<td><%= display_user_role(user) %></td>
<td>
<%= link_to edit_user_path(user), class: 'btn btn-info btn-sm' do %>
<i class="bi bi-pencil-fill" style="color: white;"></i>
<% end %>
<%= link_to user_path(user), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger btn-sm' do %>
<i class="bi bi-trash-fill"></i>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="col-12 d-flex justify-content-between mb-4">
<!-- Button for Admins to add a new user -->
<% if can?(:create, User) %> <!-- Checks if the current user has the permission to create new users -->
<%= link_to 'Add New User', admin_new_user_path, class: "btn btn-dark" %>
<% end %>
<%= link_to 'Back to Home', root_path, class: "btn btn-secondary" %> <!-- Adjust as needed -->
</div>
</div>
</div>