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)
All checks were successful
Build and deploy / Validate source (push) Successful in 1m39s
Build and deploy / Integration suite on a real stack (push) Successful in 10m18s
Build and deploy / Secret scan and release gate (push) Successful in 16s
Build and deploy / Publish images (push) Successful in 2m33s

- 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) <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-30 09:36:34 -03:00
parent 6ec0ea31a6
commit 9fc4d4e906
3 changed files with 33 additions and 5 deletions

View File

@@ -475,10 +475,15 @@
if (draftId && quotedCart === cartSnapshot()) { await refresh(true); return; } if (draftId && quotedCart === cartSnapshot()) { await refresh(true); return; }
if (draftId) clearDraft(); if (draftId) clearDraft();
if (!clienteOk() || !entrega.cotado) return; 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 // Guidance, not a failure: the customer still has a quality note to
// confirm, and the page takes them to it (Sentry DTF-WEB-Y). // confirm, and the page takes them to it (Sentry DTF-WEB-Y).
if (!cartPodeEnviar()) { 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'}); 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'); return message('Revise a qualidade e confirme a ressalva de cada item antes de enviar o pedido.','warn');
} }

View File

@@ -118,9 +118,18 @@ function invalidaItemAtual(){
pintaPedido(); pintaPedido();
} }
function itemPodeEnviar(item){ function itemPodeEnviar(item){
if(semMargem(item)) return false;
return item.qualityStatus==='ok' || item.qualityStatus==='unverified' || return item.qualityStatus==='ok' || item.qualityStatus==='unverified' ||
(item.qualityStatus==='warning' && item.qualityAcknowledged===true); (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 // 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. // desmarcado fica guardado para depois. O item aberto no produto sempre vai.
function itensAPagar(){ function itensAPagar(){
@@ -209,7 +218,8 @@ function pintaPedido(){
' aria-label="Incluir '+escapeHTML(it.tit)+' no pagamento"></label>'+ ' aria-label="Incluir '+escapeHTML(it.tit)+' no pagamento"></label>'+
'<span class="miniItem">'+(it.mini ? '<img src="'+escapeHTML(it.mini)+'" alt="">' : '<i>'+escapeHTML(it.ext||'')+'</i>')+ '<span class="miniItem">'+(it.mini ? '<img src="'+escapeHTML(it.mini)+'" alt="">' : '<i>'+escapeHTML(it.ext||'')+'</i>')+
(it.arquivos>1 ? '<em>+'+(it.arquivos-1)+'</em>' : '')+'</span>'+ (it.arquivos>1 ? '<em>+'+(it.arquivos-1)+'</em>' : '')+'</span>'+
'<div class="nm2"><b>'+escapeHTML(it.tit)+'</b><span>'+escapeHTML(it.desc)+'</span></div>'+ '<div class="nm2"><b>'+escapeHTML(it.tit)+'</b><span>'+escapeHTML(it.desc)+'</span>'+
(semMargem(it)?'<span class="avisoF">O espaço entre as cópias passou a ser de 8 mm. Remova este item e adicione a folha de novo.</span>':'')+'</div>'+
'<div class="vl2">'+rs(it.total)+'</div>'+ '<div class="vl2">'+rs(it.total)+'</div>'+
'<button type="button" class="x" data-rmi="'+i+'" aria-label="Remover '+escapeHTML(it.tit)+'">'+icone('lixeira')+'<span>Remover</span></button></div>').join(''); '<button type="button" class="x" data-rmi="'+i+'" aria-label="Remover '+escapeHTML(it.tit)+'">'+icone('lixeira')+'<span>Remover</span></button></div>').join('');
$('itens').querySelectorAll('[data-sel]').forEach(c=>c.addEventListener('change',()=>{ $('itens').querySelectorAll('[data-sel]').forEach(c=>c.addEventListener('change',()=>{

View File

@@ -81,9 +81,17 @@ async function sendUpload(file, {api, prefix='/uploads', startPath=prefix, progr
signal?.addEventListener('abort',()=>xhr.abort(),{once:true}); signal?.addEventListener('abort',()=>xhr.abort(),{once:true});
xhr.send(body); 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;offset<file.size;offset+=size,part++){ for(let offset=0,part=1;offset<file.size;offset+=size,part++){
if(done.has(part))continue; if(done.has(part))continue;
if(signal?.aborted)throw cancelled(); if(signal?.aborted){giveBack();throw cancelled();}
progress('Enviando '+file.name+' · parte '+part+'/'+Math.ceil(file.size/size)); progress('Enviando '+file.name+' · parte '+part+'/'+Math.ceil(file.size/size));
// A part the network dropped goes again twice, on a fresh link, before // A part the network dropped goes again twice, on a fresh link, before
// the customer is asked to resume (DTF-WEB-13). // the customer is asked to resume (DTF-WEB-13).
@@ -91,7 +99,8 @@ async function sendUpload(file, {api, prefix='/uploads', startPath=prefix, progr
const signed=await withRetry(options=>api(prefix+'/'+id+'/parts/'+part,{},options)); const signed=await withRetry(options=>api(prefix+'/'+id+'/parts/'+part,{},options));
try{await put(signed.url,file.slice(offset,offset+size));break;} try{await put(signed.url,file.slice(offset,offset+size));break;}
catch(error){ 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)); 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) => { window.dtfUpload = async (file, options) => {
if(options?.signal?.aborted)throw new DOMException('Envio cancelado.','AbortError'); if(options?.signal?.aborted)throw new DOMException('Envio cancelado.','AbortError');
await uploadSlot(); 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();} finally{releaseUploadSlot();}
}; };