@salesgenterp/ui-components 0.4.451 → 0.4.452

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -10498,6 +10498,147 @@ var StyledButton = styled__default.button(_templateObject2$u || (_templateObject
10498
10498
  return props.theme.primaryColor;
10499
10499
  });
10500
10500
 
10501
+ var DiscountSummaryModal = function DiscountSummaryModal(_ref) {
10502
+ var discountCoupons = _ref.discountCoupons,
10503
+ orderTotal = _ref.orderTotal,
10504
+ primaryColor = _ref.primaryColor,
10505
+ open = _ref.open,
10506
+ onCancel = _ref.onCancel;
10507
+ return /*#__PURE__*/React__default.createElement(material.Dialog, {
10508
+ open: open,
10509
+ onClose: onCancel,
10510
+ fullWidth: true,
10511
+ maxWidth: "sm"
10512
+ }, /*#__PURE__*/React__default.createElement(material.DialogTitle, null, /*#__PURE__*/React__default.createElement(material.Typography, {
10513
+ variant: "h4",
10514
+ fontWeight: "bold",
10515
+ align: "center",
10516
+ sx: {
10517
+ color: '#000000',
10518
+ fontSize: '1.8rem'
10519
+ }
10520
+ }, "Discount Has Been Applied! \uD83C\uDF89")), /*#__PURE__*/React__default.createElement(material.DialogContent, null, /*#__PURE__*/React__default.createElement(material.Box, {
10521
+ sx: {
10522
+ padding: 2
10523
+ }
10524
+ }, /*#__PURE__*/React__default.createElement(material.TableContainer, {
10525
+ component: material.Box,
10526
+ sx: {
10527
+ border: '1px solid #e0e0e0',
10528
+ borderRadius: 2
10529
+ }
10530
+ }, /*#__PURE__*/React__default.createElement(material.Table, null, /*#__PURE__*/React__default.createElement(material.TableHead, null, /*#__PURE__*/React__default.createElement(material.TableRow, null, /*#__PURE__*/React__default.createElement(material.TableCell, {
10531
+ sx: {
10532
+ fontWeight: 'bold',
10533
+ fontSize: '1.2rem',
10534
+ padding: '12px'
10535
+ }
10536
+ }, "Coupon Code"), /*#__PURE__*/React__default.createElement(material.TableCell, {
10537
+ sx: {
10538
+ fontWeight: 'bold',
10539
+ fontSize: '1.2rem',
10540
+ padding: '12px'
10541
+ }
10542
+ }, "Discount"), /*#__PURE__*/React__default.createElement(material.TableCell, {
10543
+ sx: {
10544
+ fontWeight: 'bold',
10545
+ fontSize: '1.2rem',
10546
+ padding: '12px'
10547
+ }
10548
+ }, "Auto Applied"))), /*#__PURE__*/React__default.createElement(material.TableBody, null, discountCoupons === null || discountCoupons === void 0 ? void 0 : discountCoupons.map(function (item, i) {
10549
+ return /*#__PURE__*/React__default.createElement(material.TableRow, {
10550
+ key: i
10551
+ }, /*#__PURE__*/React__default.createElement(material.TableCell, {
10552
+ sx: {
10553
+ fontWeight: 'bold',
10554
+ fontSize: '1.2rem',
10555
+ padding: '12px'
10556
+ }
10557
+ }, (item === null || item === void 0 ? void 0 : item.couponCode) || ''), /*#__PURE__*/React__default.createElement(material.TableCell, {
10558
+ sx: {
10559
+ fontSize: '1.2rem',
10560
+ padding: '12px',
10561
+ color: 'success.main',
10562
+ fontWeight: 'bold'
10563
+ }
10564
+ }, renderMoney(item === null || item === void 0 ? void 0 : item.amount)), /*#__PURE__*/React__default.createElement(material.TableCell, {
10565
+ sx: {
10566
+ fontSize: '1.2rem',
10567
+ padding: '12px'
10568
+ }
10569
+ }, (item === null || item === void 0 ? void 0 : item.autoApplicable) && /*#__PURE__*/React__default.createElement(fa6.FaCheck, {
10570
+ color: "green",
10571
+ style: {
10572
+ fontSize: '1.5rem'
10573
+ }
10574
+ })));
10575
+ })))), /*#__PURE__*/React__default.createElement(material.Divider, {
10576
+ sx: {
10577
+ marginY: 3
10578
+ }
10579
+ }), /*#__PURE__*/React__default.createElement(material.TableContainer, {
10580
+ component: material.Box,
10581
+ sx: {
10582
+ border: '1px solid #e0e0e0',
10583
+ borderRadius: 2
10584
+ }
10585
+ }, /*#__PURE__*/React__default.createElement(material.Table, null, /*#__PURE__*/React__default.createElement(material.TableBody, null, /*#__PURE__*/React__default.createElement(material.TableRow, null, /*#__PURE__*/React__default.createElement(material.TableCell, {
10586
+ sx: {
10587
+ fontWeight: 'bold',
10588
+ fontSize: '1.2rem',
10589
+ padding: '12px'
10590
+ }
10591
+ }, "Sub Total"), /*#__PURE__*/React__default.createElement(material.TableCell, {
10592
+ sx: {
10593
+ fontWeight: 'bold',
10594
+ fontSize: '1.2rem',
10595
+ padding: '12px'
10596
+ }
10597
+ }, renderMoney(orderTotal === null || orderTotal === void 0 ? void 0 : orderTotal.subTotal))), /*#__PURE__*/React__default.createElement(material.TableRow, null, /*#__PURE__*/React__default.createElement(material.TableCell, {
10598
+ sx: {
10599
+ fontWeight: 'bold',
10600
+ fontSize: '1.2rem',
10601
+ padding: '12px'
10602
+ }
10603
+ }, "Total Discount"), /*#__PURE__*/React__default.createElement(material.TableCell, {
10604
+ sx: {
10605
+ fontWeight: 'bold',
10606
+ fontSize: '1.2rem',
10607
+ padding: '12px',
10608
+ color: 'success.main'
10609
+ }
10610
+ }, renderMoney(orderTotal === null || orderTotal === void 0 ? void 0 : orderTotal.couponDiscountTotal))), /*#__PURE__*/React__default.createElement(material.TableRow, null, /*#__PURE__*/React__default.createElement(material.TableCell, {
10611
+ sx: {
10612
+ fontWeight: 'bold',
10613
+ fontSize: '1.2rem',
10614
+ padding: '12px'
10615
+ }
10616
+ }, "Order Total"), /*#__PURE__*/React__default.createElement(material.TableCell, {
10617
+ sx: {
10618
+ fontWeight: 'bold',
10619
+ fontSize: '1.2rem',
10620
+ padding: '12px',
10621
+ color: 'primary.main'
10622
+ }
10623
+ }, renderMoney(orderTotal === null || orderTotal === void 0 ? void 0 : orderTotal.totalAmount)))))))), /*#__PURE__*/React__default.createElement(material.DialogActions, {
10624
+ sx: {
10625
+ justifyContent: 'center',
10626
+ padding: 2
10627
+ }
10628
+ }, /*#__PURE__*/React__default.createElement(MuiButton, {
10629
+ variant: "contained",
10630
+ onClick: function onClick() {
10631
+ return onCancel(false);
10632
+ },
10633
+ primaryColor: primaryColor,
10634
+ style: {
10635
+ fontSize: '1.1rem',
10636
+ padding: '0.5rem 2rem',
10637
+ fontWeight: 700
10638
+ }
10639
+ }, "Okay")));
10640
+ };
10641
+
10501
10642
  var _templateObject$K, _templateObject2$v, _templateObject3$m, _templateObject4$i, _templateObject5$e, _templateObject6$c, _templateObject7$8, _templateObject8$6;
