feat: the Redesenho preview on the Kanban: sent, approved, rejected, and a reminder every 3 h (Rodada 5, D2)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-11-30 11:59:24 -03:00
parent 45c5493a4c
commit a275a77896
3 changed files with 71 additions and 0 deletions

View File

@@ -27,6 +27,29 @@ const stalled=order=>!!order.late;
// A mark on the card, not a stage; a finished order no longer needs it.
const waitingContact=order=>!!order.contact_since&&!order.cancelled_at&&order.state!=='fin';
const contactWho=order=>(order.contact_by||'')+' em '+when(order.contact_since);
// The redesign previews of an order: each one is sent to the customer and
// waits for the answer; the card counts them.
const previewsOf=order=>order.previews||[];
const openPreview=order=>previewsOf(order).find(p=>!p.decided_at)||null;
const previewApproved=order=>previewsOf(order).some(p=>p.result==='approved');
// A preview waiting three hours or more reminds the designer, once per block.
function remindPreviews(orders){
if(!may('produce'))return;
const open=[];
for(const order of orders){const preview=openPreview(order);if(preview)open.push({order,preview});}
open.sort((a,b)=>Date.parse(a.preview.sent_at)-Date.parse(b.preview.sent_at));
for(const {order,preview} of open){
const block=Math.floor((Date.now()-Date.parse(preview.sent_at))/(3*3600e3));
if(block<1)continue;
const key='dtf-preview-reminder:'+order.id+':'+preview.number;
try{
if(Number(localStorage.getItem(key))>=block)continue;
localStorage.setItem(key,String(block));
}catch(_){return;}
say('Prévia '+preview.number+' do pedido #'+order.number+' com o cliente há '+block*3+' h. Confira a resposta.',false,15000);
return;
}
}
// The print proof (app/proof.py): asked for at checkout, or an order above 10 m.
// The room marks "Prova OK" once it is checked; without it, no Finalizado.
const PROOF_ABOVE_METRES=10;
@@ -414,6 +437,13 @@ function cardFlags(order){
const n=Number(order.snapshot.redesign.arts)||1;
out.push(['warn','Redesenho · '+n+(n===1?' arte':' artes'),
'O designer redesenha ou vetoriza a arte antes de imprimir; prazo +48 h']);
const previews=previewsOf(order), open=openPreview(order), many=previews.length>1?' · '+previews.length+' prévias':'';
if(open)out.push(['warn','Prévia '+open.number+' com o cliente'+many,
'Enviada por '+open.sent_by+' em '+when(open.sent_at)+'; o tempo da etapa está parado']);
else if(previewApproved(order)){
const p=previews.filter(x=>x.result==='approved').slice(-1)[0];
out.push(['','Prévia aprovada'+many,'A prévia '+p.number+' foi aprovada em '+when(p.decided_at)+'; envie a arte final']);
}
}
if(order.proof_parent)out.push(['warn','Prova do #'+order.proof_parent.number,'Card da prova do pedido #'+order.proof_parent.number]);
if(live&&waitingProof(order)&&order.state!=='tra')out.push(['warn','Aguardando prova','Entra na fila com Prova OK no card #'+order.proof_card.number]);