feat: open the customer's WhatsApp from the order panel
All checks were successful
Build and deploy / Validate source (push) Successful in 4s
Build and deploy / Integration suite on a real stack (push) Successful in 2m13s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 43s
All checks were successful
Build and deploy / Validate source (push) Successful in 4s
Build and deploy / Integration suite on a real stack (push) Successful in 2m13s
Build and deploy / Secret scan and release gate (push) Successful in 5s
Build and deploy / Publish images (push) Successful in 43s
The number in the Kanban's order panel is now a formatted wa.me link, so a correction or a question about the artwork can be sent by hand in one click. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -40,6 +40,23 @@ function ago(value){
|
|||||||
const hours=Math.round(minutes/60);
|
const hours=Math.round(minutes/60);
|
||||||
return hours<48?'há '+hours+' h':'há '+Math.round(hours/24)+' dias';
|
return hours<48?'há '+hours+' h':'há '+Math.round(hours/24)+' dias';
|
||||||
}
|
}
|
||||||
|
// The customer's WhatsApp opens the conversation, for messages the system does
|
||||||
|
// not send (a correction, a question about the artwork).
|
||||||
|
function whatsappLink(zap){
|
||||||
|
const digits=String(zap||'').replace(/\D/g,'');
|
||||||
|
if(digits.length<10)return null;
|
||||||
|
return 'https://wa.me/'+(digits.length<=11?'55':'')+digits;
|
||||||
|
}
|
||||||
|
function contato(customer){
|
||||||
|
const line=node('span','CNPJ '+customer.cnpj+' · ');
|
||||||
|
const href=whatsappLink(customer.zap);
|
||||||
|
if(!href){line.append(customer.zap||'');return line;}
|
||||||
|
const d=String(customer.zap).replace(/\D/g,'').replace(/^55(?=\d{10,11}$)/,'');
|
||||||
|
const shown=d.length===11?'('+d.slice(0,2)+') '+d.slice(2,7)+'-'+d.slice(7):d.length===10?'('+d.slice(0,2)+') '+d.slice(2,6)+'-'+d.slice(6):customer.zap;
|
||||||
|
const a=node('a',shown,'zap');a.href=href;a.target='_blank';a.rel='noopener noreferrer';
|
||||||
|
a.title='Abrir conversa no WhatsApp';
|
||||||
|
line.append(a);return line;
|
||||||
|
}
|
||||||
function node(tag,text,className){const e=document.createElement(tag);if(text!==undefined&&text!==null)e.textContent=text;if(className)e.className=className;return e;}
|
function node(tag,text,className){const e=document.createElement(tag);if(text!==undefined&&text!==null)e.textContent=text;if(className)e.className=className;return e;}
|
||||||
function button(text,fn,className='btn'){
|
function button(text,fn,className='btn'){
|
||||||
const b=node('button',text,className);b.type='button';
|
const b=node('button',text,className);b.type='button';
|
||||||
@@ -244,7 +261,7 @@ function renderPanel(order){
|
|||||||
const body=node('div',undefined,'panel-body');
|
const body=node('div',undefined,'panel-body');
|
||||||
const s=order.snapshot, dest=s.destination;
|
const s=order.snapshot, dest=s.destination;
|
||||||
const facts=node('section',undefined,'facts');
|
const facts=node('section',undefined,'facts');
|
||||||
const who=node('div');who.append(node('p','Cliente','eyebrow'),node('b',s.customer.mail),node('span','CNPJ '+s.customer.cnpj+' · '+s.customer.zap));
|
const who=node('div');who.append(node('p','Cliente','eyebrow'),node('b',s.customer.mail),contato(s.customer));
|
||||||
const where=node('div');where.append(node('p','Entrega','eyebrow'),node('b',dest?dest.recipient:'Retirada em Franca'),
|
const where=node('div');where.append(node('p','Entrega','eyebrow'),node('b',dest?dest.recipient:'Retirada em Franca'),
|
||||||
node('span',dest?dest.street+', '+dest.number+(dest.complement?' '+dest.complement:'')+' · '+dest.district+' · '+dest.city+'/'+dest.state+' · CEP '+dest.postal_code:'Cliente retira na fábrica'));
|
node('span',dest?dest.street+', '+dest.number+(dest.complement?' '+dest.complement:'')+' · '+dest.district+' · '+dest.city+'/'+dest.state+' · CEP '+dest.postal_code:'Cliente retira na fábrica'));
|
||||||
facts.append(who,where);
|
facts.append(who,where);
|
||||||
|
|||||||
Reference in New Issue
Block a user