fix: Site tab, an empty Novo preço keeps the current price
The grey 9,90 in Novo preço is only a hint; saving a band with the field empty refused with "Informe o preço em reais". Empty now keeps the current price, and Salvar sits below the bands it saves with the price. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -101,7 +101,8 @@ function sitePriceBlock(product){
|
||||
return {from_metres:String(from),unit_cents:unit};
|
||||
});
|
||||
const save=button('Salvar',async()=>{
|
||||
const cents=moneyInputCents(price.value);
|
||||
// Empty keeps the current price (the grey hint), so a band alone can be added.
|
||||
const cents=price.value.trim()?moneyInputCents(price.value):product.unit_cents>0?product.unit_cents:null;
|
||||
if(cents===null)throw new Error('Informe o preço em reais, como 19,90.');
|
||||
const whenDate=starts.value?new Date(starts.value):null;
|
||||
if(whenDate&&Number.isNaN(whenDate.getTime()))throw new Error('Data inválida.');
|
||||
@@ -111,7 +112,8 @@ function sitePriceBlock(product){
|
||||
say(whenDate?'Preço salvo para '+when(whenDate)+'.':'Preço salvo. Vale a partir de agora.');
|
||||
await loadSiteAdmin();
|
||||
},'btn pri');
|
||||
form.append(priceLabel,startsLabel,save,...(permiteFaixas?[bands]:[]));
|
||||
// Salvar after the bands: it saves the price and its bands together.
|
||||
form.append(priceLabel,startsLabel,...(permiteFaixas?[bands]:[]),save);
|
||||
|
||||
const scheduled=node('div',undefined,'siteScheduled');
|
||||
if(product.scheduled.length){
|
||||
|
||||
Reference in New Issue
Block a user