10502
10643
  var CheckoutRootContainer = styled__default.div(_templateObject$K || (_templateObject$K = _taggedTemplateLiteralLoose(["\n width: 100%;\n padding: 2rem;\n background-color: ", ";\n font-size: 16px;\n\n div,\n button,\n span {\n font-size: 16px;\n }\n @media only screen and (max-width: 1600px) {\n padding: 3em 0.5em;\n }\n @media screen and (max-width: 900px) {\n div,\n button,\n span {\n font-size: 12px;\n }\n padding: 2rem 0.5rem;\n }\n"])), function (props) {
10503
10644
  return props.bg;
@@ -11218,7 +11359,7 @@ var Step2 = function Step2(_ref) {
11218
11359
  if (rangeValue) {
11219
11360
  modifyItem.amount = rangeValue === null || rangeValue === void 0 ? void 0 : rangeValue.value;
11220
11361
  }
11221
- if (item !== null && item !== void 0 && item.freeShippingLimit && (orderTotal === null || orderTotal === void 0 ? void 0 : orderTotal.totalAmount) > (item === null || item === void 0 ? void 0 : item.freeShippingLimit)) {
11362
+ if (item !== null && item !== void 0 && item.freeShippingLimit && ((orderTotal === null || orderTotal === void 0 ? void 0 : orderTotal.totalAmount) || 0) - ((orderTotal === null || orderTotal === void 0 ? void 0 : orderTotal.shippingAmount) || 0) > (item === null || item === void 0 ? void 0 : item.freeShippingLimit)) {
11222
11363
  modifyItem.amount = 0;
11223
11364
  }
11224
11365
  return modifyItem;
@@ -12698,152 +12839,6 @@ var Step4 = function Step4(_ref) {
12698
12839
  })))))));
