@open-tender/store 1.1.87 → 1.1.89

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.
@@ -7,7 +7,7 @@ var CartUpsellItem = function (_a) {
7
7
  var item = _a.item, callback = _a.callback, isLast = _a.isLast, children = _a.children;
8
8
  var dispatch = (0, hooks_1.useAppDispatch)();
9
9
  var apiUrl = (0, hooks_1.useAppSelector)(slices_1.selectKioskApi);
10
- var _b = (0, hooks_1.useAppSelector)(slices_1.selectKioskConfig), config = _b.cartUpsellItem, cardConfig = _b.card;
10
+ var config = (0, hooks_1.useAppSelector)(slices_1.selectKioskConfig).cartUpsellItem;
11
11
  var builtItem = (0, utils_1.useBuilder)(item).item;
12
12
  var quantity = builtItem.quantity, groups = builtItem.groups;
13
13
  var groupsBelowMin = (0, utils_1.hasGroupsBelowMin)(null, groups);
@@ -20,6 +20,6 @@ var CartUpsellItem = function (_a) {
20
20
  }
21
21
  };
22
22
  var handlers = { add: add };
23
- return children({ config: config, handlers: handlers, item: item, isLast: isLast, cardConfig: cardConfig, apiUrl: apiUrl });
23
+ return children({ config: config, handlers: handlers, item: item, isLast: isLast, apiUrl: apiUrl });
24
24
  };
25
25
  exports.default = CartUpsellItem;
@@ -7,7 +7,7 @@ var UpsellItem = function (_a) {
7
7
  var item = _a.item, callback = _a.callback, isLast = _a.isLast, children = _a.children;
8
8
  var dispatch = (0, hooks_1.useAppDispatch)();
9
9
  var apiUrl = (0, hooks_1.useAppSelector)(slices_1.selectKioskApi);
10
- var _b = (0, hooks_1.useAppSelector)(slices_1.selectKioskConfig), config = _b.upsellItem, cardConfig = _b.card;
10
+ var config = (0, hooks_1.useAppSelector)(slices_1.selectKioskConfig).upsellItem;
11
11
  var builtItem = (0, utils_1.useBuilder)(item).item;
12
12
  var quantity = builtItem.quantity, groups = builtItem.groups;
13
13
  var groupsBelowMin = (0, utils_1.hasGroupsBelowMin)(null, groups);
@@ -20,6 +20,6 @@ var UpsellItem = function (_a) {
20
20
  }
21
21
  };
22
22
  var handlers = { add: add };
23
- return children({ config: config, handlers: handlers, item: item, isLast: isLast, cardConfig: cardConfig, apiUrl: apiUrl });
23
+ return children({ config: config, handlers: handlers, item: item, isLast: isLast, apiUrl: apiUrl });
24
24
  };
25
25
  exports.default = UpsellItem;
@@ -33,7 +33,78 @@ export declare const selectCustomerAccount: (state: AppState) => Customer | null
33
33
  export declare const selectCustomerDeals: (state: AppState) => Discounts;
34
34
  export declare const selectCustomerFavorites: (state: AppState) => Favorites;
35
35
  export declare const selectCustomerGiftCards: (state: AppState) => GiftCards;
36
- export declare const selectCustomerLoyalty: (state: AppState) => LoyaltyPrograms;
37
36
  export declare const selectCustomerOrders: (state: AppState) => Orders;
38
37
  export declare const selectCustomerRewards: (state: AppState) => Discounts;
