feat: customers buy with a CPF or a CNPJ
All checks were successful
Build and deploy / Validate source (push) Successful in 1m38s
Build and deploy / Integration suite on a real stack (push) Successful in 4m57s
Build and deploy / Secret scan and release gate (push) Successful in 13s
Build and deploy / Publish images (push) Successful in 2m1s
All checks were successful
Build and deploy / Validate source (push) Successful in 1m38s
Build and deploy / Integration suite on a real stack (push) Successful in 4m57s
Build and deploy / Secret scan and release gate (push) Successful in 13s
Build and deploy / Publish images (push) Successful in 2m1s
The cart and the account signup take either document, each with its own mask and check digits. Tiny gets a person (F) for a CPF, Mercado Pago the matching identification type, and only CNPJs go to the company registry. The Kanban, the account page and the alerts show which one it is. Also pins the Correios test's clock: its fake token expired today, so the suite failed from Oct 16 on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -122,7 +122,9 @@ function place(dest,prefix=''){
|
||||
}
|
||||
const cm=v=>Number(v).toLocaleString('pt-BR',{maximumFractionDigits:1});
|
||||
const plural=(n,one,many)=>n+' '+(n===1?one:many);
|
||||
function cnpj(value){const d=String(value||'').replace(/\D/g,'');return d.length===14?d.replace(/^(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})$/,'$1.$2.$3/$4-$5'):String(value||'');}
|
||||
// The customer's CPF or CNPJ, formatted, and which of the two it is.
|
||||
function cnpj(value){const d=String(value||'').replace(/\D/g,'');return d.length===14?d.replace(/^(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})$/,'$1.$2.$3/$4-$5'):d.length===11?d.replace(/^(\d{3})(\d{3})(\d{3})(\d{2})$/,'$1.$2.$3-$4'):String(value||'');}
|
||||
const docKind=value=>String(value||'').replace(/\D/g,'').length===11?'CPF':'CNPJ';
|
||||
function copyButton(text,label){
|
||||
const b=node('button',undefined,'copy');b.type='button';b.title=label;b.setAttribute('aria-label',label);b.append(icon(ICON_COPY));
|
||||
b.onclick=async e=>{e.stopPropagation();try{await navigator.clipboard.writeText(text);say('Copiado.');}catch(_){say('Não foi possível copiar.',true);}};
|
||||
@@ -672,7 +674,7 @@ function renderPanel(order){
|
||||
const s=order.snapshot, dest=s.destination;
|
||||
const facts=node('section',undefined,'facts');
|
||||
const who=node('div',undefined,'fcard');
|
||||
const doc=node('span',undefined,'line');doc.append('CNPJ '+cnpj(s.customer.cnpj),copyButton(cnpj(s.customer.cnpj),'Copiar CNPJ'));
|
||||
const doc=node('span',undefined,'line');doc.append(docKind(s.customer.cnpj)+' '+cnpj(s.customer.cnpj),copyButton(cnpj(s.customer.cnpj),'Copiar '+docKind(s.customer.cnpj)));
|
||||
who.append(node('p','Cliente','eyebrow'),buyerBlock(s),doc);
|
||||
const zap=whatsappLink(s.customer.zap);
|
||||
if(zap){const a=node('a','Abrir conversa','zapbtn');a.href=zap;a.target='_blank';a.rel='noopener noreferrer';a.title=s.customer.zap;a.prepend(icon(ICON_CHAT));who.append(a);}
|
||||
@@ -1272,7 +1274,7 @@ function review(quote){
|
||||
const name=node('div',undefined,'qname');name.append(buyerBlock(quote.draft),badge(...status));
|
||||
const pay=paymentBadge(quote.payment);if(pay)name.append(pay);
|
||||
const sub=node('div',undefined,'qsub');const c=quote.draft.customer;
|
||||
const doc=node('span');doc.append('CNPJ '+cnpj(c.cnpj),copyButton(cnpj(c.cnpj),'Copiar CNPJ'));sub.append(doc);
|
||||
const doc=node('span');doc.append(docKind(c.cnpj)+' '+cnpj(c.cnpj),copyButton(cnpj(c.cnpj),'Copiar '+docKind(c.cnpj)));sub.append(doc);
|
||||
const zap=whatsappLink(c.zap);
|
||||
if(zap){const a=node('a',c.zap,'zapbtn');a.href=zap;a.target='_blank';a.rel='noopener noreferrer';a.prepend(icon(ICON_CHAT));sub.append(a);}
|
||||
sub.append(place(quote.draft.destination,'Entrega em '),node('span','#'+quote.id.slice(0,8)+' · '+ago(quote.created_at),'faint'));
|
||||
@@ -1662,7 +1664,7 @@ async function runSearch(text){
|
||||
for(const row of rows){const hit=make(row);hit.el.id='hit-'+searchHits.length;searchHits.push(hit);parts.push(hit.el);}
|
||||
}
|
||||
if(!searchHits.length)parts.push(node('p','Nada encontrado para “'+text+'”.','rempty'));
|
||||
parts.push(node('div','↑ ↓ para escolher · Enter abre · Esc fecha · busca por e-mail, CNPJ, WhatsApp ou nº do pedido','rhelp'));
|
||||
parts.push(node('div','↑ ↓ para escolher · Enter abre · Esc fecha · busca por e-mail, CPF/CNPJ, WhatsApp ou nº do pedido','rhelp'));
|
||||
box.replaceChildren(...parts);box.hidden=false;$('search').setAttribute('aria-expanded','true');
|
||||
}
|
||||
function hitRow(items,title,sub,meta,badge,color,open){
|
||||
|
||||
Reference in New Issue
Block a user