12699
12840
  };
12700
12841
 
12701
- var DiscountSummaryModal = function DiscountSummaryModal(_ref) {
12702
- var discountCoupons = _ref.discountCoupons,
12703
- orderTotal = _ref.orderTotal,
12704
- primaryColor = _ref.primaryColor,
12705
- open = _ref.open,
12706
- onCancel = _ref.onCancel;
12707
- return /*#__PURE__*/React__default.createElement(material.Dialog, {
12708
- open: open,
12709
- onClose: onCancel,
12710
- fullWidth: true,
12711
- maxWidth: "sm"
12712
- }, /*#__PURE__*/React__default.createElement(material.DialogTitle, null, /*#__PURE__*/React__default.createElement(material.Typography, {
12713
- variant: "h4",
12714
- fontWeight: "bold",
12715
- align: "center",
12716
- sx: {
12717
- color: '#000000',
12718
- fontSize: '1.8rem'
12719
- }
12720
- }, "Discount Has Been Applied! \uD83C\uDF89")), /*#__PURE__*/React__default.createElement(material.DialogContent, null, /*#__PURE__*/React__default.createElement(material.Box, {
12721
- sx: {
12722
- padding: 2
12723
- }
12724
- }, /*#__PURE__*/React__default.createElement(material.TableContainer, {
12725
- component: material.Box,
12726
- sx: {
12727
- border: '1px solid #e0e0e0',
12728
- borderRadius: 2
12729
- }
12730
- }, /*#__PURE__*/React__default.createElement(material.Table, null, /*#__PURE__*/React__default.createElement(material.TableHead, null, /*#__PURE__*/React__default.createElement(material.TableRow, null, /*#__PURE__*/React__default.createElement(material.TableCell, {
12731
- sx: {
12732
- fontWeight: 'bold',
12733
- fontSize: '1.2rem',
12734
- padding: '12px'
12735
- }
12736
- }, "Coupon Code"), /*#__PURE__*/React__default.createElement(material.TableCell, {
12737
- sx: {
12738
- fontWeight: 'bold',
12739
- fontSize: '1.2rem',
12740
- padding: '12px'
12741
- }
12742
- }, "Discount"), /*#__PURE__*/React__default.createElement(material.TableCell, {
12743
- sx: {
12744
- fontWeight: 'bold',
12745
- fontSize: '1.2rem',
12746
- padding: '12px'
12747
- }
12748
- }, "Auto Applied"))), /*#__PURE__*/React__default.createElement(material.TableBody, null, discountCoupons === null || discountCoupons === void 0 ? void 0 : discountCoupons.map(function (item, i) {
12749
- return /*#__PURE__*/React__default.createElement(material.TableRow, {
12750
- key: i
12751
- }, /*#__PURE__*/React__default.createElement(material.TableCell, {
12752
- sx: {
12753
- fontWeight: 'bold',
12754
- fontSize: '1.2rem',
12755
- padding: '12px'
12756
- }
12757
- }, (item === null || item === void 0 ? void 0 : item.couponCode) || ''), /*#__PURE__*/React__default.createElement(material.TableCell, {
12758
- sx: {
12759
- fontSize: '1.2rem',
12760
- padding: '12px',
12761
- color: 'success.main',
12762
- fontWeight: 'bold'
12763
- }
12764
- }, "$", (item === null || item === void 0 ? void 0 : item.amount) || ''), /*#__PURE__*/React__default.createElement(material.TableCell, {
12765
- sx: {
12766
- fontSize: '1.2rem',
12767
- padding: '12px'
12768
- }
12769
- }, item !== null && item !== void 0 && item.autoApplicable ? /*#__PURE__*/React__default.createElement(io5.IoCheckmarkCircleOutline, {
12770
- color: "green",
12771
- style: {
12772
- fontSize: '1.5rem'
12773
- }
12774
- }) : /*#__PURE__*/React__default.createElement(io5.IoCloseCircleOutline, {
12775
- color: "red",
12776
- style: {
12777
- fontSize: '1.5rem'
12778
- }
12779
- })));
12780
- })))), /*#__PURE__*/React__default.createElement(material.Divider, {
12781
- sx: {
12782
- marginY: 3
12783
- }
12784
- }), /*#__PURE__*/React__default.createElement(material.TableContainer, {
12785
- component: material.Box,
12786
- sx: {
12787
- border: '1px solid #e0e0e0',
12788
- borderRadius: 2
12789
- }
12790
- }, /*#__PURE__*/React__default.createElement(material.Table, null, /*#__PURE__*/React__default.createElement(material.TableBody, null, /*#__PURE__*/React__default.createElement(material.TableRow, null, /*#__PURE__*/React__default.createElement(material.TableCell, {
12791
- sx: {
12792
- fontWeight: 'bold',
12793
- fontSize: '1.2rem',
12794
- padding: '12px'
12795
- }
12796
- }, "Sub Total"), /*#__PURE__*/React__default.createElement(material.TableCell, {
12797
- sx: {
12798
- fontWeight: 'bold',
12799
- fontSize: '1.2rem',
12800
- padding: '12px'
12801
- }
12802
- }, "$", (orderTotal === null || orderTotal === void 0 ? void 0 : orderTotal.subTotal) || '')), /*#__PURE__*/React__default.createElement(material.TableRow, null, /*#__PURE__*/React__default.createElement(material.TableCell, {
12803
- sx: {
12804
- fontWeight: 'bold',
12805
- fontSize: '1.2rem',
12806
- padding: '12px'
12807
- }
12808
- }, "Total Discount"), /*#__PURE__*/React__default.createElement(material.TableCell, {
12809
- sx: {
12810
- fontWeight: 'bold',
12811
- fontSize: '1.2rem',
12812
- padding: '12px',
12813
- color: 'success.main'
12814
- }
12815
- }, "$", (orderTotal === null || orderTotal === void 0 ? void 0 : orderTotal.couponDiscountTotal) || '')), /*#__PURE__*/React__default.createElement(material.TableRow, null, /*#__PURE__*/React__default.createElement(material.TableCell, {
12816
- sx: {
12817
- fontWeight: 'bold',
12818
- fontSize: '1.2rem',
12819
- padding: '12px'
12820
- }
12821
- }, "Order Total"), /*#__PURE__*/React__default.createElement(material.TableCell, {
12822
- sx: {
12823
- fontWeight: 'bold',
12824
- fontSize: '1.2rem',
12825
- padding: '12px',
12826
- color: 'primary.main'
12827
- }
12828
- }, "$", (orderTotal === null || orderTotal === void 0 ? void 0 : orderTotal.totalAmount) || ''))))))), /*#__PURE__*/React__default.createElement(material.DialogActions, {
12829
- sx: {
12830
- justifyContent: 'center',
12831
- padding: 2
12832
- }
12833
- }, /*#__PURE__*/React__default.createElement(MuiButton, {
12834
- variant: "contained",
12835
- onClick: function onClick() {
12836
- return onCancel(false);
12837
- },
12838
- primaryColor: primaryColor,
12839
- style: {
12840
- fontSize: '1.1rem',
12841
- padding: '0.5rem 2rem',
12842
- fontWeight: 700
12843
- }
12844
- }, "Okay")));
12845
- };
12846
-
12847
12842
  var steps = [{
12848
12843
  text: 'Personal Information',
12849
12844
  icon: /*#__PURE__*/React__default.createElement(cg.CgProfile, {
@@ -12951,6 +12946,7 @@ var CheckoutPageComponent = function CheckoutPageComponent(_ref) {
12951
12946
  discountCoupons = _useState19[0],
12952
12947
  setDiscountCoupons = _useState19[1];
12953
12948
  var previousSubTotalRef = React.useRef(null);
12949
+ var previousShippingAddressIdRef = React.useRef(null);
12954
12950
  React.useEffect(function () {
12955
12951
  if (apiEndPoint && token) {
12956
12952
  (function () {
@@ -13051,120 +13047,138 @@ var CheckoutPageComponent = function CheckoutPageComponent(_ref) {
13051
13047
  setCurrStep(0);
13052
13048
  }
13053
13049
  }, [customer, currStep]);
13054
- var inDebounce;
13055
13050
  React.useEffect(function () {
13056
13051
  (function () {
13057
13052
  try {
13058
- var _temp12 = function () {
13059
- if (!isNullUndefined(cartData === null || cartData === void 0 ? void 0 : cartData.cartSubTotal) && customer && (cartData === null || cartData === void 0 ? void 0 : cartData.cartSubTotal) !== previousSubTotalRef.current) {
13060
- var _temp11 = function _temp11() {
13061
- previousSubTotalRef.current = cartData === null || cartData === void 0 ? void 0 : cartData.cartSubTotal;
13062
- cartTotalOnChangeData();
13063
- };
13064
- var _temp10 = _catch(function () {
13065
- return Promise.resolve(autoApplyCoupon({
13066
- apiEndPoint: apiEndPoint,
13067
- token: token,
13068
- subTotal: cartData === null || cartData === void 0 ? void 0 : cartData.cartSubTotal
13069
- })).then(function () {
13070
- function _temp9(_fetchCartData) {
13071
- _fetchCartData;
13072
- }
13073
- return fetchCartData ? Promise.resolve(fetchCartData()).then(_temp9) : _temp9(fetchCartData);
13053
+ var _temp9 = function () {
13054
+ if (customer) {
13055
+ return Promise.resolve(taxFunction()).then(function (taxAmount) {
13056
+ return Promise.resolve(discountFunction()).then(function (couponDiscountTotal) {
13057
+ return Promise.resolve(cartTotalOnChangeData({
13058
+ apiCouponDiscountTotal: couponDiscountTotal || 0,
13059
+ apiTaxAmount: taxAmount || 0
13060
+ })).then(function () {});
13074
13061
  });
13075
- }, function () {});
13076
- return _temp10 && _temp10.then ? _temp10.then(_temp11) : _temp11(_temp10);
13062
+ });
13077
13063
  }
13078
13064
  }();
13079
- return _temp12 && _temp12.then ? _temp12.then(function () {}) : void 0;
13065
+ return _temp9 && _temp9.then ? _temp9.then(function () {}) : void 0;
13080
13066
  } catch (e) {
13081
13067
  Promise.reject(e);
13082
13068
  }
13083
13069
  })();
13084
13070
  }, [customer, cartData, shippingMethod, ccProcessingFees, shippingAddressId]);
13085
- var cartTotalOnChangeData = function cartTotalOnChangeData() {
13086
- clearTimeout(inDebounce);
13087
- inDebounce = setTimeout(function () {
13088
- (function () {
13089
- try {
13090
- var _temp18 = function () {
13091
- if (apiEndPoint && token) {
13092
- var _temp17 = function _temp17() {
13093
- function _temp15() {
13094
- var _taxAmount, _ref2, _ref3, _cartData$cartDiscoun, _cartData$cartSubTota, _ref4;
13095
- var totalData = {
13096
- taxAmount: parseFloat((_taxAmount = _taxAmount2) === null || _taxAmount === void 0 ? void 0 : _taxAmount.toFixed(2)),
13097
- shippingAmount: parseFloat((_ref2 = (shippingMethod === null || shippingMethod === void 0 ? void 0 : shippingMethod.amount) || 0) === null || _ref2 === void 0 ? void 0 : _ref2.toFixed(2)),
13098
- couponDiscountTotal: _couponDiscountTotal,
13099
- adjustmentValue: parseFloat((_ref3 = ccProcessingFees ? (cartData === null || cartData === void 0 ? void 0 : cartData.totalCartPrice) * (ccProcessingFees / 100) : 0) === null || _ref3 === void 0 ? void 0 : _ref3.toFixed(2)),
13100
- cartDiscount: parseFloat(cartData === null || cartData === void 0 ? void 0 : (_cartData$cartDiscoun = cartData.cartDiscount) === null || _cartData$cartDiscoun === void 0 ? void 0 : _cartData$cartDiscoun.toFixed(2)),
13101
- subTotal: parseFloat(cartData === null || cartData === void 0 ? void 0 : (_cartData$cartSubTota = cartData.cartSubTotal) === null || _cartData$cartSubTota === void 0 ? void 0 : _cartData$cartSubTota.toFixed(2)),
13102
- totalAmount: parseFloat((_ref4 = (cartData === null || cartData === void 0 ? void 0 : cartData.totalCartPrice) + _taxAmount2 + ((shippingMethod === null || shippingMethod === void 0 ? void 0 : shippingMethod.amount) || 0) - _couponDiscountTotal + (ccProcessingFees ? (cartData === null || cartData === void 0 ? void 0 : cartData.totalCartPrice) * (ccProcessingFees / 100) : 0)) === null || _ref4 === void 0 ? void 0 : _ref4.toFixed(2)),
13103
- totalQuantity: cartData === null || cartData === void 0 ? void 0 : cartData.totalCartQuantity
13104
- };
13105
- setOrderTotal(totalData);
13106
- }
13107
- var _temp14 = _catch(function () {
13108
- return Promise.resolve(getCartDiscountList({
13109
- apiEndPoint: apiEndPoint,
13110
- token: token
13111
- })).then(function (discountCouponsData) {
13112
- var _ref5;
13113
- _couponDiscountTotal = parseFloat((_ref5 = lodash.sumBy(discountCouponsData, 'amount') || 0) === null || _ref5 === void 0 ? void 0 : _ref5.toFixed(2));
13114
- setDiscountCoupons({
13115
- openDiscountModal: discountCouponsData === null || discountCouponsData === void 0 ? void 0 : discountCouponsData.some(function (coupon) {
13116
- return coupon.autoApplicable;
13117
- }),
13118
- discountCouponsData: discountCouponsData
13119
- });
13071
+ var taxFunction = function taxFunction() {
13072
+ try {
13073
+ return Promise.resolve(function (_cartData$cartLineIte) {
13074
+ if (shippingAddressId && (cartData === null || cartData === void 0 ? void 0 : (_cartData$cartLineIte = cartData.cartLineItemDtoList) === null || _cartData$cartLineIte === void 0 ? void 0 : _cartData$cartLineIte.length) > 0 && shippingAddressId !== previousShippingAddressIdRef.current) {
13075
+ var taxAmount = 0;
13076
+ return _catch(function () {
13077
+ return Promise.resolve(getTaxData({
13078
+ apiEndPoint: apiEndPoint,
13079
+ token: token,
13080
+ shippingAddressId: shippingAddressId
13081
+ })).then(function (taxData) {
13082
+ var _customer$customerDto;
13083
+ taxAmount = !(customer !== null && customer !== void 0 && (_customer$customerDto = customer.customerDto) !== null && _customer$customerDto !== void 0 && _customer$customerDto.taxable) ? 0 : lodash.sumBy(taxData, 'taxAmount') || 0;
13084
+ previousShippingAddressIdRef.current = shippingAddressId;
13085
+ return taxAmount;
13086
+ });
13087
+ }, function () {});
13088
+ }
13089
+ }());
13090
+ } catch (e) {
13091
+ return Promise.reject(e);
13092
+ }
13093
+ };
13094
+ var discountFunction = function discountFunction() {
13095
+ try {
13096
+ return Promise.resolve(function () {
13097
+ if (!isNullUndefined(cartData === null || cartData === void 0 ? void 0 : cartData.cartSubTotal) && (cartData === null || cartData === void 0 ? void 0 : cartData.cartSubTotal) !== previousSubTotalRef.current) {
13098
+ var couponDiscountTotal = 0;
13099
+ return _catch(function () {
13100
+ return Promise.resolve(autoApplyCoupon({
13101
+ apiEndPoint: apiEndPoint,
13102
+ token: token,
13103
+ subTotal: cartData === null || cartData === void 0 ? void 0 : cartData.cartSubTotal
13104
+ })).then(function () {
13105
+ function _temp10(_fetchCartData) {
13106
+ _fetchCartData;
13107
+ return Promise.resolve(getCartDiscountList({
13108
+ apiEndPoint: apiEndPoint,
13109
+ token: token
13110
+ })).then(function (discountCouponsData) {
13111
+ var _ref2;
13112
+ couponDiscountTotal = parseFloat((_ref2 = lodash.sumBy(discountCouponsData, 'amount') || 0) === null || _ref2 === void 0 ? void 0 : _ref2.toFixed(2));
13113
+ setDiscountCoupons({
13114
+ openDiscountModal: discountCouponsData === null || discountCouponsData === void 0 ? void 0 : discountCouponsData.some(function (coupon) {
13115
+ return coupon === null || coupon === void 0 ? void 0 : coupon.autoApplicable;
13116
+ }),
13117
+ discountCouponsData: discountCouponsData
13120
13118
  });
13121
- }, function () {});
13122
- return _temp14 && _temp14.then ? _temp14.then(_temp15) : _temp15(_temp14);
13123
- };
13124
- var _taxAmount2 = 0;
13125
- var _couponDiscountTotal = 0;
13126
- var _temp16 = function (_cartData$cartLineIte) {
13127
- if (shippingAddressId && (cartData === null || cartData === void 0 ? void 0 : (_cartData$cartLineIte = cartData.cartLineItemDtoList) === null || _cartData$cartLineIte === void 0 ? void 0 : _cartData$cartLineIte.length) > 0) {
13128
- var _temp13 = _catch(function () {
13129
- return Promise.resolve(getTaxData({
13130
- apiEndPoint: apiEndPoint,
13131
- token: token,
13132
- shippingAddressId: shippingAddressId
13133
- })).then(function (taxData) {
13134
- var _customer$customerDto;
13135
- _taxAmount2 = !(customer !== null && customer !== void 0 && (_customer$customerDto = customer.customerDto) !== null && _customer$customerDto !== void 0 && _customer$customerDto.taxable) ? 0 : lodash.sumBy(taxData, 'taxAmount') || 0;
13136
- });
13137
- }, function () {});
13138
- if (_temp13 && _temp13.then) return _temp13.then(function () {});
13139
- }
13140
- }();
13141
- return _temp16 && _temp16.then ? _temp16.then(_temp17) : _temp17(_temp16);
13142
- }
13143
- }();
13144
- return _temp18 && _temp18.then ? _temp18.then(function () {}) : void 0;
13119
+ previousSubTotalRef.current = cartData === null || cartData === void 0 ? void 0 : cartData.cartSubTotal;
13120
+ return couponDiscountTotal;
13121
+ });
13122
+ }
13123
+ return fetchCartData ? Promise.resolve(fetchCartData()).then(_temp10) : _temp10(fetchCartData);
13124
+ });
13125
+ }, function () {});
13126
+ }
13127
+ }());
13128
+ } catch (e) {
13129
+ return Promise.reject(e);
13130
+ }
13131
+ };
13132
+ var inDebounce;
13133
+ var cartTotalOnChangeData = function cartTotalOnChangeData(_ref3) {
13134
+ var apiCouponDiscountTotal = _ref3.apiCouponDiscountTotal,
13135
+ apiTaxAmount = _ref3.apiTaxAmount;
13136
+ try {
13137
+ clearTimeout(inDebounce);
13138
+ inDebounce = setTimeout(function () {
13139
+ try {
13140
+ if (apiEndPoint && token) {
13141
+ var _ref4, _ref5, _cartData$cartDiscoun, _cartData$cartSubTota, _ref6;
13142
+ var taxAmount = apiTaxAmount || 0;
13143
+ var couponDiscountTotal = apiCouponDiscountTotal || 0;
13144
+ var totalData = {
13145
+ taxAmount: parseFloat(taxAmount === null || taxAmount === void 0 ? void 0 : taxAmount.toFixed(2)),
13146
+ shippingAmount: parseFloat((_ref4 = (shippingMethod === null || shippingMethod === void 0 ? void 0 : shippingMethod.amount) || 0) === null || _ref4 === void 0 ? void 0 : _ref4.toFixed(2)),
13147
+ couponDiscountTotal: couponDiscountTotal,
13148
+ adjustmentValue: parseFloat((_ref5 = ccProcessingFees ? (cartData === null || cartData === void 0 ? void 0 : cartData.totalCartPrice) * (ccProcessingFees / 100) : 0) === null || _ref5 === void 0 ? void 0 : _ref5.toFixed(2)),
13149
+ cartDiscount: parseFloat(cartData === null || cartData === void 0 ? void 0 : (_cartData$cartDiscoun = cartData.cartDiscount) === null || _cartData$cartDiscoun === void 0 ? void 0 : _cartData$cartDiscoun.toFixed(2)),
13150
+ subTotal: parseFloat(cartData === null || cartData === void 0 ? void 0 : (_cartData$cartSubTota = cartData.cartSubTotal) === null || _cartData$cartSubTota === void 0 ? void 0 : _cartData$cartSubTota.toFixed(2)),
13151
+ totalAmount: parseFloat((_ref6 = (cartData === null || cartData === void 0 ? void 0 : cartData.totalCartPrice) + taxAmount + ((shippingMethod === null || shippingMethod === void 0 ? void 0 : shippingMethod.amount) || 0) - couponDiscountTotal + (ccProcessingFees ? (cartData === null || cartData === void 0 ? void 0 : cartData.totalCartPrice) * (ccProcessingFees / 100) : 0)) === null || _ref6 === void 0 ? void 0 : _ref6.toFixed(2)),
13152
+ totalQuantity: cartData === null || cartData === void 0 ? void 0 : cartData.totalCartQuantity
13153
+ };
13154
+ setOrderTotal(totalData);
13155
+ }
13145
13156
  } catch (e) {
13146
13157
  Promise.reject(e);
13147
13158
  }
13148
- })();
13149
- }, 500);
13159
+ }, 500);
13160
+ return Promise.resolve();
13161
+ } catch (e) {
13162
+ return Promise.reject(e);
13163
+ }
13150
13164
  };
13151
13165
  var onLoginCustomer = function onLoginCustomer(data) {
13152
13166
  try {
13153
- var _temp20 = function _temp20() {
13167
+ var _temp12 = function _temp12() {
13154
13168
  setLoginLoading(false);
13155
13169
  };
13156
13170
  setLoginLoading(true);
13157
- var _temp19 = _catch(function () {
13171
+ var _temp11 = _catch(function () {
13158
13172
  return Promise.resolve(handleLogin(data)).then(function () {});
13159
13173
  }, function () {});
13160
- return Promise.resolve(_temp19 && _temp19.then ? _temp19.then(_temp20) : _temp20(_temp19));
13174
+ return Promise.resolve(_temp11 && _temp11.then ? _temp11.then(_temp12) : _temp12(_temp11));
13161
13175
  } catch (e) {
13162
13176
  return Promise.reject(e);
13163
13177
  }
13164
13178
  };
13165
13179
  var addStoreAddress = function addStoreAddress(data) {
13166
13180
  try {
13167
- var _temp22 = _catch(function () {
13181
+ var _temp14 = _catch(function () {
13168
13182
  var _customer$customerDto2;
13169
13183
  return Promise.resolve(createStoreAddress({
13170
13184
  apiEndPoint: apiEndPoint,
@@ -13172,7 +13186,7 @@ var CheckoutPageComponent = function CheckoutPageComponent(_ref) {
13172
13186
  data: data,
13173
13187
  customerId: customer === null || customer === void 0 ? void 0 : (_customer$customerDto2 = customer.customerDto) === null || _customer$customerDto2 === void 0 ? void 0 : _customer$customerDto2.id
13174
13188
  })).then(function (result) {
13175
- var _temp21 = function () {
13189
+ var _temp13 = function () {
13176
13190
  if (result) {
13177
13191
  return Promise.resolve(getCustomer({
13178
13192
  apiEndPoint: apiEndPoint,
@@ -13182,10 +13196,10 @@ var CheckoutPageComponent = function CheckoutPageComponent(_ref) {
13182
13196
  });
13183
13197
  }
13184
13198
  }();
13185
- if (_temp21 && _temp21.then) return _temp21.then(function () {});
13199
+ if (_temp13 && _temp13.then) return _temp13.then(function () {});
13186
13200
  });
13187
13201
  }, function () {});
13188
- return Promise.resolve(_temp22 && _temp22.then ? _temp22.then(function () {}) : void 0);
13202
+ return Promise.resolve(_temp14 && _temp14.then ? _temp14.then(function () {}) : void 0);
13189
13203
  } catch (e) {
13190
13204
  return Promise.reject(e);
13191
13205
  }
@@ -13258,11 +13272,11 @@ var CheckoutPageComponent = function CheckoutPageComponent(_ref) {
13258
13272
  };
13259
13273
  var onPlaceOrder = function onPlaceOrder(note, transactionId) {
13260
13274
  try {
13261
- var _temp24 = function _temp24() {
13275
+ var _temp16 = function _temp16() {
13262
13276
  setOrdering(false);
13263
13277
  };
13264
13278
  setOrdering(true);
13265
- var _temp23 = _catch(function () {
13279
+ var _temp15 = _catch(function () {
13266
13280
  var authorizeCustomerCardData = {
13267
13281
  authorizeDotNetCustomerProfileId: selectedPaymentMethod === null || selectedPaymentMethod === void 0 ? void 0 : selectedPaymentMethod.authorizeDotNetCustomerProfileId,
13268
13282
  authorizeDotNetCustomerPaymentProfileId: selectedPaymentMethod === null || selectedPaymentMethod === void 0 ? void 0 : selectedPaymentMethod.authorizeDotNetCustomerPaymentProfileId
@@ -13319,12 +13333,12 @@ var CheckoutPageComponent = function CheckoutPageComponent(_ref) {
13319
13333
  paymentModeId: selectedStoreCredits === null || selectedStoreCredits === void 0 ? void 0 : selectedStoreCredits.id
13320
13334
  }];
13321
13335
  } else if (selectedStoreCredits && (selectedStoreCredits === null || selectedStoreCredits === void 0 ? void 0 : selectedStoreCredits.amount) < (orderTotal === null || orderTotal === void 0 ? void 0 : orderTotal.totalAmount)) {
13322
- var _selectedStoreCredits, _ref6;
13336
+ var _selectedStoreCredits, _ref7;
13323
13337
  orderPaymentList = [{
13324
13338
  amount: parseFloat(selectedStoreCredits === null || selectedStoreCredits === void 0 ? void 0 : (_selectedStoreCredits = selectedStoreCredits.amount) === null || _selectedStoreCredits === void 0 ? void 0 : _selectedStoreCredits.toFixed(2)),
13325
13339
  paymentModeId: selectedStoreCredits === null || selectedStoreCredits === void 0 ? void 0 : selectedStoreCredits.id
13326
13340
  }, _extends({
13327
- amount: parseFloat((_ref6 = (orderTotal === null || orderTotal === void 0 ? void 0 : orderTotal.totalAmount) - (selectedStoreCredits === null || selectedStoreCredits === void 0 ? void 0 : selectedStoreCredits.amount)) === null || _ref6 === void 0 ? void 0 : _ref6.toFixed(2)),
13341
+ amount: parseFloat((_ref7 = (orderTotal === null || orderTotal === void 0 ? void 0 : orderTotal.totalAmount) - (selectedStoreCredits === null || selectedStoreCredits === void 0 ? void 0 : selectedStoreCredits.amount)) === null || _ref7 === void 0 ? void 0 : _ref7.toFixed(2)),
13328
13342
  paymentModeId: selectedPaymentMethod === null || selectedPaymentMethod === void 0 ? void 0 : selectedPaymentMethod.id,
13329
13343
  customerOrderCard: ecommerceCustomPaymentDto,
13330
13344
  transactionId: transactionId
@@ -13349,7 +13363,7 @@ var CheckoutPageComponent = function CheckoutPageComponent(_ref) {
13349
13363
  }
13350
13364
  return Promise.resolve(createSalesOrder(salesOrderDtoBody)).then(function () {});
13351
13365
  }, function () {});
13352
- return Promise.resolve(_temp23 && _temp23.then ? _temp23.then(_temp24) : _temp24(_temp23));
13366
+ return Promise.resolve(_temp15 && _temp15.then ? _temp15.then(_temp16) : _temp16(_temp15));
13353
13367
  } catch (e) {
13354
13368
  return Promise.reject(e);
13355
13369
  }