@open-tender/store 1.1.276 → 1.1.278

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)
@@ -358,12 +358,11 @@ exports.addCreditTender = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.Add
358
358
  }); });
359
359
  exports.validatePosOrder = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.ValidatePosOrder, function (_1, _a) { return tslib_1.__awaiter(void 0, [_1, _a], void 0, function (_, _b) {
360
360
  var _c, config, order, checkout, preparedOrder, check, submitted, validated_1, toRemove, err_8, errors, fields;
361
- var _d;
362
361
  var dispatch = _b.dispatch, getState = _b.getState, rejectWithValue = _b.rejectWithValue;
363
- return tslib_1.__generator(this, function (_e) {
364
- switch (_e.label) {
362
+ return tslib_1.__generator(this, function (_d) {
363
+ switch (_d.label) {
365
364
  case 0:
366
- _e.trys.push([0, 2, , 3]);
365
+ _d.trys.push([0, 2, , 3]);
367
366
  _c = getState(), config = _c.config, order = _c.order, checkout = _c.checkout;
368
367
  preparedOrder = (0, exports.prepareOrder)(order, checkout);
369
368
  if (!preparedOrder)
@@ -372,14 +371,16 @@ exports.validatePosOrder = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.Va
372
371
  // remove any submitted discounts that aren't applied
373
372
  ];
374
373
  case 1:
375
- check = _e.sent();
376
- submitted = (_d = preparedOrder.discounts) === null || _d === void 0 ? void 0 : _d.map(function (i) { return i.id; });
374
+ check = _d.sent();
375
+ submitted = preparedOrder.discounts;
377
376
  validated_1 = check.discounts.map(function (i) { return i.id; });
378
- toRemove = submitted === null || submitted === void 0 ? void 0 : submitted.filter(function (id) { return !validated_1.includes(id); });
379
- toRemove === null || toRemove === void 0 ? void 0 : toRemove.forEach(function (id) { return dispatch((0, exports.removeDiscount)({ id: id })); });
377
+ toRemove = submitted === null || submitted === void 0 ? void 0 : submitted.filter(function (discount) { return !validated_1.includes(discount.id); });
378
+ toRemove === null || toRemove === void 0 ? void 0 : toRemove.forEach(function (discount) {
379
+ return dispatch((0, exports.removeDiscount)({ id: discount.id, index: discount.index }));
380
+ });
380
381
  return [2 /*return*/, check];
381
382
  case 2:
382
- err_8 = _e.sent();
383
+ err_8 = _d.sent();
383
384
  errors = (0, utils_1.handleRespError)(err_8).errors;
384
385
  fields = errors ? Object.keys(errors) : [];
385
386
  if (fields.includes('order_uuid')) {
@@ -530,7 +531,9 @@ var checkoutSlice = (0, toolkit_1.createSlice)({
530
531
  }
531
532
  else {
532
533
  state.discounts = state.discounts.filter(function (item) {
533
- return item.id !== id && item.index !== discountIndex;
534
+ return item.id !== id &&
535
+ item.index !== undefined &&
536
+ item.index !== discountIndex;
534
537
  });
535
538
  }
536
539
  },
@@ -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)
@@ -354,12 +354,11 @@ export var addCreditTender = createAsyncThunk(CheckoutActionType.AddCreditTender
354
354
  }); });
355
355
  export var validatePosOrder = createAsyncThunk(CheckoutActionType.ValidatePosOrder, function (_1, _a) { return __awaiter(void 0, [_1, _a], void 0, function (_, _b) {
356
356
  var _c, config, order, checkout, preparedOrder, check, submitted, validated_1, toRemove, err_8, errors, fields;
357
- var _d;
358
357
  var dispatch = _b.dispatch, getState = _b.getState, rejectWithValue = _b.rejectWithValue;
359
- return __generator(this, function (_e) {
360
- switch (_e.label) {
358
+ return __generator(this, function (_d) {
359
+ switch (_d.label) {
361
360
  case 0:
362
- _e.trys.push([0, 2, , 3]);
361
+ _d.trys.push([0, 2, , 3]);
363
362
  _c = getState(), config = _c.config, order = _c.order, checkout = _c.checkout;
364
363
  preparedOrder = prepareOrder(order, checkout);
365
364
  if (!preparedOrder)
@@ -368,14 +367,16 @@ export var validatePosOrder = createAsyncThunk(CheckoutActionType.ValidatePosOrd
368
367
  // remove any submitted discounts that aren't applied
369
368
  ];
370
369
  case 1:
371
- check = _e.sent();
372
- submitted = (_d = preparedOrder.discounts) === null || _d === void 0 ? void 0 : _d.map(function (i) { return i.id; });
370
+ check = _d.sent();
371
+ submitted = preparedOrder.discounts;
373
372
  validated_1 = check.discounts.map(function (i) { return i.id; });
374
- toRemove = submitted === null || submitted === void 0 ? void 0 : submitted.filter(function (id) { return !validated_1.includes(id); });
375
- toRemove === null || toRemove === void 0 ? void 0 : toRemove.forEach(function (id) { return dispatch(removeDiscount({ id: id })); });
373
+ toRemove = submitted === null || submitted === void 0 ? void 0 : submitted.filter(function (discount) { return !validated_1.includes(discount.id); });
374
+ toRemove === null || toRemove === void 0 ? void 0 : toRemove.forEach(function (discount) {
375
+ return dispatch(removeDiscount({ id: discount.id, index: discount.index }));
376
+ });
376
377
  return [2 /*return*/, check];
377
378
  case 2:
378
- err_8 = _e.sent();
379
+ err_8 = _d.sent();
379
380
  errors = handleRespError(err_8).errors;
380
381
  fields = errors ? Object.keys(errors) : [];
381
382
  if (fields.includes('order_uuid')) {
@@ -526,7 +527,9 @@ var checkoutSlice = createSlice({
526
527
  }
527
528
  else {
528
529
  state.discounts = state.discounts.filter(function (item) {
529
- return item.id !== id && item.index !== discountIndex;
530
+ return item.id !== id &&
531
+ item.index !== undefined &&
532
+ item.index !== discountIndex;
530
533
  });
531
534
  }
532
535
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/store",
3
- "version": "1.1.276",
3
+ "version": "1.1.278",
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",