Corrige tela branca no Passo 3 + erros na tela de usuários
- Passo 3 (revisar): GROUP BY tipo + ORDER BY created_at é inválido no PostgreSQL (PG::GroupingError → 500/tela branca). reorder(nil) no count. Só ficou acessível depois de corrigir o new? da consolidação. - Usuários: helper badge_status_usuario criado; rota toggle_ativo corrigida para toggle_ativo_admin_usuario_path (PATCH); confirms via turbo_confirm. - Passo 3: contagem mostra entregas distintas + nº de pilares (multi-pilar). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -129,7 +129,8 @@ class ConsolidacaoEntregasController < ApplicationController
|
||||
.where(motorista_nome: @motorista)
|
||||
.order(:created_at)
|
||||
|
||||
@resumo = @classificacoes.group(:tipo).count
|
||||
# reorder(nil): GROUP BY tipo + ORDER BY created_at é inválido no PostgreSQL
|
||||
@resumo = @classificacoes.reorder(nil).group(:tipo).count
|
||||
@total = @classificacoes.sum do |c|
|
||||
c.tipo == 'desconto' ? -c.valor_aplicado : c.valor_aplicado
|
||||
end
|
||||
|
||||
@@ -43,6 +43,13 @@ module ApplicationHelper
|
||||
tag.span label, class: "inline-flex items-center px-2.5 py-1 rounded-full text-xs font-bold #{cfg[:cor]}"
|
||||
end
|
||||
|
||||
# Badge de status ativo/inativo do usuário
|
||||
def badge_status_usuario(ativo)
|
||||
cor = ativo ? 'bg-green-600 text-white' : 'bg-red-600 text-white'
|
||||
label = ativo ? 'Ativo' : 'Inativo'
|
||||
tag.span label, class: "inline-flex items-center px-2.5 py-1 rounded-full text-xs font-bold #{cor}"
|
||||
end
|
||||
|
||||
# Barra de progresso laranja
|
||||
def progress_bar(percentual, label: nil)
|
||||
pct = percentual.to_i.clamp(0, 100)
|
||||
|
||||
@@ -73,10 +73,10 @@
|
||||
<% end %>
|
||||
|
||||
<% if policy(usuario).toggle_ativo? %>
|
||||
<%= button_to toggle_ativo_usuario_path(usuario), method: :post,
|
||||
<%= button_to toggle_ativo_admin_usuario_path(usuario), method: :patch,
|
||||
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 %>
|
||||
form: { data: { turbo_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"/>
|
||||
@@ -88,7 +88,7 @@
|
||||
<%= 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 %>
|
||||
form: { data: { turbo_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"/>
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<div class="bg-[#1a1a1a] border border-orange-500 rounded-xl p-6 mb-6 text-center">
|
||||
<p class="text-gray-400 text-sm mb-1">Total a pagar — <%= @motorista %></p>
|
||||
<p class="text-orange-500 font-black text-4xl"><%= moeda(@total) %></p>
|
||||
<p class="text-gray-500 text-xs mt-1"><%= @classificacoes.size %> entregas classificadas</p>
|
||||
<p class="text-gray-500 text-xs mt-1"><%= @classificacoes.map(&:tracking_id).uniq.size %> entregas classificadas (<%= @classificacoes.size %> pilares)</p>
|
||||
</div>
|
||||
|
||||
<%# Detalhe das classificações %>
|
||||
|
||||
Reference in New Issue
Block a user