From 9fc4d4e9065363817a01274cc28f63201be3dc9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Mon, 30 Nov 2026 09:36:34 -0300 Subject: [PATCH] fix: a cancelled upload holds no reservation, an old ready sheet is flagged in the cart, the address check is guidance (DTF-WEB-14, 22, 24) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 14: switching products cancelled the files being sent, but each one still waiting for a place opened its reservation when it got one, and none gave it back: 27 in ten seconds filled the cap of 30 (29/11). A cancelled upload now never starts, and one cancelled after starting gives its place back. - 22: a ready sheet kept in the cart from before the 8 mm says so on its row and holds Pagar, instead of a refusal after the whole checkout. - 24: "Preencha o endereço de entrega" is a warning, not an error. Co-Authored-By: Claude Opus 5.5 (1M context) --- web/checkout.js | 7 ++++++- web/site-cart.js | 12 +++++++++++- web/upload.js | 19 ++++++++++++++++--- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/web/checkout.js b/web/checkout.js index 001e145..ceeb468 100644 --- a/web/checkout.js +++ b/web/checkout.js @@ -475,10 +475,15 @@ if (draftId && quotedCart === cartSnapshot()) { await refresh(true); return; } if (draftId) clearDraft(); if (!clienteOk() || !entrega.cotado) return; - if (!enderecoOk()) return message('Preencha o endereço de entrega.','error'); + // Guidance: the customer fills it in (Sentry DTF-WEB-24). + if (!enderecoOk()) return message('Preencha o endereço de entrega.','warn'); // Guidance, not a failure: the customer still has a quality note to // confirm, and the page takes them to it (Sentry DTF-WEB-Y). if (!cartPodeEnviar()) { + if (itensAPagar().some(semMargem)) { + document.querySelector('.item .avisoF')?.scrollIntoView({behavior:'smooth',block:'center'}); + return message('Uma folha do carrinho foi montada antes dos 8 mm entre as cópias: remova e adicione de novo.','warn'); + } document.querySelector('.aceiteRes input:not(:checked)')?.closest('label')?.scrollIntoView({behavior:'smooth',block:'center'}); return message('Revise a qualidade e confirme a ressalva de cada item antes de enviar o pedido.','warn'); } diff --git a/web/site-cart.js b/web/site-cart.js index 587b755..876f801 100644 --- a/web/site-cart.js +++ b/web/site-cart.js @@ -118,9 +118,18 @@ function invalidaItemAtual(){ pintaPedido(); } function itemPodeEnviar(item){ + if(semMargem(item)) return false; return item.qualityStatus==='ok' || item.qualityStatus==='unverified' || (item.qualityStatus==='warning' && item.qualityAcknowledged===true); } +// Uma folha pronta guardada no carrinho antes dos 8 mm entre as cópias +// (27/11/2026): o servidor a recusa no pagamento, então o carrinho diz já, +// no próprio item, para refazê-lo (Sentry DTF-WEB-22). +function semMargem(item){ + if(!['file','uvfile','premium'].includes(item.modo) || !item.production?.placements) return false; + const ps=[...item.production.placements].sort((a,b)=>a.y_cm-b.y_cm); + return ps.some((p,i)=>i>0 && p.y_cm < ps[i-1].y_cm+ps[i-1].length_cm+MARGEM_FOLHA_CM-0.02); +} // Os itens marcados no carrinho são os que vão para o pagamento; um item // desmarcado fica guardado para depois. O item aberto no produto sempre vai. function itensAPagar(){ @@ -209,7 +218,8 @@ function pintaPedido(){ ' aria-label="Incluir '+escapeHTML(it.tit)+' no pagamento">'+ ''+(it.mini ? '' : ''+escapeHTML(it.ext||'')+'')+ (it.arquivos>1 ? '+'+(it.arquivos-1)+'' : '')+''+ - '
'+escapeHTML(it.tit)+''+escapeHTML(it.desc)+'
'+ + '
'+escapeHTML(it.tit)+''+escapeHTML(it.desc)+''+ + (semMargem(it)?'O espaço entre as cópias passou a ser de 8 mm. Remova este item e adicione a folha de novo.':'')+'
'+ '
'+rs(it.total)+'
'+ '').join(''); $('itens').querySelectorAll('[data-sel]').forEach(c=>c.addEventListener('change',()=>{ diff --git a/web/upload.js b/web/upload.js index 913ab0b..a2e08b5 100644 --- a/web/upload.js +++ b/web/upload.js @@ -81,9 +81,17 @@ async function sendUpload(file, {api, prefix='/uploads', startPath=prefix, progr signal?.addEventListener('abort',()=>xhr.abort(),{once:true}); xhr.send(body); }); + // A file taken off the page while it went gives its place back at once: a + // reservation it left would hold the pending cap for 20 minutes, and a + // customer switching products filled it (Sentry DTF-WEB-14, 29/11). + const giveBack=()=>{ + fetch('/api'+prefix+'/'+id,{method:'DELETE',credentials:'same-origin'}).catch(()=>{}); + if(resume)localStorage.removeItem(key); + }; + if(signal?.aborted){giveBack();throw cancelled();} for(let offset=0,part=1;offsetapi(prefix+'/'+id+'/parts/'+part,{},options)); try{await put(signed.url,file.slice(offset,offset+size));break;} catch(error){ - if(error?.name==='AbortError'||attempt>=2)throw error; + if(error?.name==='AbortError'){giveBack();throw error;} + if(attempt>=2)throw error; await new Promise(resolve=>setTimeout(resolve,(attempt+1)*3000)); } } @@ -104,6 +113,10 @@ async function sendUpload(file, {api, prefix='/uploads', startPath=prefix, progr window.dtfUpload = async (file, options) => { if(options?.signal?.aborted)throw new DOMException('Envio cancelado.','AbortError'); await uploadSlot(); - try{return await sendUpload(file, options);} + try{ + // Taken off the page while it waited for a place: no reservation at all. + if(options?.signal?.aborted)throw new DOMException('Envio cancelado.','AbortError'); + return await sendUpload(file, options); + } finally{releaseUploadSlot();} };