@open-tender/store 1.0.16 → 1.0.17

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,6 +1,6 @@
1
1
  import { OrderState } from './order';
2
2
  import { AppState } from '../app';
3
- import { CustomerIdentifier, CustomerIdentify, Money, Order, OrderCreate, OrderCreateDiscounts, OrderCreateGiftCards, OrderCreatePoints, OrderCreateSurcharges, OrderTender, RequestError, RequestStatus, Taxes } from '@open-tender/types';
3
+ import { CustomerIdentifier, CustomerIdentify, Money, Order, OrderCreate, OrderCreateDiscount, OrderCreateDiscounts, OrderCreateGiftCards, OrderCreatePoints, OrderCreateSurcharge, OrderCreateSurcharges, OrderTender, RequestError, RequestStatus, Taxes } from '@open-tender/types';
4
4
  import { Tender } from '../types';
5
5
  export interface CheckoutState {
6
6
  activating: RequestStatus;
@@ -143,7 +143,7 @@ export declare const activateGiftCards: import("@reduxjs/toolkit").AsyncThunk<an
143
143
  fulfilledMeta?: unknown;
144
144
  rejectedMeta?: unknown;
145
145
  }>;
146
- export declare const resetPosCheckout: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheckout">, resetPosCheck: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheck">, handleCheckoutError: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/handleCheckoutError">, addGiftCard: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addGiftCard">, removeGiftCard: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/removeGiftCard">, addSurcharge: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addSurcharge">, removeSurcharge: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/removeSurcharge">, addDiscount: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addDiscount">, removeDiscount: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/removeDiscount">, addTax: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addTax">, removeTax: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/removeTax">, addTip: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addTip">, removeTip: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/removeTip">, setTaxExempt: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setTaxExempt">, addCustomer: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addCustomer">, removeCustomer: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/removeCustomer">, setPendingDiscounts: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setPendingDiscounts">, setPoints: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setPoints">, setMadeFor: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setMadeFor">, setPhone: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setPhone">;
146
+ export declare const resetPosCheckout: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheckout">, resetPosCheck: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheck">, handleCheckoutError: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/handleCheckoutError">, addGiftCard: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addGiftCard">, removeGiftCard: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/removeGiftCard">, addSurcharge: import("@reduxjs/toolkit").ActionCreatorWithPayload<OrderCreateSurcharge, "checkout/addSurcharge">, removeSurcharge: import("@reduxjs/toolkit").ActionCreatorWithPayload<OrderCreateSurcharge, "checkout/removeSurcharge">, addDiscount: import("@reduxjs/toolkit").ActionCreatorWithPayload<OrderCreateDiscount, "checkout/addDiscount">, removeDiscount: import("@reduxjs/toolkit").ActionCreatorWithPayload<OrderCreateDiscount, "checkout/removeDiscount">, addTax: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addTax">, removeTax: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/removeTax">, addTip: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addTip">, removeTip: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/removeTip">, setTaxExempt: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setTaxExempt">, addCustomer: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addCustomer">, removeCustomer: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/removeCustomer">, setPendingDiscounts: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setPendingDiscounts">, setPoints: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setPoints">, setMadeFor: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setMadeFor">, setPhone: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setPhone">;
147
147
  export declare const selectPosCheckout: (state: AppState) => CheckoutState;
148
148
  export declare const selectPosCheck: (state: AppState) => Order | null;
149
149
  export declare const selectPosCustomer: (state: AppState) => CustomerIdentify | null;
