@techstuff-dev/foundation-api-utils 2.3.0 → 2.3.1

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.
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var toolkit = require('@reduxjs/toolkit');
4
- var slice = require('./slice-Dpwqdz65.js');
4
+ var slice = require('./slice-CJ4WSj5p.js');
5
5
  var slice$1 = require('./slice-CkWobkWw.js');
6
6
 
7
7
  // This file exists just so TypeScript has a module at ./store for IDEs/build.
@@ -11,4 +11,4 @@ var slice$1 = require('./slice-CkWobkWw.js');
11
11
  const rootReducer = toolkit.combineSlices(slice.cartSlice, slice$1.authSlice, slice.authApi, slice.contentApi, slice.paymentApi, slice.productsApi, slice.ordersApi);
12
12
 
13
13
  exports.rootReducer = rootReducer;
14
- //# sourceMappingURL=shared-CdwWllrh.js.map
14
+ //# sourceMappingURL=shared-Dg7JQIWA.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shared-CdwWllrh.js","sources":["../../../lib/store/shared.ts"],"sourcesContent":[null],"names":["combineSlices","cartSlice","authSlice","authApi","contentApi","paymentApi","productsApi","ordersApi"],"mappings":";;;;;;AAAA;AACA;AAUA;AAEA;MACa,WAAW,GAAGA,qBAAa,CACtCC,eAAS,EACTC,iBAAS,EACTC,aAAO,EACPC,gBAAU,EACVC,gBAAU,EACVC,iBAAW,EACXC,eAAS;;;;"}
1
+ {"version":3,"file":"shared-Dg7JQIWA.js","sources":["../../../lib/store/shared.ts"],"sourcesContent":[null],"names":["combineSlices","cartSlice","authSlice","authApi","contentApi","paymentApi","productsApi","ordersApi"],"mappings":";;;;;;AAAA;AACA;AAUA;AAEA;MACa,WAAW,GAAGA,qBAAa,CACtCC,eAAS,EACTC,iBAAS,EACTC,aAAO,EACPC,gBAAU,EACVC,gBAAU,EACVC,iBAAW,EACXC,eAAS;;;;"}
@@ -6549,10 +6549,13 @@ const cartSlice = toolkit.createSlice({
6549
6549
  },
6550
6550
  addToCart: (state, action) => {
6551
6551
  const { options, item } = action.payload;
6552
- const newTotal = state.netTotal + options.selectedPrice;
6552
+ const price = Number(options?.selectedPrice) || 0;
6553
+ const currentNetTotal = Number(state.netTotal) || 0;
6554
+ const newTotal = currentNetTotal + price;
6553
6555
  const taxAmount = newTotal * (state.taxRate.percentage / 100);
6554
6556
  const grossTotal = newTotal + taxAmount;
6555
- const addItem = item ? { ...item, options } : null;
6557
+ const sanitizedOptions = { ...options, selectedPrice: price };
6558
+ const addItem = item ? { ...item, options: sanitizedOptions } : null;
6556
6559
  if (!addItem) {
6557
6560
  return state;
6558
6561
  }
@@ -6576,7 +6579,9 @@ const cartSlice = toolkit.createSlice({
6576
6579
  },
6577
6580
  removeFromCart: (state, action) => {
6578
6581
  const { id, price } = action.payload;
6579
- const newTotal = state.netTotal - price;
6582
+ const sanitizedPrice = Number(price) || 0;
6583
+ const currentNetTotal = Number(state.netTotal) || 0;
6584
+ const newTotal = currentNetTotal - sanitizedPrice;
6580
6585
  const taxAmount = newTotal * (state.taxRate.percentage / 100);
6581
6586
  const grossTotal = newTotal + taxAmount;
6582
6587
  return {
@@ -6703,4 +6708,4 @@ exports.useUpdateUserMutation = useUpdateUserMutation;
6703
6708
  exports.useVerifyUserAttributesQuery = useVerifyUserAttributesQuery;
6704
6709
  exports.useVerifyUserQuery = useVerifyUserQuery;
6705
6710
  exports.useVerifyUserResendQuery = useVerifyUserResendQuery;
6706
- //# sourceMappingURL=slice-Dpwqdz65.js.map
6711
+ //# sourceMappingURL=slice-CJ4WSj5p.js.map