Files
Reem-Notas/app/views/admin/grupos_contato/index.html.erb

106 lines
5.6 KiB
Plaintext

<div class="space-y-6">
<div class="flex flex-col sm:flex-row sm:items-center justify-between gap-4">
<div>
<h1 class="text-2xl font-bold text-white flex items-center gap-2">
<%= icone :tag, espaco: false %> Grupos de contato
</h1>
<p class="text-gray-400 text-sm mt-0.5">
É o grupo que assina os eventos — cadastrar alguém novo é escolher o grupo,
não repetir a configuração pessoa por pessoa.
</p>
</div>
<%= link_to new_admin_grupo_path, data: { turbo: false },
class: 'inline-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] whitespace-nowrap' do %>
<%= icone :adicionar, cor: nil, tamanho: 'w-5 h-5', espaco: false %> Novo grupo
<% end %>
</div>
<%= render 'shared/flash' %>
<div class="bg-[#1a1a1a] rounded-2xl border border-white/5 overflow-hidden">
<div class="overflow-x-auto">
<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">Grupo</th>
<th class="px-6 py-4 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider">Descrição</th>
<th class="px-6 py-4 text-right text-xs font-semibold text-gray-400 uppercase tracking-wider">Contatos</th>
<th class="px-6 py-4 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider">Assina os eventos</th>
<th class="px-6 py-4 text-left text-xs font-semibold text-gray-400 uppercase tracking-wider">Situação</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">
<% @grupos.each do |grupo| %>
<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] flex-shrink-0">
<%= icone :tag, cor: nil, tamanho: 'w-4 h-4', espaco: false %>
</div>
<span class="text-white font-medium"><%= grupo.nome %></span>
</div>
</td>
<td class="px-6 py-4 text-gray-400 text-sm"><%= grupo.descricao.presence || '—' %></td>
<td class="px-6 py-4 text-right">
<%= link_to admin_contatos_path(grupo_id: grupo.id), data: { turbo: false },
class: 'inline-flex items-center px-2.5 py-1 rounded-full text-xs font-bold
bg-[#f97316]/15 border border-[#f97316]/30 text-[#f97316]
hover:bg-[#f97316]/25 transition-colors',
title: 'Ver os contatos deste grupo' do %>
<%= grupo.contatos.size %>
<% end %>
</td>
<td class="px-6 py-4">
<% nomes = grupo.assinaturas.select(&:ativo).map { |a| a.evento_notificacao.nome } %>
<% if nomes.any? %>
<div class="flex flex-wrap gap-1.5 max-w-sm">
<% nomes.each do |nome| %>
<span class="inline-flex items-center px-2.5 py-1 rounded-full text-xs
bg-white/5 border border-white/10 text-gray-300"><%= nome %></span>
<% end %>
</div>
<% else %>
<span class="text-gray-500 text-sm">— nenhum</span>
<% end %>
</td>
<td class="px-6 py-4"><%= badge_status_usuario(grupo.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">
<%= link_to edit_admin_grupo_path(grupo), data: { turbo: false },
class: 'p-2 text-gray-400 hover:text-white hover:bg-white/10 rounded-lg transition-colors',
title: 'Editar' do %>
<%= icone :editar, cor: nil, tamanho: 'w-4 h-4', espaco: false %>
<% end %>
<%= button_to admin_grupo_path(grupo), method: :delete,
class: 'p-2 text-gray-600 hover:text-red-400 hover:bg-red-900/20 rounded-lg transition-colors',
title: 'Excluir',
form: { data: { turbo_confirm: "Excluir #{grupo.nome}? Os #{grupo.contatos.size} contato(s) ficam sem grupo e param de receber." } } do %>
<%= icone :excluir, cor: nil, tamanho: 'w-4 h-4', espaco: false %>
<% end %>
</div>
</td>
</tr>
<% end %>
<% if @grupos.empty? %>
<tr>
<td colspan="6" class="px-6 py-16 text-center text-gray-500">
<div class="mb-3"><%= icone :vazio, tamanho: 'w-10 h-10', cor: 'text-gray-600', espaco: false %></div>
<p>Nenhum grupo ainda.</p>
<p class="text-sm mt-1">
Crie um (ex.: <strong class="text-gray-300">Diretoria</strong>,
<strong class="text-gray-300">Motoristas</strong>) e depois cadastre os contatos dentro dele.
</p>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>