@open-tender/store 1.1.271 → 1.1.273

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,10 +1,11 @@
1
1
  import { Discount } from '@open-tender/types';
2
2
  import { RewardProps, AppliedProps } from '@open-tender/ui';
3
3
  import React, { ReactNode } from 'react';
4
- declare const Reward: ({ reward, callback, isLast, children, AppliedView }: {
4
+ declare const Reward: ({ reward, isLast, index, callback, children, AppliedView }: {
5
5
  reward: Discount;
6
- callback?: () => void;
7
6
  isLast?: boolean;
7
+ index: number;
8
+ callback?: () => void;
8
9
  children: (props: RewardProps) => ReactNode;
9
10
  AppliedView: (props: AppliedProps) => ReactNode;
10
11
  }) => React.ReactNode;
@@ -6,21 +6,21 @@ 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 reward = _a.reward, callback = _a.callback, isLast = _a.isLast, children = _a.children, AppliedView = _a.AppliedView;
9
+ var reward = _a.reward, isLast = _a.isLast, index = _a.index, callback = _a.callback, children = _a.children, AppliedView = _a.AppliedView;
10
10
  var dispatch = (0, hooks_1.useAppDispatch)();
11
11
  var apiUrl = (0, hooks_1.useAppSelector)(slices_1.selectKioskApi);
12
12
  var _b = (0, hooks_1.useAppSelector)(slices_1.selectKioskConfig), config = _b.reward, cardConfig = _b.card;
13
13
  var check = (0, hooks_1.useAppSelector)(slices_1.selectPosCheckout).check;
14
- var discountIds = check === null || check === void 0 ? void 0 : check.discounts.map(function (i) { return i.id; });
14
+ var discountIdIndexMap = new Map(check === null || check === void 0 ? void 0 : check.discounts.map(function (item, index) { return [item.id, index]; }));
15
15
  var id = reward.discount_id;
16
- var isApplied = !!(discountIds === null || discountIds === void 0 ? void 0 : discountIds.includes(id));
16
+ var isApplied = discountIdIndexMap.get(id) === index;
17
17
  var apply = function () {
18
- dispatch((0, slices_1.addDiscount)({ id: id }));
18
+ dispatch((0, slices_1.addDiscount)({ id: id, index: index }));
19
19
  if (callback)
20
20
  callback();
21
21
  };
22
22
  var remove = function () {
23
- dispatch((0, slices_1.removeDiscount)({ id: id }));
23
+ dispatch((0, slices_1.removeDiscount)({ id: id, index: index }));
24
24
  if (callback)
25
25
  callback();
26
26
  };
@@ -33,6 +33,7 @@ var Reward = function (_a) {
33
33
  handlers: handlers,
34
34
  reward: reward,
35
35
  isApplied: isApplied,
36
+ index: index,
36
37
  isLast: isLast,
37
38
  cardConfig: cardConfig,
38
39
  renderApplied: renderApplied,
@@ -8,7 +8,7 @@ var Reward_1 = tslib_1.__importDefault(require("./Reward"));
8
8
  var Rewards = function (_a) {
9
9
  var title = _a.title, subtitle = _a.subtitle, rewards = _a.rewards, children = _a.children, RewardView = _a.RewardView, AppliedView = _a.AppliedView;
10
10
  var config = (0, hooks_1.useAppSelector)(slices_1.selectKioskConfig).rewards;
11
- var renderReward = (0, react_1.useCallback)(function (reward, isLast) { return (react_1.default.createElement(Reward_1.default, { reward: reward, isLast: isLast, children: RewardView, AppliedView: AppliedView })); }, [RewardView, AppliedView]);
11
+ var renderReward = (0, react_1.useCallback)(function (reward, index, isLast) { return (react_1.default.createElement(Reward_1.default, { reward: reward, index: index, isLast: isLast, children: RewardView, AppliedView: AppliedView })); }, [RewardView, AppliedView]);
12
12
  if (!config)
13
13
  return null;
14
14
  return children({ config: config, title: title, subtitle: subtitle, rewards: rewards, renderReward: renderReward });
@@ -12,6 +12,7 @@ var useResetOrder = function (callback) {
12
12
  dispatch((0, slices_1.resetCustomerIdentify)());
13
13
  dispatch((0, slices_1.resetCustomer)());
14
14
  dispatch((0, slices_1.resetMenu)());
15
+ dispatch((0, slices_1.closeModal)());
15
16
  if (callback)
16
17
  callback();
17
18
  };
@@ -164,7 +164,11 @@ export declare const activateGiftCards: import("@reduxjs/toolkit").AsyncThunk<an
164
164
  fulfilledMeta?: unknown;
165
165
  rejectedMeta?: unknown;
166
166
  }>;
167
- export declare const resetPosCheckout: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheckout">, resetPosCheck: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheck">, resetPosCheckError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheckError">, 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">;
167
+ export declare const resetPosCheckout: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheckout">, resetPosCheck: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheck">, resetPosCheckError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheckError">, 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 & {
168
+ index?: number | undefined;
169
+ }, "checkout/addDiscount">, removeDiscount: import("@reduxjs/toolkit").ActionCreatorWithPayload<OrderCreateDiscount & {
170
+ index?: number | undefined;
171
+ }, "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">;
168
172
  export declare const selectPosCheckout: (state: AppState) => CheckoutState;
169
173
  export declare const selectPosCheck: (state: AppState) => Order | null;
170
174
  export declare const selectPosCustomer: (state: AppState) => CustomerIdentify | null;
@@ -519,14 +519,15 @@ var checkoutSlice = (0, toolkit_1.createSlice)({
519
519
  },
520
520
  removeDiscount: function (state, action) {
521
521
  var id = action.payload.id;
522
+ var discountIndex = action.payload.index;
522
523
  var discount = state.check
523
- ? state.check.discounts.find(function (i) { return i.id === id; })
524
+ ? state.check.discounts.find(function (item, index) { return item.id === id && index === discountIndex; })
524
525
  : null;
525
526
  if (discount && discount.discount_type === 'LOYALTY') {
526
527
  state.points = [];
527
528
  }
528
529
  else {
529
- state.discounts = state.discounts.filter(function (i) { return i.id !== id; });
530
+ state.discounts = state.discounts.filter(function (item, index) { return item.id !== id && index !== discountIndex; });
530
531
  }
531
532
  },
532
533
  addTax: function (state, action) {
@@ -1,10 +1,11 @@
1
1
  import { Discount } from '@open-tender/types';
2
2
  import { RewardProps, AppliedProps } from '@open-tender/ui';
3
3
  import React, { ReactNode } from 'react';
4
- declare const Reward: ({ reward, callback, isLast, children, AppliedView }: {
4
+ declare const Reward: ({ reward, isLast, index, callback, children, AppliedView }: {
5
5
  reward: Discount;
6
- callback?: () => void;
7
6
  isLast?: boolean;
7
+ index: number;
8
+ callback?: () => void;
8
9
  children: (props: RewardProps) => ReactNode;
9
10
  AppliedView: (props: AppliedProps) => ReactNode;
10
11
  }) => React.ReactNode;
@@ -3,21 +3,21 @@ 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 reward = _a.reward, callback = _a.callback, isLast = _a.isLast, children = _a.children, AppliedView = _a.AppliedView;
6
+ var reward = _a.reward, isLast = _a.isLast, index = _a.index, callback = _a.callback, children = _a.children, AppliedView = _a.AppliedView;
7
7
  var dispatch = useAppDispatch();
8
8
  var apiUrl = useAppSelector(selectKioskApi);
9
9
  var _b = useAppSelector(selectKioskConfig), config = _b.reward, cardConfig = _b.card;
10
10
  var check = useAppSelector(selectPosCheckout).check;
11
- var discountIds = check === null || check === void 0 ? void 0 : check.discounts.map(function (i) { return i.id; });
11
+ var discountIdIndexMap = new Map(check === null || check === void 0 ? void 0 : check.discounts.map(function (item, index) { return [item.id, index]; }));
12
12
  var id = reward.discount_id;
13
- var isApplied = !!(discountIds === null || discountIds === void 0 ? void 0 : discountIds.includes(id));
13
+ var isApplied = discountIdIndexMap.get(id) === index;
14
14
  var apply = function () {
15
- dispatch(addDiscount({ id: id }));
15
+ dispatch(addDiscount({ id: id, index: index }));
16
16
  if (callback)
17
17
  callback();
18
18
  };
19
19
  var remove = function () {
20
- dispatch(removeDiscount({ id: id }));
20
+ dispatch(removeDiscount({ id: id, index: index }));
21
21
  if (callback)
22
22
  callback();
23
23
  };
@@ -30,6 +30,7 @@ var Reward = function (_a) {
30
30
  handlers: handlers,
31
31
  reward: reward,
32
32
  isApplied: isApplied,
33
+ index: index,
33
34
  isLast: isLast,
34
35
  cardConfig: cardConfig,
35
36
  renderApplied: renderApplied,
@@ -5,7 +5,7 @@ import { default as RewardContainer } from './Reward';
5
5
  var Rewards = function (_a) {
6
6
  var title = _a.title, subtitle = _a.subtitle, rewards = _a.rewards, children = _a.children, RewardView = _a.RewardView, AppliedView = _a.AppliedView;
7
7
  var config = useAppSelector(selectKioskConfig).rewards;
8
- var renderReward = useCallback(function (reward, isLast) { return (React.createElement(RewardContainer, { reward: reward, isLast: isLast, children: RewardView, AppliedView: AppliedView })); }, [RewardView, AppliedView]);
8
+ var renderReward = useCallback(function (reward, index, isLast) { return (React.createElement(RewardContainer, { reward: reward, index: index, isLast: isLast, children: RewardView, AppliedView: AppliedView })); }, [RewardView, AppliedView]);
9
9
  if (!config)
10
10
  return null;
11
11
  return children({ config: config, title: title, subtitle: subtitle, rewards: rewards, renderReward: renderReward });
@@ -1,5 +1,5 @@
1
1
  import { useAppDispatch } from '../app/hooks';
2
- import { resetCart, resetCustomer, resetCustomerIdentify, resetIdleState, resetMenu, resetPosCheckout, setOrderId } from '../slices';
2
+ import { closeModal, resetCart, resetCustomer, resetCustomerIdentify, resetIdleState, resetMenu, resetPosCheckout, setOrderId } from '../slices';
3
3
  var useResetOrder = function (callback) {
4
4
  var dispatch = useAppDispatch();
5
5
  var resetOrder = function () {
@@ -10,6 +10,7 @@ var useResetOrder = function (callback) {
10
10
  dispatch(resetCustomerIdentify());
11
11
  dispatch(resetCustomer());
12
12
  dispatch(resetMenu());
13
+ dispatch(closeModal());
13
14
  if (callback)
14
15
  callback();
15
16
  };
@@ -164,7 +164,11 @@ export declare const activateGiftCards: import("@reduxjs/toolkit").AsyncThunk<an
164
164
  fulfilledMeta?: unknown;
165
165
  rejectedMeta?: unknown;
166
166
  }>;
167
- export declare const resetPosCheckout: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheckout">, resetPosCheck: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheck">, resetPosCheckError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheckError">, 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">;
167
+ export declare const resetPosCheckout: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheckout">, resetPosCheck: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheck">, resetPosCheckError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"checkout/resetPosCheckError">, 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 & {
168
+ index?: number | undefined;
169
+ }, "checkout/addDiscount">, removeDiscount: import("@reduxjs/toolkit").ActionCreatorWithPayload<OrderCreateDiscount & {
170
+ index?: number | undefined;
171
+ }, "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">;
168
172
  export declare const selectPosCheckout: (state: AppState) => CheckoutState;
169
173
  export declare const selectPosCheck: (state: AppState) => Order | null;
170
174
  export declare const selectPosCustomer: (state: AppState) => CustomerIdentify | null;
@@ -515,14 +515,15 @@ var checkoutSlice = createSlice({
515
515
  },
516
516
  removeDiscount: function (state, action) {
517
517
  var id = action.payload.id;
518
+ var discountIndex = action.payload.index;
518
519
  var discount = state.check
519
- ? state.check.discounts.find(function (i) { return i.id === id; })
520
+ ? state.check.discounts.find(function (item, index) { return item.id === id && index === discountIndex; })
520
521
  : null;
521
522
  if (discount && discount.discount_type === 'LOYALTY') {
522
523
  state.points = [];
523
524
  }
524
525
  else {
525
- state.discounts = state.discounts.filter(function (i) { return i.id !== id; });
526
+ state.discounts = state.discounts.filter(function (item, index) { return item.id !== id && index !== discountIndex; });
526
527
  }
527
528
  },
528
529
  addTax: function (state, action) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/store",
3
- "version": "1.1.271",
3
+ "version": "1.1.273",
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",
@@ -62,8 +62,8 @@
62
62
  "peerDependencies": {
63
63
  "@emotion/react": "^11.11.1",
64
64
  "@open-tender/types": "^0.4.145",
65
- "@open-tender/ui": "^0.4.49",
66
- "@open-tender/utils": "^0.5.30",
65
+ "@open-tender/ui": "^0.4.51",
66
+ "@open-tender/utils": "^0.5.32",
67
67
  "@reduxjs/toolkit": "^2.0.1",
68
68
  "date-fns": "2.30.0",
69
69
  "date-fns-tz": "^2.0.0",