so many bugs

Former-commit-id: 9ad8311734169cda6602f558defb715390dfa342
This commit is contained in:
Ben
2022-04-27 23:33:40 +01:00
parent 3f2037f1fc
commit 0dde3712d3
2 changed files with 11 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
import { GetBasketTotalPrice } from '../basket.mjs';
import { RegisterComponent, Component, SideLoad } from './components.mjs'; import { RegisterComponent, Component, SideLoad } from './components.mjs';
import * as Basket from '../basket.mjs';
class Checkout extends Component { class Checkout extends Component {
static __IDENTIFY() { return 'checkout'; } static __IDENTIFY() { return 'checkout'; }
@@ -10,8 +10,8 @@ class Checkout extends Component {
async OnMount() { async OnMount() {
this.setState({ this.setState({
subtotal: parseFloat(await GetBasketTotalPrice()).toFixed(2), subtotal: parseFloat(await Basket.GetBasketTotalPrice()).toFixed(2),
total: parseFloat(await GetBasketTotalPrice()).toFixed(2), total: parseFloat(await Basket.GetBasketTotalPrice()).toFixed(2),
discount: 0, discount: 0,
}); });
} }
@@ -221,10 +221,9 @@ class Checkout extends Component {
return; return;
} }
offerTextBox.classList.add('code-applied'); const offer = req.data;
offerTextBox.disabled = true;
if (await GetBasketTotalPrice() < req.discount.min_value) { if ((await Basket.GetBasketTotalPrice()) < parseFloat(offer.min_value)) {
// show error // show error
offerTextBox.classList.add('error'); offerTextBox.classList.add('error');
setTimeout(() => { setTimeout(() => {
@@ -233,10 +232,13 @@ class Checkout extends Component {
return; return;
} }
offerTextBox.classList.add('code-applied');
offerTextBox.disabled = true;
this.setState({ this.setState({
subtotal: parseFloat(await GetBasketTotalPrice()).toFixed(2), subtotal: parseFloat(await Basket.GetBasketTotalPrice()).toFixed(2),
total: parseFloat(await GetBasketTotalPrice(req.discount, req.type, req.entity_type)).toFixed(2), total: parseFloat(await Basket.GetBasketTotalPrice(offer.discount, offer.type, offer.entity_type)).toFixed(2),
discount: await GetAbsoluteBasketDiscount(req.discount, req.type, req.entity_type), discount: await Basket.GetAbsoluteBasketDiscount(offer.discount, offer.type, offer.entity_type),
}); });
}); });
} }

View File

@@ -91,8 +91,6 @@ async function SumPrices(bricksArr, quantityArray) {
} }
Database.Query('COMMIT TRANSACTION;'); Database.Query('COMMIT TRANSACTION;');
console.log(dbres.rows)
// validate database response // validate database response
if (dbres.rows.length === 0) { if (dbres.rows.length === 0) {
return { return {