Correções de integração Fases 2/3 ↔ 4-8 + Auditoria UI + README final
This commit is contained in:
43
app/views/admin/auditoria_logs/index.html.erb
Normal file
43
app/views/admin/auditoria_logs/index.html.erb
Normal file
@@ -0,0 +1,43 @@
|
||||
<%# app/views/admin/auditoria_logs/index.html.erb %>
|
||||
<% content_for :title, 'Auditoria' %>
|
||||
|
||||
<h1 class="text-2xl font-bold text-white mb-6">🔍 Auditoria</h1>
|
||||
|
||||
<%= form_with url: admin_auditoria_logs_path, method: :get,
|
||||
class: 'bg-[#1a1a1a] border border-[#2a2a2a] rounded-xl p-4 mb-6 flex flex-wrap gap-3' do %>
|
||||
<%= select_tag :user_id,
|
||||
options_from_collection_for_select(@usuarios, :id, :nome_display, params[:user_id]),
|
||||
include_blank: 'Todos os usuários',
|
||||
class: 'bg-[#0a0a0a] border border-[#2a2a2a] text-white rounded-lg px-3 py-2.5' %>
|
||||
<%= text_field_tag :acao, params[:acao], placeholder: 'Ação (ex: finalizar)',
|
||||
class: 'bg-[#0a0a0a] border border-[#2a2a2a] text-white rounded-lg px-3 py-2.5' %>
|
||||
<%= submit_tag 'Filtrar', class: 'bg-orange-500 hover:bg-orange-600 text-black font-bold px-5 rounded-lg cursor-pointer' %>
|
||||
<% end %>
|
||||
|
||||
<div class="bg-[#1a1a1a] border border-[#2a2a2a] rounded-xl overflow-hidden">
|
||||
<table class="w-full text-sm">
|
||||
<thead class="bg-[#0a0a0a] text-gray-400">
|
||||
<tr>
|
||||
<th class="text-left px-4 py-3">Quando</th>
|
||||
<th class="text-left px-4 py-3">Usuário</th>
|
||||
<th class="text-left px-4 py-3">Ação</th>
|
||||
<th class="text-left px-4 py-3">Entidade</th>
|
||||
<th class="text-left px-4 py-3">Detalhes</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-[#2a2a2a] text-gray-300">
|
||||
<% @logs.each do |log| %>
|
||||
<tr class="hover:bg-[#0a0a0a]">
|
||||
<td class="px-4 py-3 whitespace-nowrap"><%= l log.created_at, format: :short %></td>
|
||||
<td class="px-4 py-3"><%= User.find_by(id: log.user_id)&.nome_display || "##{log.user_id}" %></td>
|
||||
<td class="px-4 py-3"><span class="bg-orange-500/20 text-orange-400 px-2 py-1 rounded text-xs font-bold"><%= log.acao %></span></td>
|
||||
<td class="px-4 py-3"><%= log.entidade %><%= " ##{log.entidade_id}" if log.entidade_id %></td>
|
||||
<td class="px-4 py-3 text-gray-500 text-xs"><%= log.dados_novos['detalhes'] || log.dados_novos.to_s.first(80) %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% if @logs.empty? %>
|
||||
<p class="text-gray-500 text-center py-10">Nenhum registro de auditoria encontrado.</p>
|
||||
<% end %>
|
||||
</div>
|
||||
58
app/views/admin/configuracoes/edit.html.erb
Normal file
58
app/views/admin/configuracoes/edit.html.erb
Normal file
@@ -0,0 +1,58 @@
|
||||
<%# app/views/configuracoes/edit.html.erb %>
|
||||
<div class="max-w-lg mx-auto space-y-6">
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold text-white">
|
||||
<%= @configuracao.icone %> Editar: <%= @configuracao.tipo_label %>
|
||||
</h1>
|
||||
<p class="text-gray-400 text-sm mt-0.5">Atualize o valor do pilar de preço</p>
|
||||
</div>
|
||||
|
||||
<%= render 'shared/flash' %>
|
||||
|
||||
<%= form_with(model: @configuracao, url: admin_configuracao_path(@configuracao), method: :patch,
|
||||
class: 'bg-[#1a1a1a] rounded-2xl border border-white/5 p-8 space-y-6') do |f| %>
|
||||
|
||||
<% if @configuracao.errors.any? %>
|
||||
<div class="p-4 bg-red-900/30 border border-red-500/40 rounded-xl">
|
||||
<ul class="list-disc list-inside space-y-1">
|
||||
<% @configuracao.errors.full_messages.each do |msg| %>
|
||||
<li class="text-red-300 text-sm"><%= msg %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div>
|
||||
<%= f.label :valor, 'Valor (R$)', class: 'block text-sm font-medium text-gray-300 mb-1.5' %>
|
||||
<div class="relative">
|
||||
<span class="absolute left-4 top-1/2 -translate-y-1/2 text-gray-400 font-medium">R$</span>
|
||||
<%= f.number_field :valor,
|
||||
step: 0.01,
|
||||
min: 0,
|
||||
class: 'w-full pl-10 pr-4 py-3 bg-[#0a0a0a] border border-white/10 rounded-xl
|
||||
text-white text-xl font-bold focus:outline-none focus:border-[#f97316]
|
||||
focus:ring-1 focus:ring-[#f97316] transition-colors',
|
||||
placeholder: '0.00' %>
|
||||
</div>
|
||||
<p class="text-gray-500 text-xs mt-1.5">Valor atual: <%= moeda(@configuracao.valor) %></p>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<%= f.label :descricao, 'Descrição (opcional)', class: 'block text-sm font-medium text-gray-300 mb-1.5' %>
|
||||
<%= f.text_area :descricao, rows: 2,
|
||||
class: 'w-full px-4 py-3 bg-[#0a0a0a] border border-white/10 rounded-xl text-white
|
||||
placeholder-gray-600 focus:outline-none focus:border-[#f97316] focus:ring-1
|
||||
focus:ring-[#f97316] transition-colors resize-none',
|
||||
placeholder: 'Ex: Entrega padrão para UBS e EMAD' %>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-between pt-2 border-t border-white/5">
|
||||
<%= link_to 'Cancelar', admin_configuracoes_path,
|
||||
class: 'px-6 py-3 text-gray-400 hover:text-white border border-white/10
|
||||
hover:border-white/20 rounded-xl transition-colors' %>
|
||||
<%= f.submit 'Salvar Preço',
|
||||
class: 'px-8 py-3 bg-[#f97316] hover:bg-orange-500 text-white font-semibold
|
||||
rounded-xl transition-colors cursor-pointer min-h-[48px]' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
64
app/views/admin/configuracoes/index.html.erb
Normal file
64
app/views/admin/configuracoes/index.html.erb
Normal file
@@ -0,0 +1,64 @@
|
||||
<%# app/views/configuracoes/index.html.erb %>
|
||||
<div class="space-y-6">
|
||||
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold text-white">Configurações</h1>
|
||||
<p class="text-gray-400 text-sm mt-0.5">Pilares de preço e parâmetros do sistema</p>
|
||||
</div>
|
||||
|
||||
<%= render 'shared/flash' %>
|
||||
|
||||
<%# Pilares de preço %>
|
||||
<div>
|
||||
<h2 class="text-lg font-semibold text-white mb-4">💰 Pilares de Preço</h2>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
|
||||
<% @configuracoes.each do |cfg| %>
|
||||
<div class="bg-[#1a1a1a] rounded-2xl border border-white/5 p-6 group relative">
|
||||
<div class="flex items-start justify-between mb-4">
|
||||
<div class="text-3xl"><%= cfg.icone %></div>
|
||||
<% if policy(cfg).edit? %>
|
||||
<%= link_to edit_admin_configuracao_path(cfg),
|
||||
class: 'opacity-0 group-hover:opacity-100 transition-opacity p-1.5
|
||||
text-gray-500 hover:text-white hover:bg-white/10 rounded-lg' do %>
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/>
|
||||
</svg>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<p class="text-gray-400 text-sm mb-1"><%= cfg.tipo_label %></p>
|
||||
<p class="text-3xl font-bold text-white"><%= moeda(cfg.valor) %></p>
|
||||
<% if cfg.descricao.present? %>
|
||||
<p class="text-gray-500 text-xs mt-2"><%= cfg.descricao %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%# Informações do banco externo %>
|
||||
<div class="bg-[#1a1a1a] rounded-2xl border border-white/5 p-6">
|
||||
<h2 class="text-lg font-semibold text-white mb-4">🗄️ Banco de Dados Externo</h2>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-3 gap-4">
|
||||
<div class="p-4 bg-[#0a0a0a] rounded-xl border border-white/5">
|
||||
<p class="text-gray-400 text-xs mb-1">Tabela monitorada</p>
|
||||
<p class="text-white font-mono text-sm">db_reem_simplerout_2026</p>
|
||||
</div>
|
||||
<div class="p-4 bg-[#0a0a0a] rounded-xl border border-white/5">
|
||||
<p class="text-gray-400 text-xs mb-1">Account ID</p>
|
||||
<p class="text-white font-mono text-sm">95907 (Gade Hospitalar)</p>
|
||||
</div>
|
||||
<div class="p-4 bg-[#0a0a0a] rounded-xl border border-white/5">
|
||||
<p class="text-gray-400 text-xs mb-1">Atualização</p>
|
||||
<p class="text-white font-mono text-sm">A cada 1 hora</p>
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-yellow-500/80 text-xs mt-4 flex items-center gap-1.5">
|
||||
<svg class="w-3.5 h-3.5 flex-shrink-0" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path fill-rule="evenodd" d="M8.257 3.099c.765-1.36 2.722-1.36 3.486 0l5.58 9.92c.75 1.334-.213 2.98-1.742 2.98H4.42c-1.53 0-2.493-1.646-1.743-2.98l5.58-9.92zM11 13a1 1 0 11-2 0 1 1 0 012 0zm-1-8a1 1 0 00-1 1v3a1 1 0 002 0V6a1 1 0 00-1-1z" clip-rule="evenodd"/>
|
||||
</svg>
|
||||
Somente leitura — nunca alterar, deletar ou truncar esta tabela.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
153
app/views/admin/usuarios/_form.html.erb
Normal file
153
app/views/admin/usuarios/_form.html.erb
Normal file
@@ -0,0 +1,153 @@
|
||||
<%# app/views/usuarios/_form.html.erb %>
|
||||
<div class="max-w-2xl mx-auto space-y-6">
|
||||
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold text-white">
|
||||
<%= usuario.new_record? ? 'Novo Usuário' : "Editar: #{usuario.nome}" %>
|
||||
</h1>
|
||||
<p class="text-gray-400 text-sm mt-0.5">
|
||||
<%= usuario.new_record? ? 'Preencha os dados para criar um novo acesso' : 'Atualize as informações do usuário' %>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<%= render 'shared/flash' %>
|
||||
|
||||
<%= form_with(model: usuario, url: usuario.new_record? ? admin_usuarios_path : admin_usuario_path(usuario),
|
||||
method: usuario.new_record? ? :post : :patch,
|
||||
class: 'bg-[#1a1a1a] rounded-2xl border border-white/5 p-8 space-y-6') do |f| %>
|
||||
|
||||
<% if usuario.errors.any? %>
|
||||
<div class="p-4 bg-red-900/30 border border-red-500/40 rounded-xl">
|
||||
<p class="text-red-400 text-sm font-medium mb-2">
|
||||
<%= pluralize(usuario.errors.count, 'erro', 'erros') %> encontrado<%= usuario.errors.count > 1 ? 's' : '' %>:
|
||||
</p>
|
||||
<ul class="list-disc list-inside space-y-1">
|
||||
<% usuario.errors.full_messages.each do |msg| %>
|
||||
<li class="text-red-300 text-sm"><%= msg %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-6">
|
||||
<%# Nome %>
|
||||
<div class="sm:col-span-2">
|
||||
<%= f.label :nome, 'Nome completo', class: 'block text-sm font-medium text-gray-300 mb-1.5' %>
|
||||
<%= f.text_field :nome,
|
||||
class: 'w-full px-4 py-3 bg-[#0a0a0a] border border-white/10 rounded-xl text-white
|
||||
placeholder-gray-600 focus:outline-none focus:border-[#f97316] focus:ring-1
|
||||
focus:ring-[#f97316] transition-colors',
|
||||
placeholder: 'João da Silva' %>
|
||||
</div>
|
||||
|
||||
<%# Perfil %>
|
||||
<div>
|
||||
<%= f.label :role, 'Perfil de acesso', class: 'block text-sm font-medium text-gray-300 mb-1.5' %>
|
||||
<%= f.select :role,
|
||||
options_for_select(role_options_for_select, usuario.role),
|
||||
{},
|
||||
class: 'w-full px-4 py-3 bg-[#0a0a0a] border border-white/10 rounded-xl text-white
|
||||
focus:outline-none focus:border-[#f97316] focus:ring-1 focus:ring-[#f97316]
|
||||
transition-colors cursor-pointer' %>
|
||||
</div>
|
||||
|
||||
<%# Ativo toggle %>
|
||||
<div class="flex items-center">
|
||||
<div class="flex-1">
|
||||
<%= f.label :ativo, 'Usuário ativo', class: 'block text-sm font-medium text-gray-300' %>
|
||||
<p class="text-gray-500 text-xs mt-0.5">Usuários inativos não conseguem fazer login</p>
|
||||
</div>
|
||||
<label class="relative inline-flex items-center cursor-pointer ml-4">
|
||||
<%= f.check_box :ativo, class: 'sr-only peer' %>
|
||||
<div class="w-11 h-6 bg-gray-700 peer-focus:outline-none rounded-full peer
|
||||
peer-checked:after:translate-x-full peer-checked:after:border-white
|
||||
after:content-[''] after:absolute after:top-[2px] after:left-[2px]
|
||||
after:bg-white after:border-gray-300 after:border after:rounded-full
|
||||
after:h-5 after:w-5 after:transition-all peer-checked:bg-[#f97316]"></div>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%# E-mail e senha (não motorista) %>
|
||||
<div id="fields-email" class="space-y-6">
|
||||
<div class="border-t border-white/5 pt-6">
|
||||
<p class="text-sm font-medium text-gray-300 mb-4">Credenciais de acesso</p>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-6">
|
||||
<div class="sm:col-span-2">
|
||||
<%= f.label :email, 'E-mail', class: 'block text-sm font-medium text-gray-300 mb-1.5' %>
|
||||
<%= f.email_field :email,
|
||||
class: 'w-full px-4 py-3 bg-[#0a0a0a] border border-white/10 rounded-xl text-white
|
||||
placeholder-gray-600 focus:outline-none focus:border-[#f97316] focus:ring-1
|
||||
focus:ring-[#f97316] transition-colors',
|
||||
placeholder: 'usuario@gade.com' %>
|
||||
</div>
|
||||
<div>
|
||||
<%= f.label :password,
|
||||
usuario.new_record? ? 'Senha' : 'Nova senha (deixe em branco para manter)',
|
||||
class: 'block text-sm font-medium text-gray-300 mb-1.5' %>
|
||||
<%= f.password_field :password,
|
||||
class: 'w-full px-4 py-3 bg-[#0a0a0a] border border-white/10 rounded-xl text-white
|
||||
placeholder-gray-600 focus:outline-none focus:border-[#f97316] focus:ring-1
|
||||
focus:ring-[#f97316] transition-colors',
|
||||
placeholder: '••••••••' %>
|
||||
</div>
|
||||
<div>
|
||||
<%= f.label :password_confirmation, 'Confirmar senha',
|
||||
class: 'block text-sm font-medium text-gray-300 mb-1.5' %>
|
||||
<%= f.password_field :password_confirmation,
|
||||
class: 'w-full px-4 py-3 bg-[#0a0a0a] border border-white/10 rounded-xl text-white
|
||||
placeholder-gray-600 focus:outline-none focus:border-[#f97316] focus:ring-1
|
||||
focus:ring-[#f97316] transition-colors',
|
||||
placeholder: '••••••••' %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%# PIN (motorista) %>
|
||||
<div id="fields-pin" class="hidden border-t border-white/5 pt-6">
|
||||
<p class="text-sm font-medium text-gray-300 mb-4">PIN de acesso</p>
|
||||
<div class="max-w-xs">
|
||||
<%= f.label :pin_code, 'PIN (4 dígitos)', class: 'block text-sm font-medium text-gray-300 mb-1.5' %>
|
||||
<%= f.text_field :pin_code,
|
||||
maxlength: 4,
|
||||
pattern: '\d{4}',
|
||||
inputmode: 'numeric',
|
||||
class: 'w-full px-4 py-3 bg-[#0a0a0a] border border-white/10 rounded-xl text-white
|
||||
placeholder-gray-600 focus:outline-none focus:border-[#f97316] focus:ring-1
|
||||
focus:ring-[#f97316] transition-colors text-center text-2xl tracking-[0.5em] font-bold',
|
||||
placeholder: '0000' %>
|
||||
<p class="text-gray-500 text-xs mt-1.5">Deve ser único entre todos os motoristas</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%# Botões %>
|
||||
<div class="flex items-center justify-between pt-2 border-t border-white/5">
|
||||
<%= link_to 'Cancelar', admin_usuarios_path,
|
||||
class: 'px-6 py-3 text-gray-400 hover:text-white border border-white/10
|
||||
hover:border-white/20 rounded-xl transition-colors' %>
|
||||
<%= f.submit usuario.new_record? ? 'Criar Usuário' : 'Salvar Alterações',
|
||||
class: 'px-8 py-3 bg-[#f97316] hover:bg-orange-500 text-white font-semibold
|
||||
rounded-xl transition-colors cursor-pointer min-h-[48px]' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const roleSelect = document.querySelector('select[name="user[role]"]');
|
||||
const fieldsEmail = document.getElementById('fields-email');
|
||||
const fieldsPin = document.getElementById('fields-pin');
|
||||
|
||||
function toggleFields() {
|
||||
if (roleSelect.value === 'motorista') {
|
||||
fieldsEmail.classList.add('hidden');
|
||||
fieldsPin.classList.remove('hidden');
|
||||
} else {
|
||||
fieldsEmail.classList.remove('hidden');
|
||||
fieldsPin.classList.add('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
roleSelect.addEventListener('change', toggleFields);
|
||||
toggleFields(); // run on load
|
||||
</script>
|
||||
2
app/views/admin/usuarios/edit.html.erb
Normal file
2
app/views/admin/usuarios/edit.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<%# app/views/usuarios/edit.html.erb %>
|
||||
<%= render 'form', usuario: @usuario %>
|
||||
120
app/views/admin/usuarios/index.html.erb
Normal file
120
app/views/admin/usuarios/index.html.erb
Normal file
@@ -0,0 +1,120 @@
|
||||
<%# app/views/usuarios/index.html.erb %>
|
||||
<div class="space-y-6">
|
||||
|
||||
<%# Header %>
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold text-white">Usuários</h1>
|
||||
<p class="text-gray-400 text-sm mt-0.5">Gerencie o acesso ao sistema</p>
|
||||
</div>
|
||||
<% if policy(User).create? %>
|
||||
<%= link_to new_admin_usuario_path,
|
||||
class: 'flex items-center gap-2 px-5 py-3 bg-[#f97316] hover:bg-orange-500
|
||||
text-white font-semibold rounded-xl transition-colors min-h-[48px]' do %>
|
||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
|
||||
</svg>
|
||||
Novo Usuário
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<%# Flash %>
|
||||
<%= render 'shared/flash' %>
|
||||
|
||||
<%# Tabela %>
|
||||
<div class="bg-[#1a1a1a] rounded-2xl border border-white/5 overflow-hidden">
|
||||
<table class="w-full">
|
||||
<thead>
|
||||
<tr class="border-b border-white/10">
|
||||
<th class="px-6 py-4 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider">Nome</th>
|
||||
<th class="px-6 py-4 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider">E-mail / PIN</th>
|
||||
<th class="px-6 py-4 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider">Perfil</th>
|
||||
<th class="px-6 py-4 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider">Status</th>
|
||||
<th class="px-6 py-4 text-right text-xs font-semibold text-gray-400 uppercase tracking-wider">Ações</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-white/5">
|
||||
<% @usuarios.each do |usuario| %>
|
||||
<tr class="hover:bg-white/5 transition-colors group">
|
||||
<td class="px-6 py-4">
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="w-9 h-9 rounded-full bg-[#f97316]/20 border border-[#f97316]/30
|
||||
flex items-center justify-center text-[#f97316] font-bold text-sm flex-shrink-0">
|
||||
<%= usuario.nome.to_s[0].upcase %>
|
||||
</div>
|
||||
<span class="text-white font-medium"><%= usuario.nome %></span>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<% if usuario.motorista? && usuario.pin_code.present? %>
|
||||
<div class="text-gray-300 text-sm">PIN: ••••</div>
|
||||
<% else %>
|
||||
<div class="text-gray-300 text-sm"><%= usuario.email %></div>
|
||||
<% end %>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<%= badge_role(usuario.role) %>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<%= badge_status_usuario(usuario.ativo?) %>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<div class="flex items-center justify-end gap-2 opacity-0 group-hover:opacity-100 transition-opacity">
|
||||
<% if policy(usuario).edit? %>
|
||||
<%= link_to edit_admin_usuario_path(usuario),
|
||||
class: 'p-2 text-gray-400 hover:text-white hover:bg-white/10 rounded-lg transition-colors',
|
||||
title: 'Editar' do %>
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/>
|
||||
</svg>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if policy(usuario).toggle_ativo? %>
|
||||
<%= button_to toggle_ativo_usuario_path(usuario), method: :post,
|
||||
class: "p-2 rounded-lg transition-colors #{usuario.ativo? ? 'text-green-400 hover:bg-green-900/30' : 'text-red-400 hover:bg-red-900/30'}",
|
||||
title: usuario.ativo? ? 'Desativar' : 'Ativar',
|
||||
data: { confirm: "#{usuario.ativo? ? 'Desativar' : 'Ativar'} #{usuario.nome}?" } do %>
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636"/>
|
||||
</svg>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if policy(usuario).destroy? %>
|
||||
<%= button_to admin_usuario_path(usuario), method: :delete,
|
||||
class: 'p-2 text-gray-600 hover:text-red-400 hover:bg-red-900/20 rounded-lg transition-colors',
|
||||
title: 'Excluir',
|
||||
data: { confirm: "Excluir #{usuario.nome} permanentemente?" } do %>
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
|
||||
</svg>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
<% if @usuarios.empty? %>
|
||||
<tr>
|
||||
<td colspan="5" class="px-6 py-16 text-center text-gray-500">
|
||||
<div class="text-4xl mb-3">👥</div>
|
||||
<p>Nenhum usuário encontrado.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<% if @usuarios.respond_to?(:total_pages) && @usuarios.total_pages > 1 %>
|
||||
<div class="px-6 py-4 border-t border-white/10">
|
||||
<%= paginate @usuarios %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
2
app/views/admin/usuarios/new.html.erb
Normal file
2
app/views/admin/usuarios/new.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<%# app/views/usuarios/new.html.erb %>
|
||||
<%= render 'form', usuario: @usuario %>
|
||||
Reference in New Issue
Block a user