38
+ export declare const selectCustomerLoyalty: ((state: {
39
+ alerts: import("@open-tender/types").Alerts;
40
+ arrivals: import("./arrivals").ArrivalsState;
41
+ cartSummary: import("./cartSummary").CartSummaryState;
42
+ checkout: import("./checkout").CheckoutState;
43
+ config: import("./config").ConfigState;
44
+ customer: CustomerState;
45
+ customerIdentify: import("./customerIdentify").CustomerIdentifyState;
46
+ deals: import("./deals").DealsState;
47
+ discounts: import("./discounts").DiscountsState;
48
+ errorAlerts: import("./errorAlerts").ErrorAlertsState;
49
+ kds: import("./kds").KdsState;
50
+ kiosk: import("./kiosk").KioskState;
51
+ menu: import("./menu").MenuState;
52
+ menuPages: import("./menuPages").MenuPagesState;
53
+ modal: import("./modal").ModalState;
54
+ notifications: import("@open-tender/types").Notifications;
55
+ offlineAuths: import("./offlineAuths").OfflineAuthsState;
56
+ order: import("./order").OrderState;
57
+ pos: import("./pos").PosState;
58
+ punches: import("./punches").PunchesState;
59
+ refund: import("./refund").RefundState;
60
+ sendReceipt: import("./sendReceipt").SendReceiptState;
61
+ settings: import("./settings").SettingsState;
62
+ sidebar: import("./sidebar").SidebarState;
63
+ surcharges: import("./surcharges").SurchargesState;
64
+ taxes: import("./taxes").TaxesState;
65
+ }) => {
66
+ name: string;
67
+ credit: `${number}.${number}` | null;
68
+ thresholds: import("@open-tender/types").LoyaltyThresholds;
69
+ progress: `${number}.${number}` | null;
70
+ tier: import("@open-tender/types").LoyaltyTier | undefined;
71
+ } | null) & {
72
+ clearCache: () => void;
73
+ resultsCount: () => number;
74
+ resetResultsCount: () => void;
75
+ } & {
76
+ resultFunc: (resultFuncArgs_0: import("@open-tender/types").LoyaltyProgram) => {
77
+ name: string;
78
+ credit: `${number}.${number}` | null;
79
+ thresholds: import("@open-tender/types").LoyaltyThresholds;
80
+ progress: `${number}.${number}` | null;
81
+ tier: import("@open-tender/types").LoyaltyTier | undefined;
82
+ } | null;
83
+ memoizedResultFunc: ((resultFuncArgs_0: import("@open-tender/types").LoyaltyProgram) => {
84
+ name: string;
85
+ credit: `${number}.${number}` | null;
86
+ thresholds: import("@open-tender/types").LoyaltyThresholds;
87
+ progress: `${number}.${number}` | null;
88
+ tier: import("@open-tender/types").LoyaltyTier | undefined;
89
+ } | null) & {
90
+ clearCache: () => void;
91
+ resultsCount: () => number;
92
+ resetResultsCount: () => void;
93
+ };
94
+ lastResult: () => {
95
+ name: string;
96
+ credit: `${number}.${number}` | null;
97
+ thresholds: import("@open-tender/types").LoyaltyThresholds;
98
+ progress: `${number}.${number}` | null;
99
+ tier: import("@open-tender/types").LoyaltyTier | undefined;
100
+ } | null;
101
+ dependencies: [(state: AppState) => import("@open-tender/types").LoyaltyProgram];
102
+ recomputations: () => number;
103
+ resetRecomputations: () => void;
104
+ dependencyRecomputations: () => number;
105
+ resetDependencyRecomputations: () => void;
106
+ } & {
107
+ argsMemoize: typeof import("reselect").weakMapMemoize;
108
+ memoize: typeof import("reselect").weakMapMemoize;
109
+ };
39
110
  export declare const customerReducer: import("redux").Reducer<CustomerState>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.customerReducer = exports.selectCustomerRewards = exports.selectCustomerOrders = exports.selectCustomerLoyalty = exports.selectCustomerGiftCards = exports.selectCustomerFavorites = exports.selectCustomerDeals = exports.selectCustomerAccount = exports.selectCustomer = exports.resetCustomer = exports.fetchCustomer = exports.CustomerActionType = void 0;
3
+ exports.customerReducer = exports.selectCustomerLoyalty = exports.selectCustomerRewards = exports.selectCustomerOrders = exports.selectCustomerGiftCards = exports.selectCustomerFavorites = exports.selectCustomerDeals = exports.selectCustomerAccount = exports.selectCustomer = exports.resetCustomer = exports.fetchCustomer = exports.CustomerActionType = void 0;
4
4
  var tslib_1 = require("tslib");
5
5
  var toolkit_1 = require("@reduxjs/toolkit");
6
6
  var types_1 = require("./types");
@@ -81,10 +81,20 @@ var selectCustomerGiftCards = function (state) {
81
81
  return state.customer.giftCards;
82
82
  };
83
83
  exports.selectCustomerGiftCards = selectCustomerGiftCards;
84
- var selectCustomerLoyalty = function (state) { return state.customer.loyalty; };
85
- exports.selectCustomerLoyalty = selectCustomerLoyalty;
86
84
  var selectCustomerOrders = function (state) { return state.customer.orders; };
87
85
  exports.selectCustomerOrders = selectCustomerOrders;
88
86
  var selectCustomerRewards = function (state) { return state.customer.rewards; };
89
87
  exports.selectCustomerRewards = selectCustomerRewards;
88
+ exports.selectCustomerLoyalty = (0, toolkit_1.createSelector)(function (state) {
89
+ var loyalty = state.customer.loyalty;
90
+ return loyalty[0] || null;
91
+ }, function (loyaltyProgram) {
92
+ if (!loyaltyProgram)
93
+ return null;
94
+ var name = loyaltyProgram.name, perk = loyaltyProgram.perk, status = loyaltyProgram.status;
95
+ var _a = perk || {}, _b = _a.credit, credit = _b === void 0 ? null : _b, _c = _a.thresholds, thresholds = _c === void 0 ? [] : _c;
96
+ var _d = status || {}, _e = _d.progress, progress = _e === void 0 ? null : _e, _f = _d.tiers, tiers = _f === void 0 ? [] : _f;
97
+ var tier = tiers.find(function (i) { return i.is_current_tier; });
98
+ return { name: name, credit: credit, thresholds: thresholds, progress: progress, tier: tier };
99
+ });
90
100
  exports.customerReducer = CustomerSlice.reducer;
