From 0dde3712d3bb9a5c13f85866c6ab0942d8a21749 Mon Sep 17 00:00:00 2001 From: Ben <36240171+benkyd@users.noreply.github.com> Date: Wed, 27 Apr 2022 23:33:40 +0100 Subject: [PATCH] so many bugs Former-commit-id: 9ad8311734169cda6602f558defb715390dfa342 --- client/public/components/checkout.mjs | 20 +++++++++++--------- src/controllers/brick-controller.js | 2 -- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/client/public/components/checkout.mjs b/client/public/components/checkout.mjs index da0ad4d..bf4b107 100644 --- a/client/public/components/checkout.mjs +++ b/client/public/components/checkout.mjs @@ -1,5 +1,5 @@ - import { GetBasketTotalPrice } from '../basket.mjs'; import { RegisterComponent, Component, SideLoad } from './components.mjs'; +import * as Basket from '../basket.mjs'; class Checkout extends Component { static __IDENTIFY() { return 'checkout'; } @@ -10,8 +10,8 @@ class Checkout extends Component { async OnMount() { this.setState({ - subtotal: parseFloat(await GetBasketTotalPrice()).toFixed(2), - total: parseFloat(await GetBasketTotalPrice()).toFixed(2), + subtotal: parseFloat(await Basket.GetBasketTotalPrice()).toFixed(2), + total: parseFloat(await Basket.GetBasketTotalPrice()).toFixed(2), discount: 0, }); } @@ -221,10 +221,9 @@ class Checkout extends Component { return; } - offerTextBox.classList.add('code-applied'); - offerTextBox.disabled = true; + const offer = req.data; - if (await GetBasketTotalPrice() < req.discount.min_value) { + if ((await Basket.GetBasketTotalPrice()) < parseFloat(offer.min_value)) { // show error offerTextBox.classList.add('error'); setTimeout(() => { @@ -233,10 +232,13 @@ class Checkout extends Component { return; } + offerTextBox.classList.add('code-applied'); + offerTextBox.disabled = true; + this.setState({ - subtotal: parseFloat(await GetBasketTotalPrice()).toFixed(2), - total: parseFloat(await GetBasketTotalPrice(req.discount, req.type, req.entity_type)).toFixed(2), - discount: await GetAbsoluteBasketDiscount(req.discount, req.type, req.entity_type), + subtotal: parseFloat(await Basket.GetBasketTotalPrice()).toFixed(2), + total: parseFloat(await Basket.GetBasketTotalPrice(offer.discount, offer.type, offer.entity_type)).toFixed(2), + discount: await Basket.GetAbsoluteBasketDiscount(offer.discount, offer.type, offer.entity_type), }); }); } diff --git a/src/controllers/brick-controller.js b/src/controllers/brick-controller.js index 316d486..4b788fb 100644 --- a/src/controllers/brick-controller.js +++ b/src/controllers/brick-controller.js @@ -91,8 +91,6 @@ async function SumPrices(bricksArr, quantityArray) { } Database.Query('COMMIT TRANSACTION;'); - console.log(dbres.rows) - // validate database response if (dbres.rows.length === 0) { return {