Files
help_desk/views/admin/users.ejs
T

68 lines
2.8 KiB
Plaintext

<%- include('../partials/header') %>
<% title = 'Usuarios'; %>
<% if (success_msg && success_msg.length > 0) { %>
<% success_msg.forEach(msg => { %>
<div class="alert alert-success alert-dismissible fade show mt-3"><%= msg %><button type="button" class="btn-close" data-bs-dismiss="alert"></button></div>
<% }) %>
<% } %>
<% if (error_msg && error_msg.length > 0) { %>
<% error_msg.forEach(msg => { %>
<div class="alert alert-danger alert-dismissible fade show mt-3"><%= msg %><button type="button" class="btn-close" data-bs-dismiss="alert"></button></div>
<% }) %>
<% } %>
<div class="d-flex justify-content-between align-items-center pt-3 pb-2 mb-3 border-bottom">
<h1 class="h2">Usuarios</h1>
<a href="/admin/users/create" class="btn btn-primary">
<i class="fas fa-plus"></i> Nuevo Usuario
</a>
</div>
<div class="table-responsive">
<table class="table table-striped table-hover">
<thead class="table-dark">
<tr>
<th>ID</th>
<th>Nombre</th>
<th>Email</th>
<th>Rol</th>
<th>Activo</th>
<th>Registro</th>
<th>Acción</th>
</tr>
</thead>
<tbody>
<% if (users.length === 0) { %>
<tr><td colspan="7" class="text-center">No hay usuarios</td></tr>
<% } %>
<% users.forEach(u => { %>
<tr>
<td><%= u.id %></td>
<td><%= u.nombre %></td>
<td><%= u.email %></td>
<td><span class="badge bg-<%= u.rol === 'superadmin' ? 'dark' : u.rol === 'admin' ? 'danger' : u.rol === 'agent' ? 'info' : 'secondary' %>"><%= u.rol %></span></td>
<td><span class="badge bg-<%= u.is_active ? 'success' : 'danger' %>"><%= u.is_active ? 'Sí' : 'No' %></span></td>
<td><%= u.created_at %></td>
<td>
<% if (u.rol !== 'superadmin') { %>
<form action="/admin/users/invite/<%= u.id %>" method="POST" style="display:inline">
<button type="submit" class="btn btn-sm btn-info" title="Generar link de invitación">
<i class="fas fa-envelope"></i>
</button>
</form>
<form action="/admin/users/delete/<%= u.id %>" method="POST" style="display:inline">
<button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('¿Eliminar este usuario?')">
<i class="fas fa-trash"></i>
</button>
</form>
<% } %>
</td>
</tr>
<% }) %>
</tbody>
</table>
</div>
<%- include('../partials/footer') %>