From 397e55c81dd1c34b3de3251489d91e04572aa170 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Mon, 16 Nov 2026 13:12:02 -0300 Subject: [PATCH] fix: Pedido pago fora do site no longer offers Faturado, and a 422 names its field (DTF-WEB-E) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The register dialog offered Faturado, which the API refuses there: an invoiced sale goes through the montador's Venda (front 7a.3). The choices are now Pix, Cartão, Dinheiro and Crédito do cliente, as the API accepts. A validation error in the Kanban now shows its first field and message instead of the bare "Confira os campos (422)". Co-Authored-By: Claude Opus 5.5 (1M context) --- web/kanban-quotes.js | 4 +++- web/kanban.js | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/web/kanban-quotes.js b/web/kanban-quotes.js index 832fa4a..8e95361 100644 --- a/web/kanban-quotes.js +++ b/web/kanban-quotes.js @@ -235,7 +235,9 @@ function callout(d,title,text,tone=''){ // An order paid outside the site (Dropstar's rule D-35): the team builds the // cart on the Site, as a customer would, and registers it here. Origin and // payment start unchosen: a default would become the answer to everything. -const PAID_OUTSIDE={pix:'Pix',card:'Cartão',cash:'Dinheiro',credit:'Crédito do cliente',faturado:'Faturado'}; +// Faturado is not one of them: an invoiced sale goes through the montador's +// Venda (front 7a.3), and the API refuses it here (Sentry DTF-WEB-E). +const PAID_OUTSIDE={pix:'Pix',card:'Cartão',cash:'Dinheiro',credit:'Crédito do cliente'}; function registerDialog(quote){ const group=(name,label,options)=>{ const g=node('div',undefined,'fgroup2');g.setAttribute('role','radiogroup');g.setAttribute('aria-label',label); diff --git a/web/kanban.js b/web/kanban.js index 4c3732e..8cd5ca1 100644 --- a/web/kanban.js +++ b/web/kanban.js @@ -231,7 +231,12 @@ async function api(path,body){ const r=await fetch('/api/operator'+path,{headers:{'Content-Type':'application/json'},...(body===undefined?{}:{method:'POST',body:JSON.stringify(body)})}); const d=await r.json(); if(!r.ok){ - const error=new Error(typeof d.detail==='string'?d.detail:'Confira os campos ('+r.status+').'); + // A validation error is a list: name its first field and what was wrong + // instead of the bare status (Sentry DTF-WEB-E). + const first=Array.isArray(d.detail)?d.detail.find(e=>e&&e.msg):null; + const field=first?.loc?.filter(part=>typeof part==='string'&&part!=='body').join('.'); + const error=new Error(typeof d.detail==='string'?d.detail: + 'Confira os campos ('+r.status+')'+(first?': '+(field?field+', ':'')+first.msg:'.')); error.status=r.status; window.dtfObservability?.apiError?.(path,r.status,error.message,d.detail); throw error;