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

This commit is contained in:
2026-06-19 14:59:26 -03:00
parent 79c0f646da
commit 7b83f2e248
13 changed files with 399 additions and 77 deletions

View File

@@ -6,7 +6,7 @@
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["modal", "nf", "erro", "resultados", "confirmar", "tipo"]
static targets = ["modal", "nf", "erro", "resultados", "confirmar", "tipoCheck"]
static values = { buscarUrl: String, apontarUrl: String }
// ── Modal ──────────────────────────────────────────────────
@@ -85,6 +85,9 @@ export default class extends Controller {
const selecionado = this.resultadosTarget.querySelector('input[name="apontamento_entrega"]:checked')
if (!selecionado) { this.mostrarErro("Selecione uma entrega."); return }
const tipos = this.tipoCheckTargets.filter(c => c.checked).map(c => c.value)
if (!tipos.length) { this.mostrarErro("Selecione ao menos uma classificação."); return }
const btn = event.currentTarget
btn.disabled = true
try {
@@ -95,7 +98,7 @@ export default class extends Controller {
"Accept": "application/json",
"X-CSRF-Token": document.querySelector('meta[name="csrf-token"]').content
},
body: JSON.stringify({ tracking_id: selecionado.value, tipo: this.tipoTarget.value })
body: JSON.stringify({ tracking_id: selecionado.value, tipos: tipos })
})
const data = await resp.json()
if (!resp.ok || data.ok === false) {