@@ -5,7 +5,7 @@ var CartUpsellItem = function (_a) {
5
5
  var item = _a.item, callback = _a.callback, isLast = _a.isLast, children = _a.children;
6
6
  var dispatch = useAppDispatch();
7
7
  var apiUrl = useAppSelector(selectKioskApi);
8
- var _b = useAppSelector(selectKioskConfig), config = _b.cartUpsellItem, cardConfig = _b.card;
8
+ var config = useAppSelector(selectKioskConfig).cartUpsellItem;
9
9
  var builtItem = useBuilder(item).item;
10
10
  var quantity = builtItem.quantity, groups = builtItem.groups;
11
11
  var groupsBelowMin = hasGroupsBelowMin(null, groups);
@@ -18,6 +18,6 @@ var CartUpsellItem = function (_a) {
18
18
  }
19
19
  };
20
20
  var handlers = { add: add };
21
- return children({ config: config, handlers: handlers, item: item, isLast: isLast, cardConfig: cardConfig, apiUrl: apiUrl });
21
+ return children({ config: config, handlers: handlers, item: item, isLast: isLast, apiUrl: apiUrl });
22
22
  };
23
23
  export default CartUpsellItem;
@@ -5,7 +5,7 @@ var UpsellItem = function (_a) {
5
5
  var item = _a.item, callback = _a.callback, isLast = _a.isLast, children = _a.children;
6
6
  var dispatch = useAppDispatch();
7
7
  var apiUrl = useAppSelector(selectKioskApi);
8
- var _b = useAppSelector(selectKioskConfig), config = _b.upsellItem, cardConfig = _b.card;
8
+ var config = useAppSelector(selectKioskConfig).upsellItem;
9
9
  var builtItem = useBuilder(item).item;
10
10
  var quantity = builtItem.quantity, groups = builtItem.groups;
11
11
  var groupsBelowMin = hasGroupsBelowMin(null, groups);
@@ -18,6 +18,6 @@ var UpsellItem = function (_a) {
18
18
  }
19
19
  };
20
20
  var handlers = { add: add };
21
- return children({ config: config, handlers: handlers, item: item, isLast: isLast, cardConfig: cardConfig, apiUrl: apiUrl });
21
+ return children({ config: config, handlers: handlers, item: item, isLast: isLast, apiUrl: apiUrl });
22
22
  };
23
23
  export default UpsellItem;
@@ -33,7 +33,78 @@ export declare const selectCustomerAccount: (state: AppState) => Customer | null
33
33
  export declare const selectCustomerDeals: (state: AppState) => Discounts;
34
34
  export declare const selectCustomerFavorites: (state: AppState) => Favorites;
35
35
  export declare const selectCustomerGiftCards: (state: AppState) => GiftCards;
36
- export declare const selectCustomerLoyalty: (state: AppState) => LoyaltyPrograms;
37
36
  export declare const selectCustomerOrders: (state: AppState) => Orders;
38
37
  export declare const selectCustomerRewards: (state: AppState) => Discounts;