@@ -324,7 +324,7 @@ exports.completeChipDNA = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.Com
324
324
  exports.validatePosOrder = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.ValidatePosOrder, function (_, _a) {
325
325
  var dispatch = _a.dispatch, getState = _a.getState, rejectWithValue = _a.rejectWithValue;
326
326
  return tslib_1.__awaiter(void 0, void 0, void 0, function () {
327
- var _b, config, order, checkout, preparedOrder, check, orderDiscountIds, checkDiscountIds_1, toRemove, err_6, errors, fields;
327
+ var _b, config, order, checkout, preparedOrder, check, submitted, validated_1, toRemove, err_6, errors, fields;
328
328
  var _c;
329
329
  return tslib_1.__generator(this, function (_d) {
330
330
  switch (_d.label) {
@@ -339,12 +339,10 @@ exports.validatePosOrder = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.Va
339
339
  ];
340
340
  case 1:
341
341
  check = _d.sent();
342
- orderDiscountIds = (_c = preparedOrder.discounts) === null || _c === void 0 ? void 0 : _c.map(function (i) { return i.id; });
343
- checkDiscountIds_1 = check.discounts.map(function (i) { return i.id; });
344
- toRemove = orderDiscountIds === null || orderDiscountIds === void 0 ? void 0 : orderDiscountIds.filter(function (id) { return !checkDiscountIds_1.includes(id); });
345
- toRemove === null || toRemove === void 0 ? void 0 : toRemove.forEach(function (discountId) {
346
- return dispatch((0, exports.removeDiscount)(discountId));
347
- });
342
+ submitted = (_c = preparedOrder.discounts) === null || _c === void 0 ? void 0 : _c.map(function (i) { return i.id; });
343
+ validated_1 = check.discounts.map(function (i) { return i.id; });
344
+ toRemove = submitted === null || submitted === void 0 ? void 0 : submitted.filter(function (id) { return !validated_1.includes(id); });
345
+ toRemove === null || toRemove === void 0 ? void 0 : toRemove.forEach(function (id) { return dispatch((0, exports.removeDiscount)({ id: id })); });
348
346
  return [2 /*return*/, check];
349
347
  case 2:
350
348
  err_6 = _d.sent();
@@ -482,20 +480,22 @@ var checkoutSlice = (0, toolkit_1.createSlice)({
482
480
  state.surcharges.push(action.payload);
483
481
  },
484
482
  removeSurcharge: function (state, action) {
485
- state.surcharges = state.surcharges.filter(function (i) { return i.id !== action.payload; });
483
+ var id = action.payload.id;
484
+ state.surcharges = state.surcharges.filter(function (i) { return i.id !== id; });
486
485
  },
487
486
  addDiscount: function (state, action) {
488
487
  state.discounts.push(action.payload);
489
488
  },
490
489
  removeDiscount: function (state, action) {
490
+ var id = action.payload.id;
491
491
  var discount = state.check
492
- ? state.check.discounts.find(function (i) { return i.id === action.payload; })
492
+ ? state.check.discounts.find(function (i) { return i.id === id; })
493
493
  : null;
494
494
  if (discount && discount.discount_type === 'LOYALTY') {
495
495
  state.points = [];
496
496
  }
497
497
  else {
498
- state.discounts = state.discounts.filter(function (i) { return i.id !== action.payload; });
498
+ state.discounts = state.discounts.filter(function (i) { return i.id !== id; });
499
499
  }
500
500
  },
501
501
  addTax: function (state, action) {
@@ -1,6 +1,6 @@
1
1
  import { OrderState } from './order';
2
2
  import { AppState } from '../app';
3
- import { CustomerIdentifier, CustomerIdentify, Money, Order, OrderCreate, OrderCreateDiscounts, OrderCreateGiftCards, OrderCreatePoints, OrderCreateSurcharges, OrderTender, RequestError, RequestStatus, Taxes } from '@open-tender/types';
3
+ import { CustomerIdentifier, CustomerIdentify, Money, Order, OrderCreate, OrderCreateDiscount, OrderCreateDiscounts, OrderCreateGiftCards, OrderCreatePoints, OrderCreateSurcharge, OrderCreateSurcharges, OrderTender, RequestError, RequestStatus, Taxes } from '@open-tender/types';
4
4
  import { Tender } from '../types';
5
5
  export interface CheckoutState {
6
6
  activating: RequestStatus;
@@ -143,7 +143,7 @@ export declare const activateGiftCards: import("@reduxjs/toolkit").AsyncThunk<an
143
143
  fulfilledMeta?: unknown;
144
144
  rejectedMeta?: unknown;
145
145
  }>;
146
- export declare const resetPosCheckout: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheckout">, resetPosCheck: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheck">, handleCheckoutError: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/handleCheckoutError">, addGiftCard: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addGiftCard">, removeGiftCard: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/removeGiftCard">, addSurcharge: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addSurcharge">, removeSurcharge: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/removeSurcharge">, addDiscount: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addDiscount">, removeDiscount: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/removeDiscount">, addTax: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addTax">, removeTax: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/removeTax">, addTip: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addTip">, removeTip: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/removeTip">, setTaxExempt: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setTaxExempt">, addCustomer: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addCustomer">, removeCustomer: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/removeCustomer">, setPendingDiscounts: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setPendingDiscounts">, setPoints: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setPoints">, setMadeFor: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setMadeFor">, setPhone: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setPhone">;
146
+ export declare const resetPosCheckout: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheckout">, resetPosCheck: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheck">, handleCheckoutError: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/handleCheckoutError">, addGiftCard: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addGiftCard">, removeGiftCard: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/removeGiftCard">, addSurcharge: import("@reduxjs/toolkit").ActionCreatorWithPayload<OrderCreateSurcharge, "checkout/addSurcharge">, removeSurcharge: import("@reduxjs/toolkit").ActionCreatorWithPayload<OrderCreateSurcharge, "checkout/removeSurcharge">, addDiscount: import("@reduxjs/toolkit").ActionCreatorWithPayload<OrderCreateDiscount, "checkout/addDiscount">, removeDiscount: import("@reduxjs/toolkit").ActionCreatorWithPayload<OrderCreateDiscount, "checkout/removeDiscount">, addTax: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addTax">, removeTax: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/removeTax">, addTip: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addTip">, removeTip: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/removeTip">, setTaxExempt: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setTaxExempt">, addCustomer: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/addCustomer">, removeCustomer: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/removeCustomer">, setPendingDiscounts: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setPendingDiscounts">, setPoints: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setPoints">, setMadeFor: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setMadeFor">, setPhone: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "checkout/setPhone">;
147
147
  export declare const selectPosCheckout: (state: AppState) => CheckoutState;
148
148
  export declare const selectPosCheck: (state: AppState) => Order | null;
149
149
  export declare const selectPosCustomer: (state: AppState) => CustomerIdentify | null;
@@ -320,7 +320,7 @@ export var completeChipDNA = createAsyncThunk(CheckoutActionType.CompleteChipDNA
320
320
  export var validatePosOrder = createAsyncThunk(CheckoutActionType.ValidatePosOrder, function (_, _a) {
321
321
  var dispatch = _a.dispatch, getState = _a.getState, rejectWithValue = _a.rejectWithValue;
322
322
  return __awaiter(void 0, void 0, void 0, function () {
323
- var _b, config, order, checkout, preparedOrder, check, orderDiscountIds, checkDiscountIds_1, toRemove, err_6, errors, fields;
323
+ var _b, config, order, checkout, preparedOrder, check, submitted, validated_1, toRemove, err_6, errors, fields;
324
324
  var _c;
325
325
  return __generator(this, function (_d) {
326
326
  switch (_d.label) {
@@ -335,12 +335,10 @@ export var validatePosOrder = createAsyncThunk(CheckoutActionType.ValidatePosOrd
335
335
  ];
336
336
  case 1:
337
337
  check = _d.sent();
338
- orderDiscountIds = (_c = preparedOrder.discounts) === null || _c === void 0 ? void 0 : _c.map(function (i) { return i.id; });
339
- checkDiscountIds_1 = check.discounts.map(function (i) { return i.id; });
340
- toRemove = orderDiscountIds === null || orderDiscountIds === void 0 ? void 0 : orderDiscountIds.filter(function (id) { return !checkDiscountIds_1.includes(id); });
341
- toRemove === null || toRemove === void 0 ? void 0 : toRemove.forEach(function (discountId) {
342
- return dispatch(removeDiscount(discountId));
343
- });
338
+ submitted = (_c = preparedOrder.discounts) === null || _c === void 0 ? void 0 : _c.map(function (i) { return i.id; });
339
+ validated_1 = check.discounts.map(function (i) { return i.id; });
340
+ toRemove = submitted === null || submitted === void 0 ? void 0 : submitted.filter(function (id) { return !validated_1.includes(id); });
341
+ toRemove === null || toRemove === void 0 ? void 0 : toRemove.forEach(function (id) { return dispatch(removeDiscount({ id: id })); });
344
342
  return [2 /*return*/, check];
345
343
  case 2:
346
344
  err_6 = _d.sent();
@@ -478,20 +476,22 @@ var checkoutSlice = createSlice({
478
476
  state.surcharges.push(action.payload);
479
477
  },
480
478
  removeSurcharge: function (state, action) {
481
- state.surcharges = state.surcharges.filter(function (i) { return i.id !== action.payload; });
479
+ var id = action.payload.id;
480
+ state.surcharges = state.surcharges.filter(function (i) { return i.id !== id; });
482
481
  },
483
482
  addDiscount: function (state, action) {
484
483
  state.discounts.push(action.payload);
485
484
  },
486
485
  removeDiscount: function (state, action) {
486
+ var id = action.payload.id;
487
487
  var discount = state.check
488
- ? state.check.discounts.find(function (i) { return i.id === action.payload; })
488
+ ? state.check.discounts.find(function (i) { return i.id === id; })
489
489
  : null;
490
490
  if (discount && discount.discount_type === 'LOYALTY') {
491
491
  state.points = [];
492
492
  }
493
493
  else {
494
- state.discounts = state.discounts.filter(function (i) { return i.id !== action.payload; });
494
+ state.discounts = state.discounts.filter(function (i) { return i.id !== id; });
495
495
  }
496
496
  },
497
497
  addTax: function (state, action) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/store",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
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",