Correção da função de adicionar entregas por fora da operação

This commit is contained in:
2026-06-19 15:07:28 -03:00
parent 7b83f2e248
commit 66794b817f

View File

@@ -1,32 +1,32 @@
<%# app/views/consolidacoes/index.html.erb %> <%# app/views/consolidacoes/index.html.erb %>
<% content_for :title, 'Consolidações' %> <% content_for :title, 'Consolidações' %>
<div class="flex items-center justify-between mb-6"> <div data-controller="nota-avulsa"
<h1 class="text-2xl font-bold text-white">📦 Consolidações</h1> data-nota-avulsa-buscar-url-value="<%= buscar_nf_consolidacoes_path %>">
<div class="flex gap-2"> <div class="flex items-center justify-between mb-6">
<%= link_to '📁 Arquivadas', arquivadas_consolidacoes_path, <h1 class="text-2xl font-bold text-white">📦 Consolidações</h1>
class: 'text-gray-400 hover:text-white border border-[#2a2a2a] px-4 py-3 rounded-lg min-h-[48px] flex items-center transition-colors' %> <div class="flex gap-2">
<% if policy(Consolidacao).create? %> <%= link_to '📁 Arquivadas', arquivadas_consolidacoes_path,
<button type="button" data-action="notaAvulsa#abrir" class: 'text-gray-400 hover:text-white border border-[#2a2a2a] px-4 py-3 rounded-lg min-h-[48px] flex items-center transition-colors' %>
class="text-white border border-dashed border-orange-500/60 hover:border-orange-500 font-semibold px-4 py-3 rounded-lg min-h-[48px] flex items-center transition-colors"> <% if policy(Consolidacao).create? %>
Nota avulsa <button type="button" data-action="nota-avulsa#abrir"
</button> class="text-white border border-dashed border-orange-500/60 hover:border-orange-500 font-semibold px-4 py-3 rounded-lg min-h-[48px] flex items-center transition-colors">
<% end %> Nota avulsa
<%= link_to '+ Nova Consolidação', new_consolidacao_path, </button>
class: 'bg-orange-500 hover:bg-orange-600 text-black font-bold px-5 py-3 rounded-lg min-h-[48px] flex items-center transition-colors' %> <% end %>
<%= link_to '+ Nova Consolidação', new_consolidacao_path,
class: 'bg-orange-500 hover:bg-orange-600 text-black font-bold px-5 py-3 rounded-lg min-h-[48px] flex items-center transition-colors' %>
</div>
</div> </div>
</div>
<%# ── Modal "Nota avulsa" — cria a consolidação direto a partir da NF ── %> <%# ── Modal "Nota avulsa" — cria a consolidação direto a partir da NF ── %>
<% if policy(Consolidacao).create? %> <% if policy(Consolidacao).create? %>
<div data-controller="notaAvulsa" <div data-nota-avulsa-target="modal" data-action="click->nota-avulsa#fundo"
data-nota-avulsa-buscar-url-value="<%= buscar_nf_consolidacoes_path %>">
<div data-nota-avulsa-target="modal" data-action="click->notaAvulsa#fundo"
class="hidden fixed inset-0 z-50 bg-black/70 flex items-center justify-center p-4"> class="hidden fixed inset-0 z-50 bg-black/70 flex items-center justify-center p-4">
<div class="bg-[#1a1a1a] border border-[#2a2a2a] rounded-2xl w-full max-w-lg p-6 max-h-[90vh] overflow-y-auto"> <div class="bg-[#1a1a1a] border border-[#2a2a2a] rounded-2xl w-full max-w-lg p-6 max-h-[90vh] overflow-y-auto text-left">
<div class="flex items-center justify-between mb-1"> <div class="flex items-center justify-between mb-1">
<h2 class="text-xl font-bold text-white"> Nota avulsa</h2> <h2 class="text-xl font-bold text-white"> Nota avulsa</h2>
<button type="button" data-action="notaAvulsa#fechar" <button type="button" data-action="nota-avulsa#fechar"
class="text-gray-500 hover:text-white text-2xl leading-none">✕</button> class="text-gray-500 hover:text-white text-2xl leading-none">✕</button>
</div> </div>
<p class="text-gray-400 text-sm mb-4">Para uma nota que chegou por fora: busque a NF e crie uma consolidação já com o apontamento do motorista.</p> <p class="text-gray-400 text-sm mb-4">Para uma nota que chegou por fora: busque a NF e crie uma consolidação já com o apontamento do motorista.</p>
@@ -36,15 +36,15 @@
<%# Busca da NF %> <%# Busca da NF %>
<div class="flex gap-2 mb-4"> <div class="flex gap-2 mb-4">
<input data-nota-avulsa-target="nf" type="text" inputmode="numeric" <input data-nota-avulsa-target="nf" type="text" inputmode="numeric"
data-action="keydown.enter->notaAvulsa#buscar" data-action="keydown.enter->nota-avulsa#buscar"
placeholder="Número da nota (NF)" placeholder="Número da nota (NF)"
class="flex-1 bg-[#0a0a0a] border border-[#2a2a2a] text-white rounded-lg px-3 py-3 text-base focus:border-orange-500 focus:outline-none"> class="flex-1 bg-[#0a0a0a] border border-[#2a2a2a] text-white rounded-lg px-3 py-3 text-base focus:border-orange-500 focus:outline-none">
<button type="button" data-action="notaAvulsa#buscar" <button type="button" data-action="nota-avulsa#buscar"
class="bg-orange-500 hover:bg-orange-600 text-black font-bold px-5 rounded-lg min-h-[48px]">Buscar</button> class="bg-orange-500 hover:bg-orange-600 text-black font-bold px-5 rounded-lg min-h-[48px]">Buscar</button>
</div> </div>
<%# Form de criação — radios (tracking_id) e tipos[] são enviados nativamente %> <%# Form de criação — radios (tracking_id) e tipos[] são enviados nativamente %>
<%= form_with url: avulsa_consolidacoes_path, method: :post, data: { action: 'submit->notaAvulsa#validar' } do %> <%= form_with url: avulsa_consolidacoes_path, method: :post, data: { action: 'submit->nota-avulsa#validar' } do %>
<div data-nota-avulsa-target="resultados" class="space-y-2 mb-4"></div> <div data-nota-avulsa-target="resultados" class="space-y-2 mb-4"></div>
<div data-nota-avulsa-target="confirmar" class="hidden border-t border-[#2a2a2a] pt-4"> <div data-nota-avulsa-target="confirmar" class="hidden border-t border-[#2a2a2a] pt-4">
@@ -66,8 +66,8 @@
<% end %> <% end %>
</div> </div>
</div> </div>
</div> <% end %>
<% end %> </div>
<%# ── Filtros ──────────────────────────────────────────── %> <%# ── Filtros ──────────────────────────────────────────── %>
<%= form_with url: consolidacoes_path, method: :get, <%= form_with url: consolidacoes_path, method: :get,