38
+ export declare const selectCustomerLoyalty: ((state: {
39
+ alerts: import("@open-tender/types").Alerts;
40
+ arrivals: import("./arrivals").ArrivalsState;
41
+ cartSummary: import("./cartSummary").CartSummaryState;
42
+ checkout: import("./checkout").CheckoutState;
43
+ config: import("./config").ConfigState;
44
+ customer: CustomerState;
45
+ customerIdentify: import("./customerIdentify").CustomerIdentifyState;
46
+ deals: import("./deals").DealsState;
47
+ discounts: import("./discounts").DiscountsState;
48
+ errorAlerts: import("./errorAlerts").ErrorAlertsState;
49
+ kds: import("./kds").KdsState;
50
+ kiosk: import("./kiosk").KioskState;
51
+ menu: import("./menu").MenuState;
52
+ menuPages: import("./menuPages").MenuPagesState;
53
+ modal: import("./modal").ModalState;
54
+ notifications: import("@open-tender/types").Notifications;
55
+ offlineAuths: import("./offlineAuths").OfflineAuthsState;
56
+ order: import("./order").OrderState;
57
+ pos: import("./pos").PosState;
58
+ punches: import("./punches").PunchesState;
59
+ refund: import("./refund").RefundState;
60
+ sendReceipt: import("./sendReceipt").SendReceiptState;
61
+ settings: import("./settings").SettingsState;
62
+ sidebar: import("./sidebar").SidebarState;
63
+ surcharges: import("./surcharges").SurchargesState;
64
+ taxes: import("./taxes").TaxesState;
65
+ }) => {
66
+ name: string;
67
+ credit: `${number}.${number}` | null;
68
+ thresholds: import("@open-tender/types").LoyaltyThresholds;
69
+ progress: `${number}.${number}` | null;
70
+ tier: import("@open-tender/types").LoyaltyTier | undefined;
71
+ } | null) & {
72
+ clearCache: () => void;
73
+ resultsCount: () => number;
74
+ resetResultsCount: () => void;
75
+ } & {
76
+ resultFunc: (resultFuncArgs_0: import("@open-tender/types").LoyaltyProgram) => {
77
+ name: string;
78
+ credit: `${number}.${number}` | null;
79
+ thresholds: import("@open-tender/types").LoyaltyThresholds;
80
+ progress: `${number}.${number}` | null;
81
+ tier: import("@open-tender/types").LoyaltyTier | undefined;
82
+ } | null;
83
+ memoizedResultFunc: ((resultFuncArgs_0: import("@open-tender/types").LoyaltyProgram) => {
84
+ name: string;
85
+ credit: `${number}.${number}` | null;
86
+ thresholds: import("@open-tender/types").LoyaltyThresholds;
87
+ progress: `${number}.${number}` | null;
88
+ tier: import("@open-tender/types").LoyaltyTier | undefined;
89
+ } | null) & {
90
+ clearCache: () => void;
91
+ resultsCount: () => number;
92
+ resetResultsCount: () => void;
93
+ };
94
+ lastResult: () => {
95
+ name: string;
96
+ credit: `${number}.${number}` | null;
97
+ thresholds: import("@open-tender/types").LoyaltyThresholds;
98
+ progress: `${number}.${number}` | null;
99
+ tier: import("@open-tender/types").LoyaltyTier | undefined;
100
+ } | null;
101
+ dependencies: [(state: AppState) => import("@open-tender/types").LoyaltyProgram];
102
+ recomputations: () => number;
103
+ resetRecomputations: () => void;
104
+ dependencyRecomputations: () => number;
105
+ resetDependencyRecomputations: () => void;
106
+ } & {
107
+ argsMemoize: typeof import("reselect").weakMapMemoize;
108
+ memoize: typeof import("reselect").weakMapMemoize;
109
+ };
39
110
  export declare const customerReducer: import("redux").Reducer<CustomerState>;
@@ -1,5 +1,5 @@
1
1
  import { __awaiter, __generator } from "tslib";
2
- import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
2
+ import { createAsyncThunk, createSelector, createSlice } from '@reduxjs/toolkit';
3
3
  import { ReducerType } from './types';
4
4
  var initialState = {
5
5
  account: null,
@@ -73,7 +73,18 @@ export var selectCustomerFavorites = function (state) {
73
73
  export var selectCustomerGiftCards = function (state) {
74
74
  return state.customer.giftCards;
75
75
  };
76
- export var selectCustomerLoyalty = function (state) { return state.customer.loyalty; };
77
76
  export var selectCustomerOrders = function (state) { return state.customer.orders; };
78
77
  export var selectCustomerRewards = function (state) { return state.customer.rewards; };
78
+ export var selectCustomerLoyalty = createSelector(function (state) {
79
+ var loyalty = state.customer.loyalty;
80
+ return loyalty[0] || null;
81
+ }, function (loyaltyProgram) {
82
+ if (!loyaltyProgram)
83
+ return null;
84
+ var name = loyaltyProgram.name, perk = loyaltyProgram.perk, status = loyaltyProgram.status;
85
+ var _a = perk || {}, _b = _a.credit, credit = _b === void 0 ? null : _b, _c = _a.thresholds, thresholds = _c === void 0 ? [] : _c;
86
+ var _d = status || {}, _e = _d.progress, progress = _e === void 0 ? null : _e, _f = _d.tiers, tiers = _f === void 0 ? [] : _f;
87
+ var tier = tiers.find(function (i) { return i.is_current_tier; });
88
+ return { name: name, credit: credit, thresholds: thresholds, progress: progress, tier: tier };
89
+ });
79
90
  export var customerReducer = CustomerSlice.reducer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/store",
3
- "version": "1.1.87",
3
+ "version": "1.1.89",
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.59",
65
- "@open-tender/ui": "^0.3.72",
66
- "@open-tender/utils": "^0.4.34",
65
+ "@open-tender/ui": "^0.3.75",
66
+ "@open-tender/utils": "^0.4.39",
67
67
  "@reduxjs/toolkit": "^2.0.1",
68
68
  "date-fns": "2.30.0",
69
69
  "date-fns-tz": "^2.0.0",