@open-tender/store 1.1.277 → 1.1.279

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.
@@ -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,9 +531,10 @@ 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 &&
534
- item.index !== undefined &&
535
- item.index !== discountIndex;
534
+ return item.id !== id ||
535
+ (item.id === id &&
536
+ item.index !== undefined &&
537
+ item.index !== discountIndex);
536
538
  });
537
539
  }
538
540
  },
@@ -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,9 +527,10 @@ var checkoutSlice = createSlice({
526
527
  }
527
528
  else {
528
529
  state.discounts = state.discounts.filter(function (item) {
529
- return item.id !== id &&
530
- item.index !== undefined &&
531
- item.index !== discountIndex;
530
+ return item.id !== id ||
531
+ (item.id === id &&
532
+ item.index !== undefined &&
533
+ item.index !== discountIndex);
532
534
  });
533
535
  }
534
536
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/store",
3
- "version": "1.1.277",
3
+ "version": "1.1.279",
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",