@open-tender/store 1.1.275 → 1.1.277

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.
@@ -6,14 +6,17 @@ var hooks_1 = require("../app/hooks");
6
6
  var slices_1 = require("../slices");
7
7
  var Applied_1 = tslib_1.__importDefault(require("./Applied"));
8
8
  var Reward = function (_a) {
9
+ var _b;
9
10
  var reward = _a.reward, isLast = _a.isLast, index = _a.index, callback = _a.callback, children = _a.children, AppliedView = _a.AppliedView;
10
11
  var dispatch = (0, hooks_1.useAppDispatch)();
11
12
  var apiUrl = (0, hooks_1.useAppSelector)(slices_1.selectKioskApi);
12
- var _b = (0, hooks_1.useAppSelector)(slices_1.selectKioskConfig), config = _b.reward, cardConfig = _b.card;
13
+ var _c = (0, hooks_1.useAppSelector)(slices_1.selectKioskConfig), config = _c.reward, cardConfig = _c.card;
13
14
  var check = (0, hooks_1.useAppSelector)(slices_1.selectPosCheckout).check;
14
- var discounts = check === null || check === void 0 ? void 0 : check.discounts.map(function (i) { return [i.id, i.index]; });
15
+ var discounts = check === null || check === void 0 ? void 0 : check.discounts;
15
16
  var id = reward.discount_id;
16
- var isApplied = !!(discounts === null || discounts === void 0 ? void 0 : discounts.includes([id, index]));
17
+ var isApplied = (_b = discounts === null || discounts === void 0 ? void 0 : discounts.some(function (discount) {
18
+ return discount.id === id && discount.index === index;
19
+ })) !== null && _b !== void 0 ? _b : false;
17
20
  var apply = function () {
18
21
  dispatch((0, slices_1.addDiscount)({ id: id, index: index }));
19
22
  if (callback)
@@ -521,13 +521,19 @@ var checkoutSlice = (0, toolkit_1.createSlice)({
521
521
  var id = action.payload.id;
522
522
  var discountIndex = action.payload.index;
523
523
  var discount = state.check
524
- ? state.check.discounts.find(function (item, index) { return item.id === id && index === discountIndex; })
524
+ ? state.check.discounts.find(function (item) {
525
+ return item.id === id && item.index === discountIndex;
526
+ })
525
527
  : null;
526
528
  if (discount && discount.discount_type === 'LOYALTY') {
527
529
  state.points = [];
528
530
  }
529
531
  else {
530
- state.discounts = state.discounts.filter(function (item, index) { return item.id !== id && index !== discountIndex; });
532
+ state.discounts = state.discounts.filter(function (item) {
533
+ return item.id !== id &&
534
+ item.index !== undefined &&
535
+ item.index !== discountIndex;
536
+ });
531
537
  }
532
538
  },
533
539
  addTax: function (state, action) {
@@ -3,14 +3,17 @@ import { useAppDispatch, useAppSelector } from '../app/hooks';
3
3
  import { addDiscount, removeDiscount, selectKioskApi, selectKioskConfig, selectPosCheckout } from '../slices';
4
4
  import { default as AppliedContainer } from './Applied';
5
5
  var Reward = function (_a) {
6
+ var _b;
6
7
  var reward = _a.reward, isLast = _a.isLast, index = _a.index, callback = _a.callback, children = _a.children, AppliedView = _a.AppliedView;
7
8
  var dispatch = useAppDispatch();
8
9
  var apiUrl = useAppSelector(selectKioskApi);
9
- var _b = useAppSelector(selectKioskConfig), config = _b.reward, cardConfig = _b.card;
10
+ var _c = useAppSelector(selectKioskConfig), config = _c.reward, cardConfig = _c.card;
10
11
  var check = useAppSelector(selectPosCheckout).check;
11
- var discounts = check === null || check === void 0 ? void 0 : check.discounts.map(function (i) { return [i.id, i.index]; });
12
+ var discounts = check === null || check === void 0 ? void 0 : check.discounts;
12
13
  var id = reward.discount_id;
13
- var isApplied = !!(discounts === null || discounts === void 0 ? void 0 : discounts.includes([id, index]));
14
+ var isApplied = (_b = discounts === null || discounts === void 0 ? void 0 : discounts.some(function (discount) {
15
+ return discount.id === id && discount.index === index;
16
+ })) !== null && _b !== void 0 ? _b : false;
14
17
  var apply = function () {
15
18
  dispatch(addDiscount({ id: id, index: index }));
16
19
  if (callback)
@@ -517,13 +517,19 @@ var checkoutSlice = createSlice({
517
517
  var id = action.payload.id;
518
518
  var discountIndex = action.payload.index;
519
519
  var discount = state.check
520
- ? state.check.discounts.find(function (item, index) { return item.id === id && index === discountIndex; })
520
+ ? state.check.discounts.find(function (item) {
521
+ return item.id === id && item.index === discountIndex;
522
+ })
521
523
  : null;
522
524
  if (discount && discount.discount_type === 'LOYALTY') {
523
525
  state.points = [];
524
526
  }
525
527
  else {
526
- state.discounts = state.discounts.filter(function (item, index) { return item.id !== id && index !== discountIndex; });
528
+ state.discounts = state.discounts.filter(function (item) {
529
+ return item.id !== id &&
530
+ item.index !== undefined &&
531
+ item.index !== discountIndex;
532
+ });
527
533
  }
528
534
  },
529
535
  addTax: function (state, action) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/store",
3
- "version": "1.1.275",
3
+ "version": "1.1.277",
4
4
  "description": "A library of hooks, reducers, utility functions, and types for use with Open Tender applications that utilize our in-store POS API",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",