feat: products and prices from the database, edited in the Kanban's Site tab (front 8.1)
Gestão and the administrators switch each product on and off and set its price from a start date; a price that has started is history and cannot change, a scheduled one can be cancelled. The Site and the server read the current price; with no row the code's prices and TREATMENT_CENTS still apply, so nothing changes until someone sets one. A switched-off product disappears from the Site and new quotes with it are refused. Approved quotes and paid orders keep their price. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
let shownCart = null;
|
||||
let pixClock = null;
|
||||
let busy = false;
|
||||
// Every product switched off in the Kanban's Site tab (front 8).
|
||||
let semPedidos = false;
|
||||
let draftId = localStorage.getItem('dtf-quote');
|
||||
let requestKey = localStorage.getItem('dtf-request-key');
|
||||
let requestBody = localStorage.getItem('dtf-request-body');
|
||||
@@ -84,6 +86,25 @@
|
||||
if(preco)preco.textContent=TAXA_TRATAMENTO>0?rs(TAXA_TRATAMENTO):'';
|
||||
if(!(TAXA_TRATAMENTO>0)&&document.getElementById('fTratamento'))document.getElementById('fTratamento').checked=false;
|
||||
}
|
||||
// What the Site sells and at what price, from the database (front 8). An
|
||||
// older server sends no `products`: the page keeps PRECO.
|
||||
if(session.products){
|
||||
for(const [mode,product] of Object.entries(session.products)){
|
||||
PRECO[mode]=product.unit_cents/100;
|
||||
const card=document.querySelector('button.ec[data-modo="'+mode+'"]');
|
||||
if(card&&!product.enabled)card.hidden=true;
|
||||
}
|
||||
document.querySelectorAll('[data-preco]').forEach(el=>{
|
||||
const product=session.products[el.dataset.preco];
|
||||
el.textContent=product&&!product.enabled?'Indisponível':rs(PRECO[el.dataset.preco]);
|
||||
});
|
||||
window.dtfProducts=session.products;
|
||||
if(typeof folhas!=='undefined'&&folhas.length&&typeof pintaFolha==='function')pintaFolha();
|
||||
if(typeof itemAtual!=='undefined'&&itemAtual&&typeof carrinho==='function')carrinho();
|
||||
if(typeof pintaTipoEnvio==='function')pintaTipoEnvio();
|
||||
semPedidos=!Object.values(session.products).some(product=>product.enabled);
|
||||
if(semPedidos)message('No momento não estamos recebendo pedidos pelo site.','warn');
|
||||
}
|
||||
if(typeof pintaPedido==='function')pintaPedido();
|
||||
}).catch(()=>{});
|
||||
window.dtfSessionReady=ready;
|
||||
@@ -719,6 +740,7 @@
|
||||
window.addEventListener('dtf-page-changed',()=>{
|
||||
if (naPagina()) refresh();
|
||||
else if (!busy) { refreshVersion++; clearInterval(pixClock); message(''); actions.replaceChildren(); pintaResumo(null); }
|
||||
if (!naPagina() && semPedidos) message('No momento não estamos recebendo pedidos pelo site.','warn');
|
||||
});
|
||||
refresh();
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user