Atualização da função de adicionar entregas por fora da operação
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user