feat: customers see an order code, not the sequential number
Some checks failed
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Failing after 3m2s
Build and deploy / Secret scan and release gate (push) Successful in 6s
Build and deploy / Publish images (push) Has been skipped

"Minha conta" lists and opens orders as "Pedido 1E867B56" (the first 8
characters of the order's id) and searches by that code, so a customer never
sees how many orders the store has. The Kanban shows the code beside the #
number, with a copy button, and its search finds an order by the code a
customer reads out. Tiny keeps its reference (DTF-<number>): it is how a
resent order is found there instead of duplicated, and the WhatsApp notices
the client sends from Tiny use Tiny's own number.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Cauê Faleiros
2026-10-02 16:50:26 -03:00
parent c19941555e
commit d7b1eaae6d
7 changed files with 41 additions and 15 deletions

View File

@@ -149,6 +149,9 @@ function paymentBadge(p){
if(p.status==='pending')return badge(p.status_detail==='pending_challenge'?'Cartão aguardando o banco':'Cartão em análise','info',tried.slice(3));
return badge('Pagamento '+p.status,'',tried.slice(3));
}
// What the customer calls the order (the id's first 8 characters, as the
// server's order_code); the # number is the operators'.
const orderCode=id=>String(id).replace(/-/g,'').slice(0,8).toUpperCase();
const sheetSize=p=>p?cm(p.film_width_cm)+' × '+cm(p.height_cm)+' cm':null;
const hoursSince=v=>Math.floor((Date.now()-new Date(v))/3600000);
// The freight's weight: what the package weighs and, when Jadlog charges the
@@ -391,7 +394,9 @@ function renderPanel(order){
const close=node('button',undefined,'close');close.type='button';close.setAttribute('aria-label','Fechar');close.append(icon(['M6 6l12 12M18 6L6 18']));close.onclick=closePanel;
const test=isTest(order)?node('span','TESTE','tag-teste'):null;
if(test)test.title='Pedido de teste: sem pagamento, não vai ao Tiny nem ao WhatsApp';
row.append(node('span','#'+order.number,'num'),stage,...(test?[test]:[]),close);
const code=node('span',undefined,'ocode');code.append('Pedido '+orderCode(order.id),copyButton(orderCode(order.id),'Copiar código do pedido'));
code.title='O código que o cliente vê';
row.append(node('span','#'+order.number,'num'),stage,...(test?[test]:[]),code,close);
// What was paid and when, and whether it is stuck: the first things asked of an order.
const paid=node('div',undefined,'paidline');
paid.append(node('b',money(order.snapshot.total_cents)),isTest(order)?' sem pagamento · '+when(order.created_at):' pago em '+when(order.created_at));
@@ -1022,7 +1027,7 @@ function hitRow(items,title,sub,meta,badge,color,open){
}
function orderHit(order){
const s=order.snapshot;
return hitRow(s.items,'#'+order.number,buyer(s).title,
return hitRow(s.items,'#'+order.number+' · '+orderCode(order.id),buyer(s).title,
s.items.map(i=>SHORT[i.mode]+' · '+metres(i.billed_metres)).join(' + ')+' · '+(s.destination?'Entrega':'Retirada')+' · pago '+when(order.created_at),
order.cancelled_at?'Cancelado':board.states[order.state],order.cancelled_at?'var(--bad)':STAGE_COLORS[order.state],()=>{
// An older finished order is not on the board yet: it joins, like "Carregar mais".