Pilot customers had no way to reset a forgotten password, and the 7 October meeting asked for two things that only needed the client's inputs to go live. Password recovery: "Esqueci minha senha" in Minha conta sends a link that works once, for an hour (/conta/redefinir#token, in the fragment so it never reaches a server or a Referer). Only the token's hash is stored, the e-mail's text is erased once sent, the answer never says whether an account exists, and a reset signs out every other session. Limited per address and source. Team alerts: Kanban users who tick "Receber alertas por e-mail" in Usuários get one when an order is paid, a cart waits for review, or a payment needs attention. Messages are queued in the transaction that caused them and sent by the worker with retries (app/mail.py). Integrações shows an E-mail row with "Enviar teste". E-mail is off in production (MAIL_ADAPTER=off; recovery keeps offering WhatsApp) until the client's SMTP account exists; then it is only settings (docs/PORTAINER.md). The local stack keeps messages in the database and log. Files opened by hand: a finished sheet in CDR, AI, PSD or TIFF (or with a length the customer typed) pays the full price plus MANUAL_FILE_EXTRA_CENTS per metre, to steer customers to PNG as the meeting asked. It is 0 until Marcus gives the amount. The Site shows it before checkout, the server charges it, Tiny gets it in the unit price, and the Kanban says it. Tested: new tests/mail_test (reset flow, SMTP delivery against a local SMTP server, retry, who gets alerts), pricing unit tests, and the browser test now checks the Site total equals the server's, run with the charge at 0 and at R$ 5,00. The full CI suite passes in a CI-style stack. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
43 lines
2.2 KiB
JavaScript
43 lines
2.2 KiB
JavaScript
/* Site DTF — the product page's buy box: price ladder, price per metre, billed length,
|
|
total and the add-to-cart button, beside the live sheet. It shows the item
|
|
the other site-*.js files already priced (itemAtual) and never computes a
|
|
price of its own, so the box and the cart always agree. */
|
|
(function(){
|
|
const vals=$('compraVals'), add=$('bAdd');
|
|
function pintaCompra(){
|
|
const it=itemAtual;
|
|
vals.hidden=!it;
|
|
add.disabled=!it || !itemPodeEnviar(it);
|
|
if(!it) return;
|
|
const semNota=!it.nota;
|
|
// The price ladder in resolution: nota = DPI ÷ 3, so 90 is 270 DPI.
|
|
const faixas=FAIXAS[it.modo], ativa=faixas.findIndex(([min])=>it.nota>=min);
|
|
$('cEscada').innerHTML=faixas.map(([min,v],i)=>
|
|
'<li'+(i===ativa?' class="on" aria-current="true"':'')+'><span>'+
|
|
(min? min*3+'+'+(i? '' : ' DPI') : semNota? 'cheio' : 'menos')+'</span>'+
|
|
'<b>'+rs(v).slice(3)+'</b></li>').join('');
|
|
const analisadas=ehFolha(it.modo) && folhas.length && folhas.every(x=>x.an);
|
|
$('cMetroLbl').textContent = it.extra ? 'Metro · cheio + '+rs(it.extra)+' manual'
|
|
: semNota ? 'Metro · preço cheio'
|
|
: analisadas && folhas.every(x=>x.an.vetor) ? 'Metro · arte vetorial'
|
|
: analisadas ? 'Metro · '+Math.min(...folhas.map(x=>x.an.dpi))+' DPI'
|
|
: 'Metro';
|
|
$('cMetro').textContent=rs(it.unit);
|
|
$('cMetragem').textContent=fmtM(it.cob)+' m';
|
|
const economia=(TABELA[it.modo]-(it.unit-(it.extra||0)))*it.cob;
|
|
$('cEco').textContent = economia>0.005 ? rs(economia)+' a menos pela resolução da arte' : '';
|
|
const partes=ehFolha(it.modo) ? Math.ceil(it.metros/20) : 1;
|
|
$('cPartes').textContent = partes>1 ? ' Sai em '+partes+' partes de até 20 m.' : '';
|
|
const sobraCm=Math.round((it.cob-it.metros)*100);
|
|
$('cObs').textContent =
|
|
it.cob===MINIMO_M && it.metros<MINIMO_M
|
|
? (ehFolha(it.modo) ? 'Pedido mínimo de 1 m.'
|
|
: 'Pedido mínimo de 1 m: ainda cabem '+sobraCm+' cm de artes sem custo.')
|
|
: '';
|
|
$('cTotal').textContent=rs(it.total);
|
|
}
|
|
add.addEventListener('click',()=>adicionaAoCarrinho());
|
|
addEventListener('dtf-cart-changed',pintaCompra);
|
|
pintaCompra();
|
|
})();
|