@open-tender/cloud 0.5.9 → 0.5.11
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.
- package/LICENSE.md +21 -21
- package/README.md +3 -3
- package/dist/cjs/app/hooks.d.ts +67 -67
- package/dist/cjs/app/hooks.js +8 -8
- package/dist/cjs/app/index.d.ts +2 -2
- package/dist/cjs/app/index.js +5 -5
- package/dist/cjs/app/store.d.ts +197 -197
- package/dist/cjs/app/store.js +65 -65
- package/dist/cjs/index.d.ts +5 -5
- package/dist/cjs/index.js +11 -11
- package/dist/cjs/services/api.d.ts +173 -173
- package/dist/cjs/services/api.js +741 -741
- package/dist/cjs/services/errors.d.ts +50 -50
- package/dist/cjs/services/errors.js +53 -53
- package/dist/cjs/services/index.d.ts +3 -3
- package/dist/cjs/services/index.js +7 -7
- package/dist/cjs/slices/alerts.d.ts +5 -5
- package/dist/cjs/slices/alerts.js +29 -29
- package/dist/cjs/slices/allergens.d.ts +101 -101
- package/dist/cjs/slices/allergens.js +83 -83
- package/dist/cjs/slices/announcements.d.ts +180 -180
- package/dist/cjs/slices/announcements.js +81 -81
- package/dist/cjs/slices/checkout.d.ts +69 -69
- package/dist/cjs/slices/checkout.js +326 -326
- package/dist/cjs/slices/completedOrders.d.ts +31 -31
- package/dist/cjs/slices/completedOrders.js +61 -61
- package/dist/cjs/slices/config.d.ts +317 -317
- package/dist/cjs/slices/config.js +195 -195
- package/dist/cjs/slices/confirmation.d.ts +8 -8
- package/dist/cjs/slices/confirmation.js +23 -23
- package/dist/cjs/slices/customer/account.d.ts +128 -128
- package/dist/cjs/slices/customer/account.js +351 -351
- package/dist/cjs/slices/customer/addresses.d.ts +55 -55
- package/dist/cjs/slices/customer/addresses.js +132 -132
- package/dist/cjs/slices/customer/allergens.d.ts +37 -37
- package/dist/cjs/slices/customer/allergens.js +94 -94
- package/dist/cjs/slices/customer/communicationPreferences.d.ts +69 -69
- package/dist/cjs/slices/customer/communicationPreferences.js +164 -164
- package/dist/cjs/slices/customer/creditCards.d.ts +137 -137
- package/dist/cjs/slices/customer/creditCards.js +170 -170
- package/dist/cjs/slices/customer/favorites.d.ts +68 -68
- package/dist/cjs/slices/customer/favorites.js +173 -173
- package/dist/cjs/slices/customer/fcmToken.d.ts +49 -49
- package/dist/cjs/slices/customer/fcmToken.js +110 -110
- package/dist/cjs/slices/customer/giftCards.d.ts +98 -98
- package/dist/cjs/slices/customer/giftCards.js +222 -222
- package/dist/cjs/slices/customer/groupOrders.d.ts +118 -118
- package/dist/cjs/slices/customer/groupOrders.js +262 -262
- package/dist/cjs/slices/customer/history.d.ts +23 -23
- package/dist/cjs/slices/customer/history.js +57 -57
- package/dist/cjs/slices/customer/houseAccounts.d.ts +26 -26
- package/dist/cjs/slices/customer/houseAccounts.js +67 -67
- package/dist/cjs/slices/customer/index.d.ts +42 -42
- package/dist/cjs/slices/customer/index.js +68 -68
- package/dist/cjs/slices/customer/loyalty.d.ts +251 -251
- package/dist/cjs/slices/customer/loyalty.js +110 -110
- package/dist/cjs/slices/customer/order.d.ts +116 -116
- package/dist/cjs/slices/customer/order.js +98 -98
- package/dist/cjs/slices/customer/orders.d.ts +27 -27
- package/dist/cjs/slices/customer/orders.js +69 -69
- package/dist/cjs/slices/customer/pointsShop.d.ts +35 -35
- package/dist/cjs/slices/customer/pointsShop.js +86 -86
- package/dist/cjs/slices/customer/qrCode.d.ts +23 -23
- package/dist/cjs/slices/customer/qrCode.js +57 -57
- package/dist/cjs/slices/customer/rewards.d.ts +26 -26
- package/dist/cjs/slices/customer/rewards.js +67 -67
- package/dist/cjs/slices/customer/thanx.d.ts +23 -23
- package/dist/cjs/slices/customer/thanx.js +56 -56
- package/dist/cjs/slices/customer/tpls.d.ts +238 -238
- package/dist/cjs/slices/customer/tpls.js +102 -102
- package/dist/cjs/slices/customer/tplsPointsShop.d.ts +38 -38
- package/dist/cjs/slices/customer/tplsPointsShop.js +88 -88
- package/dist/cjs/slices/deals.d.ts +25 -25
- package/dist/cjs/slices/deals.js +96 -96
- package/dist/cjs/slices/donations.d.ts +27 -27
- package/dist/cjs/slices/donations.js +57 -57
- package/dist/cjs/slices/geolocation.d.ts +11 -11
- package/dist/cjs/slices/geolocation.js +36 -36
- package/dist/cjs/slices/giftCards.d.ts +27 -27
- package/dist/cjs/slices/giftCards.js +58 -58
- package/dist/cjs/slices/groupOrder.d.ts +418 -418
- package/dist/cjs/slices/groupOrder.js +266 -266
- package/dist/cjs/slices/guest.d.ts +51 -51
- package/dist/cjs/slices/guest.js +91 -91
- package/dist/cjs/slices/index.d.ts +41 -41
- package/dist/cjs/slices/index.js +44 -44
- package/dist/cjs/slices/loader.d.ts +9 -9
- package/dist/cjs/slices/loader.js +25 -25
- package/dist/cjs/slices/menu.d.ts +31 -31
- package/dist/cjs/slices/menu.js +97 -97
- package/dist/cjs/slices/menuDisplay.d.ts +32 -32
- package/dist/cjs/slices/menuDisplay.js +59 -59
- package/dist/cjs/slices/menuItems.d.ts +26 -26
- package/dist/cjs/slices/menuItems.js +57 -57
- package/dist/cjs/slices/misc.d.ts +17 -17
- package/dist/cjs/slices/misc.js +51 -51
- package/dist/cjs/slices/modal.d.ts +5 -5
- package/dist/cjs/slices/modal.js +30 -30
- package/dist/cjs/slices/nav.d.ts +7 -7
- package/dist/cjs/slices/nav.js +23 -23
- package/dist/cjs/slices/navSite.d.ts +7 -7
- package/dist/cjs/slices/navSite.js +23 -23
- package/dist/cjs/slices/notifications.d.ts +5 -5
- package/dist/cjs/slices/notifications.js +27 -27
- package/dist/cjs/slices/oneTimePasscode.d.ts +40 -40
- package/dist/cjs/slices/oneTimePasscode.js +91 -91
- package/dist/cjs/slices/order.d.ts +372 -372
- package/dist/cjs/slices/order.js +528 -528
- package/dist/cjs/slices/orderFulfillment.d.ts +37 -37
- package/dist/cjs/slices/orderFulfillment.js +77 -77
- package/dist/cjs/slices/orderRating.d.ts +52 -52
- package/dist/cjs/slices/orderRating.js +105 -105
- package/dist/cjs/slices/posts.d.ts +24 -24
- package/dist/cjs/slices/posts.js +55 -55
- package/dist/cjs/slices/pushNotifications.d.ts +9 -9
- package/dist/cjs/slices/pushNotifications.js +29 -29
- package/dist/cjs/slices/qr.d.ts +11 -11
- package/dist/cjs/slices/qr.js +34 -34
- package/dist/cjs/slices/quote.d.ts +102 -102
- package/dist/cjs/slices/quote.js +65 -65
- package/dist/cjs/slices/resetPassword.d.ts +41 -41
- package/dist/cjs/slices/resetPassword.js +80 -80
- package/dist/cjs/slices/revenueCenters.d.ts +35 -35
- package/dist/cjs/slices/revenueCenters.js +95 -95
- package/dist/cjs/slices/sidebar.d.ts +7 -7
- package/dist/cjs/slices/sidebar.js +23 -23
- package/dist/cjs/slices/sidebarModal.d.ts +7 -7
- package/dist/cjs/slices/sidebarModal.js +23 -23
- package/dist/cjs/slices/signUp.d.ts +25 -25
- package/dist/cjs/slices/signUp.js +60 -60
- package/dist/cjs/slices/tags.d.ts +101 -101
- package/dist/cjs/slices/tags.js +90 -90
- package/dist/cjs/slices/terms.d.ts +20 -20
- package/dist/cjs/slices/terms.js +51 -51
- package/dist/cjs/slices/types.d.ts +62 -62
- package/dist/cjs/slices/types.js +66 -66
- package/dist/cjs/slices/unsubscribe.d.ts +39 -39
- package/dist/cjs/slices/unsubscribe.js +78 -78
- package/dist/cjs/slices/validTimes.d.ts +23 -23
- package/dist/cjs/slices/validTimes.js +57 -57
- package/dist/cjs/slices/verifyAccount.d.ts +23 -23
- package/dist/cjs/slices/verifyAccount.js +54 -54
- package/dist/esm/app/hooks.d.ts +67 -67
- package/dist/esm/app/hooks.js +4 -4
- package/dist/esm/app/index.d.ts +2 -2
- package/dist/esm/app/index.js +2 -2
- package/dist/esm/app/store.d.ts +197 -197
- package/dist/esm/app/store.js +62 -62
- package/dist/esm/index.d.ts +5 -5
- package/dist/esm/index.js +5 -5
- package/dist/esm/services/api.d.ts +173 -173
- package/dist/esm/services/api.js +739 -739
- package/dist/esm/services/errors.d.ts +50 -50
- package/dist/esm/services/errors.js +50 -50
- package/dist/esm/services/index.d.ts +3 -3
- package/dist/esm/services/index.js +3 -3
- package/dist/esm/slices/alerts.d.ts +5 -5
- package/dist/esm/slices/alerts.js +24 -24
- package/dist/esm/slices/allergens.d.ts +101 -101
- package/dist/esm/slices/allergens.js +77 -77
- package/dist/esm/slices/announcements.d.ts +180 -180
- package/dist/esm/slices/announcements.js +75 -75
- package/dist/esm/slices/checkout.d.ts +69 -69
- package/dist/esm/slices/checkout.js +318 -318
- package/dist/esm/slices/completedOrders.d.ts +31 -31
- package/dist/esm/slices/completedOrders.js +57 -57
- package/dist/esm/slices/config.d.ts +317 -317
- package/dist/esm/slices/config.js +168 -168
- package/dist/esm/slices/confirmation.d.ts +8 -8
- package/dist/esm/slices/confirmation.js +18 -18
- package/dist/esm/slices/customer/account.d.ts +128 -128
- package/dist/esm/slices/customer/account.js +344 -344
- package/dist/esm/slices/customer/addresses.d.ts +55 -55
- package/dist/esm/slices/customer/addresses.js +127 -127
- package/dist/esm/slices/customer/allergens.d.ts +37 -37
- package/dist/esm/slices/customer/allergens.js +89 -89
- package/dist/esm/slices/customer/communicationPreferences.d.ts +69 -69
- package/dist/esm/slices/customer/communicationPreferences.js +159 -159
- package/dist/esm/slices/customer/creditCards.d.ts +137 -137
- package/dist/esm/slices/customer/creditCards.js +165 -165
- package/dist/esm/slices/customer/favorites.d.ts +68 -68
- package/dist/esm/slices/customer/favorites.js +168 -168
- package/dist/esm/slices/customer/fcmToken.d.ts +49 -49
- package/dist/esm/slices/customer/fcmToken.js +106 -106
- package/dist/esm/slices/customer/giftCards.d.ts +98 -98
- package/dist/esm/slices/customer/giftCards.js +217 -217
- package/dist/esm/slices/customer/groupOrders.d.ts +118 -118
- package/dist/esm/slices/customer/groupOrders.js +256 -256
- package/dist/esm/slices/customer/history.d.ts +23 -23
- package/dist/esm/slices/customer/history.js +53 -53
- package/dist/esm/slices/customer/houseAccounts.d.ts +26 -26
- package/dist/esm/slices/customer/houseAccounts.js +62 -62
- package/dist/esm/slices/customer/index.d.ts +42 -42
- package/dist/esm/slices/customer/index.js +64 -64
- package/dist/esm/slices/customer/loyalty.d.ts +251 -251
- package/dist/esm/slices/customer/loyalty.js +102 -102
- package/dist/esm/slices/customer/order.d.ts +116 -116
- package/dist/esm/slices/customer/order.js +94 -94
- package/dist/esm/slices/customer/orders.d.ts +27 -27
- package/dist/esm/slices/customer/orders.js +63 -63
- package/dist/esm/slices/customer/pointsShop.d.ts +35 -35
- package/dist/esm/slices/customer/pointsShop.js +82 -82
- package/dist/esm/slices/customer/qrCode.d.ts +23 -23
- package/dist/esm/slices/customer/qrCode.js +53 -53
- package/dist/esm/slices/customer/rewards.d.ts +26 -26
- package/dist/esm/slices/customer/rewards.js +62 -62
- package/dist/esm/slices/customer/thanx.d.ts +23 -23
- package/dist/esm/slices/customer/thanx.js +52 -52
- package/dist/esm/slices/customer/tpls.d.ts +238 -238
- package/dist/esm/slices/customer/tpls.js +98 -98
- package/dist/esm/slices/customer/tplsPointsShop.d.ts +38 -38
- package/dist/esm/slices/customer/tplsPointsShop.js +84 -84
- package/dist/esm/slices/deals.d.ts +25 -25
- package/dist/esm/slices/deals.js +90 -90
- package/dist/esm/slices/donations.d.ts +27 -27
- package/dist/esm/slices/donations.js +53 -53
- package/dist/esm/slices/geolocation.d.ts +11 -11
- package/dist/esm/slices/geolocation.js +30 -30
- package/dist/esm/slices/giftCards.d.ts +27 -27
- package/dist/esm/slices/giftCards.js +54 -54
- package/dist/esm/slices/groupOrder.d.ts +418 -418
- package/dist/esm/slices/groupOrder.js +259 -259
- package/dist/esm/slices/guest.d.ts +51 -51
- package/dist/esm/slices/guest.js +86 -86
- package/dist/esm/slices/index.d.ts +41 -41
- package/dist/esm/slices/index.js +41 -41
- package/dist/esm/slices/loader.d.ts +9 -9
- package/dist/esm/slices/loader.js +21 -21
- package/dist/esm/slices/menu.d.ts +31 -31
- package/dist/esm/slices/menu.js +90 -90
- package/dist/esm/slices/menuDisplay.d.ts +32 -32
- package/dist/esm/slices/menuDisplay.js +55 -55
- package/dist/esm/slices/menuItems.d.ts +26 -26
- package/dist/esm/slices/menuItems.js +52 -52
- package/dist/esm/slices/misc.d.ts +17 -17
- package/dist/esm/slices/misc.js +41 -41
- package/dist/esm/slices/modal.d.ts +5 -5
- package/dist/esm/slices/modal.js +25 -25
- package/dist/esm/slices/nav.d.ts +7 -7
- package/dist/esm/slices/nav.js +19 -19
- package/dist/esm/slices/navSite.d.ts +7 -7
- package/dist/esm/slices/navSite.js +19 -19
- package/dist/esm/slices/notifications.d.ts +5 -5
- package/dist/esm/slices/notifications.js +22 -22
- package/dist/esm/slices/oneTimePasscode.d.ts +40 -40
- package/dist/esm/slices/oneTimePasscode.js +86 -86
- package/dist/esm/slices/order.d.ts +372 -372
- package/dist/esm/slices/order.js +508 -508
- package/dist/esm/slices/orderFulfillment.d.ts +37 -37
- package/dist/esm/slices/orderFulfillment.js +73 -73
- package/dist/esm/slices/orderRating.d.ts +52 -52
- package/dist/esm/slices/orderRating.js +101 -101
- package/dist/esm/slices/posts.d.ts +24 -24
- package/dist/esm/slices/posts.js +51 -51
- package/dist/esm/slices/pushNotifications.d.ts +9 -9
- package/dist/esm/slices/pushNotifications.js +23 -23
- package/dist/esm/slices/qr.d.ts +11 -11
- package/dist/esm/slices/qr.js +29 -29
- package/dist/esm/slices/quote.d.ts +102 -102
- package/dist/esm/slices/quote.js +61 -61
- package/dist/esm/slices/resetPassword.d.ts +41 -41
- package/dist/esm/slices/resetPassword.js +76 -76
- package/dist/esm/slices/revenueCenters.d.ts +35 -35
- package/dist/esm/slices/revenueCenters.js +89 -89
- package/dist/esm/slices/sidebar.d.ts +7 -7
- package/dist/esm/slices/sidebar.js +19 -19
- package/dist/esm/slices/sidebarModal.d.ts +7 -7
- package/dist/esm/slices/sidebarModal.js +19 -19
- package/dist/esm/slices/signUp.d.ts +25 -25
- package/dist/esm/slices/signUp.js +56 -56
- package/dist/esm/slices/tags.d.ts +101 -101
- package/dist/esm/slices/tags.js +84 -84
- package/dist/esm/slices/terms.d.ts +20 -20
- package/dist/esm/slices/terms.js +47 -47
- package/dist/esm/slices/types.d.ts +62 -62
- package/dist/esm/slices/types.js +63 -63
- package/dist/esm/slices/unsubscribe.d.ts +39 -39
- package/dist/esm/slices/unsubscribe.js +74 -74
- package/dist/esm/slices/validTimes.d.ts +23 -23
- package/dist/esm/slices/validTimes.js +52 -52
- package/dist/esm/slices/verifyAccount.d.ts +23 -23
- package/dist/esm/slices/verifyAccount.js +50 -50
- package/package.json +61 -61
package/dist/cjs/slices/deals.js
CHANGED
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.dealsReducer = exports.selectEligibleDeals = exports.selectDeals = exports.setSelectedDeals = exports.resetDeals = exports.fetchDeals = exports.DealsActionType = void 0;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const toolkit_1 = require("@reduxjs/toolkit");
|
|
7
|
-
const types_1 = require("./types");
|
|
8
|
-
const utils_1 = require("@open-tender/utils");
|
|
9
|
-
const initialState = {
|
|
10
|
-
entities: [],
|
|
11
|
-
selected: null,
|
|
12
|
-
error: null,
|
|
13
|
-
loading: 'idle'
|
|
14
|
-
};
|
|
15
|
-
var DealsActionType;
|
|
16
|
-
(function (DealsActionType) {
|
|
17
|
-
DealsActionType["FetchDeals"] = "deals/fetchDeals";
|
|
18
|
-
})(DealsActionType = exports.DealsActionType || (exports.DealsActionType = {}));
|
|
19
|
-
exports.fetchDeals = (0, toolkit_1.createAsyncThunk)(DealsActionType.FetchDeals, (_, { getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
-
const { api } = getState().config;
|
|
21
|
-
if (!api)
|
|
22
|
-
return;
|
|
23
|
-
try {
|
|
24
|
-
const { profile } = getState().customer.account;
|
|
25
|
-
const { customer_id = null } = profile || {};
|
|
26
|
-
return yield api.getDeals(customer_id);
|
|
27
|
-
}
|
|
28
|
-
catch (err) {
|
|
29
|
-
return rejectWithValue(err);
|
|
30
|
-
}
|
|
31
|
-
}));
|
|
32
|
-
const dealsSlice = (0, toolkit_1.createSlice)({
|
|
33
|
-
name: types_1.ReducerType.Deals,
|
|
34
|
-
initialState,
|
|
35
|
-
reducers: {
|
|
36
|
-
resetDeals: () => initialState,
|
|
37
|
-
setSelectedDeals: (state, action) => {
|
|
38
|
-
state.selected = action.payload;
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
extraReducers: builder => {
|
|
42
|
-
builder
|
|
43
|
-
.addCase(exports.fetchDeals.fulfilled, (state, action) => {
|
|
44
|
-
state.entities = action.payload;
|
|
45
|
-
state.loading = 'idle';
|
|
46
|
-
state.error = null;
|
|
47
|
-
})
|
|
48
|
-
.addCase(exports.fetchDeals.pending, state => {
|
|
49
|
-
state.loading = 'pending';
|
|
50
|
-
})
|
|
51
|
-
.addCase(exports.fetchDeals.rejected, (state, action) => {
|
|
52
|
-
state.error = action.payload;
|
|
53
|
-
state.loading = 'idle';
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
_a = dealsSlice.actions, exports.resetDeals = _a.resetDeals, exports.setSelectedDeals = _a.setSelectedDeals;
|
|
58
|
-
const selectDeals = (state) => state.deals;
|
|
59
|
-
exports.selectDeals = selectDeals;
|
|
60
|
-
const selectEligibleDeals = (state) => {
|
|
61
|
-
const { brand } = state.config || {};
|
|
62
|
-
if (!brand || !brand.has_deals)
|
|
63
|
-
return [];
|
|
64
|
-
let { entities: deals } = state.deals;
|
|
65
|
-
const { orderType, serviceType, revenueCenter } = state.order;
|
|
66
|
-
if (orderType) {
|
|
67
|
-
deals = deals.filter(i => !i.order_type || i.order_type === orderType);
|
|
68
|
-
}
|
|
69
|
-
if (serviceType) {
|
|
70
|
-
deals = deals.filter(i => !i.service_type || i.service_type === serviceType);
|
|
71
|
-
}
|
|
72
|
-
if (revenueCenter) {
|
|
73
|
-
const { revenue_center_id } = revenueCenter;
|
|
74
|
-
deals = deals.filter(i => {
|
|
75
|
-
var _a;
|
|
76
|
-
return !((_a = i.revenue_centers) === null || _a === void 0 ? void 0 : _a.length) ||
|
|
77
|
-
i.revenue_centers
|
|
78
|
-
.map(r => r.revenue_center_id)
|
|
79
|
-
.includes(revenue_center_id);
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
const minutes = (0, utils_1.getMinutesfromDate)(new Date());
|
|
83
|
-
deals = deals.filter(i => {
|
|
84
|
-
if (!i.dayparts.length)
|
|
85
|
-
return true;
|
|
86
|
-
const validDayparts = i.dayparts.filter(d => {
|
|
87
|
-
const start = (0, utils_1.time24ToMinutes)(d.start_time);
|
|
88
|
-
const end = (0, utils_1.time24ToMinutes)(d.end_time);
|
|
89
|
-
return start <= minutes && minutes <= end;
|
|
90
|
-
});
|
|
91
|
-
return validDayparts.length > 0;
|
|
92
|
-
});
|
|
93
|
-
return deals;
|
|
94
|
-
};
|
|
95
|
-
exports.selectEligibleDeals = selectEligibleDeals;
|
|
96
|
-
exports.dealsReducer = dealsSlice.reducer;
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.dealsReducer = exports.selectEligibleDeals = exports.selectDeals = exports.setSelectedDeals = exports.resetDeals = exports.fetchDeals = exports.DealsActionType = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const toolkit_1 = require("@reduxjs/toolkit");
|
|
7
|
+
const types_1 = require("./types");
|
|
8
|
+
const utils_1 = require("@open-tender/utils");
|
|
9
|
+
const initialState = {
|
|
10
|
+
entities: [],
|
|
11
|
+
selected: null,
|
|
12
|
+
error: null,
|
|
13
|
+
loading: 'idle'
|
|
14
|
+
};
|
|
15
|
+
var DealsActionType;
|
|
16
|
+
(function (DealsActionType) {
|
|
17
|
+
DealsActionType["FetchDeals"] = "deals/fetchDeals";
|
|
18
|
+
})(DealsActionType = exports.DealsActionType || (exports.DealsActionType = {}));
|
|
19
|
+
exports.fetchDeals = (0, toolkit_1.createAsyncThunk)(DealsActionType.FetchDeals, (_, { getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
const { api } = getState().config;
|
|
21
|
+
if (!api)
|
|
22
|
+
return;
|
|
23
|
+
try {
|
|
24
|
+
const { profile } = getState().customer.account;
|
|
25
|
+
const { customer_id = null } = profile || {};
|
|
26
|
+
return yield api.getDeals(customer_id);
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
return rejectWithValue(err);
|
|
30
|
+
}
|
|
31
|
+
}));
|
|
32
|
+
const dealsSlice = (0, toolkit_1.createSlice)({
|
|
33
|
+
name: types_1.ReducerType.Deals,
|
|
34
|
+
initialState,
|
|
35
|
+
reducers: {
|
|
36
|
+
resetDeals: () => initialState,
|
|
37
|
+
setSelectedDeals: (state, action) => {
|
|
38
|
+
state.selected = action.payload;
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
extraReducers: builder => {
|
|
42
|
+
builder
|
|
43
|
+
.addCase(exports.fetchDeals.fulfilled, (state, action) => {
|
|
44
|
+
state.entities = action.payload;
|
|
45
|
+
state.loading = 'idle';
|
|
46
|
+
state.error = null;
|
|
47
|
+
})
|
|
48
|
+
.addCase(exports.fetchDeals.pending, state => {
|
|
49
|
+
state.loading = 'pending';
|
|
50
|
+
})
|
|
51
|
+
.addCase(exports.fetchDeals.rejected, (state, action) => {
|
|
52
|
+
state.error = action.payload;
|
|
53
|
+
state.loading = 'idle';
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
_a = dealsSlice.actions, exports.resetDeals = _a.resetDeals, exports.setSelectedDeals = _a.setSelectedDeals;
|
|
58
|
+
const selectDeals = (state) => state.deals;
|
|
59
|
+
exports.selectDeals = selectDeals;
|
|
60
|
+
const selectEligibleDeals = (state) => {
|
|
61
|
+
const { brand } = state.config || {};
|
|
62
|
+
if (!brand || !brand.has_deals)
|
|
63
|
+
return [];
|
|
64
|
+
let { entities: deals } = state.deals;
|
|
65
|
+
const { orderType, serviceType, revenueCenter } = state.order;
|
|
66
|
+
if (orderType) {
|
|
67
|
+
deals = deals.filter(i => !i.order_type || i.order_type === orderType);
|
|
68
|
+
}
|
|
69
|
+
if (serviceType) {
|
|
70
|
+
deals = deals.filter(i => !i.service_type || i.service_type === serviceType);
|
|
71
|
+
}
|
|
72
|
+
if (revenueCenter) {
|
|
73
|
+
const { revenue_center_id } = revenueCenter;
|
|
74
|
+
deals = deals.filter(i => {
|
|
75
|
+
var _a;
|
|
76
|
+
return !((_a = i.revenue_centers) === null || _a === void 0 ? void 0 : _a.length) ||
|
|
77
|
+
i.revenue_centers
|
|
78
|
+
.map(r => r.revenue_center_id)
|
|
79
|
+
.includes(revenue_center_id);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
const minutes = (0, utils_1.getMinutesfromDate)(new Date());
|
|
83
|
+
deals = deals.filter(i => {
|
|
84
|
+
if (!i.dayparts.length)
|
|
85
|
+
return true;
|
|
86
|
+
const validDayparts = i.dayparts.filter(d => {
|
|
87
|
+
const start = (0, utils_1.time24ToMinutes)(d.start_time);
|
|
88
|
+
const end = (0, utils_1.time24ToMinutes)(d.end_time);
|
|
89
|
+
return start <= minutes && minutes <= end;
|
|
90
|
+
});
|
|
91
|
+
return validDayparts.length > 0;
|
|
92
|
+
});
|
|
93
|
+
return deals;
|
|
94
|
+
};
|
|
95
|
+
exports.selectEligibleDeals = selectEligibleDeals;
|
|
96
|
+
exports.dealsReducer = dealsSlice.reducer;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { AppState } from '../app';
|
|
2
|
-
import { Donation, DonationPurchase, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
-
export interface DonationState {
|
|
4
|
-
donation: Donation | null;
|
|
5
|
-
error: RequestError | Record<string, any>;
|
|
6
|
-
loading: RequestStatus;
|
|
7
|
-
success: boolean;
|
|
8
|
-
}
|
|
9
|
-
export declare enum DonationActionType {
|
|
10
|
-
PurchaseDonation = "donations/purchaseDonation"
|
|
11
|
-
}
|
|
12
|
-
export declare const purchaseDonation: import("@reduxjs/toolkit").AsyncThunk<Donation, {
|
|
13
|
-
data: DonationPurchase;
|
|
14
|
-
callback?: (() => void) | undefined;
|
|
15
|
-
}, {
|
|
16
|
-
state: AppState;
|
|
17
|
-
rejectValue: RequestError;
|
|
18
|
-
dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
|
|
19
|
-
extra?: unknown;
|
|
20
|
-
serializedErrorType?: unknown;
|
|
21
|
-
pendingMeta?: unknown;
|
|
22
|
-
fulfilledMeta?: unknown;
|
|
23
|
-
rejectedMeta?: unknown;
|
|
24
|
-
}>;
|
|
25
|
-
export declare const resetDonation: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"donations/resetDonation">;
|
|
26
|
-
export declare const selectDonation: (state: AppState) => DonationState;
|
|
27
|
-
export declare const donationsReducer: import("redux").Reducer<DonationState, import("redux").AnyAction>;
|
|
1
|
+
import { AppState } from '../app';
|
|
2
|
+
import { Donation, DonationPurchase, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
+
export interface DonationState {
|
|
4
|
+
donation: Donation | null;
|
|
5
|
+
error: RequestError | Record<string, any>;
|
|
6
|
+
loading: RequestStatus;
|
|
7
|
+
success: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare enum DonationActionType {
|
|
10
|
+
PurchaseDonation = "donations/purchaseDonation"
|
|
11
|
+
}
|
|
12
|
+
export declare const purchaseDonation: import("@reduxjs/toolkit").AsyncThunk<Donation, {
|
|
13
|
+
data: DonationPurchase;
|
|
14
|
+
callback?: (() => void) | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
state: AppState;
|
|
17
|
+
rejectValue: RequestError;
|
|
18
|
+
dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
|
|
19
|
+
extra?: unknown;
|
|
20
|
+
serializedErrorType?: unknown;
|
|
21
|
+
pendingMeta?: unknown;
|
|
22
|
+
fulfilledMeta?: unknown;
|
|
23
|
+
rejectedMeta?: unknown;
|
|
24
|
+
}>;
|
|
25
|
+
export declare const resetDonation: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"donations/resetDonation">;
|
|
26
|
+
export declare const selectDonation: (state: AppState) => DonationState;
|
|
27
|
+
export declare const donationsReducer: import("redux").Reducer<DonationState, import("redux").AnyAction>;
|
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.donationsReducer = exports.selectDonation = exports.resetDonation = exports.purchaseDonation = exports.DonationActionType = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
-
const types_1 = require("./types");
|
|
7
|
-
const initialState = {
|
|
8
|
-
donation: null,
|
|
9
|
-
success: false,
|
|
10
|
-
error: null,
|
|
11
|
-
loading: 'idle'
|
|
12
|
-
};
|
|
13
|
-
var DonationActionType;
|
|
14
|
-
(function (DonationActionType) {
|
|
15
|
-
DonationActionType["PurchaseDonation"] = "donations/purchaseDonation";
|
|
16
|
-
})(DonationActionType = exports.DonationActionType || (exports.DonationActionType = {}));
|
|
17
|
-
exports.purchaseDonation = (0, toolkit_1.createAsyncThunk)(DonationActionType.PurchaseDonation, (requestData, { getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
-
const { api } = getState().config;
|
|
19
|
-
if (!api)
|
|
20
|
-
return;
|
|
21
|
-
try {
|
|
22
|
-
const donation = yield api.postPurchaseDonation(requestData.data);
|
|
23
|
-
if (requestData.callback)
|
|
24
|
-
requestData.callback();
|
|
25
|
-
return donation;
|
|
26
|
-
}
|
|
27
|
-
catch (err) {
|
|
28
|
-
return rejectWithValue(err);
|
|
29
|
-
}
|
|
30
|
-
}));
|
|
31
|
-
const donationsSlice = (0, toolkit_1.createSlice)({
|
|
32
|
-
name: types_1.ReducerType.Donations,
|
|
33
|
-
initialState,
|
|
34
|
-
reducers: {
|
|
35
|
-
resetDonation: () => initialState
|
|
36
|
-
},
|
|
37
|
-
extraReducers: builder => {
|
|
38
|
-
builder
|
|
39
|
-
.addCase(exports.purchaseDonation.fulfilled, (state, action) => {
|
|
40
|
-
state.donation = action.payload;
|
|
41
|
-
state.success = true;
|
|
42
|
-
state.loading = 'idle';
|
|
43
|
-
state.error = null;
|
|
44
|
-
})
|
|
45
|
-
.addCase(exports.purchaseDonation.pending, state => {
|
|
46
|
-
state.loading = 'pending';
|
|
47
|
-
})
|
|
48
|
-
.addCase(exports.purchaseDonation.rejected, (state, action) => {
|
|
49
|
-
state.error = action.payload;
|
|
50
|
-
state.loading = 'idle';
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
exports.resetDonation = donationsSlice.actions.resetDonation;
|
|
55
|
-
const selectDonation = (state) => state.donations;
|
|
56
|
-
exports.selectDonation = selectDonation;
|
|
57
|
-
exports.donationsReducer = donationsSlice.reducer;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.donationsReducer = exports.selectDonation = exports.resetDonation = exports.purchaseDonation = exports.DonationActionType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
+
const types_1 = require("./types");
|
|
7
|
+
const initialState = {
|
|
8
|
+
donation: null,
|
|
9
|
+
success: false,
|
|
10
|
+
error: null,
|
|
11
|
+
loading: 'idle'
|
|
12
|
+
};
|
|
13
|
+
var DonationActionType;
|
|
14
|
+
(function (DonationActionType) {
|
|
15
|
+
DonationActionType["PurchaseDonation"] = "donations/purchaseDonation";
|
|
16
|
+
})(DonationActionType = exports.DonationActionType || (exports.DonationActionType = {}));
|
|
17
|
+
exports.purchaseDonation = (0, toolkit_1.createAsyncThunk)(DonationActionType.PurchaseDonation, (requestData, { getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
const { api } = getState().config;
|
|
19
|
+
if (!api)
|
|
20
|
+
return;
|
|
21
|
+
try {
|
|
22
|
+
const donation = yield api.postPurchaseDonation(requestData.data);
|
|
23
|
+
if (requestData.callback)
|
|
24
|
+
requestData.callback();
|
|
25
|
+
return donation;
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
return rejectWithValue(err);
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
31
|
+
const donationsSlice = (0, toolkit_1.createSlice)({
|
|
32
|
+
name: types_1.ReducerType.Donations,
|
|
33
|
+
initialState,
|
|
34
|
+
reducers: {
|
|
35
|
+
resetDonation: () => initialState
|
|
36
|
+
},
|
|
37
|
+
extraReducers: builder => {
|
|
38
|
+
builder
|
|
39
|
+
.addCase(exports.purchaseDonation.fulfilled, (state, action) => {
|
|
40
|
+
state.donation = action.payload;
|
|
41
|
+
state.success = true;
|
|
42
|
+
state.loading = 'idle';
|
|
43
|
+
state.error = null;
|
|
44
|
+
})
|
|
45
|
+
.addCase(exports.purchaseDonation.pending, state => {
|
|
46
|
+
state.loading = 'pending';
|
|
47
|
+
})
|
|
48
|
+
.addCase(exports.purchaseDonation.rejected, (state, action) => {
|
|
49
|
+
state.error = action.payload;
|
|
50
|
+
state.loading = 'idle';
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
exports.resetDonation = donationsSlice.actions.resetDonation;
|
|
55
|
+
const selectDonation = (state) => state.donations;
|
|
56
|
+
exports.selectDonation = selectDonation;
|
|
57
|
+
exports.donationsReducer = donationsSlice.reducer;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { LatLng, RequestError } from '@open-tender/types';
|
|
2
|
-
import { AppState } from '../app';
|
|
3
|
-
export interface GeoLocationState {
|
|
4
|
-
latLng: LatLng | null;
|
|
5
|
-
error: RequestError;
|
|
6
|
-
loading: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare const resetGeolocation: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"geolocation/resetGeolocation">, setGeoLatLng: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "geolocation/setGeoLatLng">, setGeoError: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "geolocation/setGeoError">, setGeoLoading: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"geolocation/setGeoLoading">;
|
|
9
|
-
export declare const selectGeo: (state: AppState) => GeoLocationState;
|
|
10
|
-
export declare const selectGeoLatLng: (state: AppState) => LatLng | null;
|
|
11
|
-
export declare const geolocationReducer: import("redux").Reducer<GeoLocationState, import("redux").AnyAction>;
|
|
1
|
+
import { LatLng, RequestError } from '@open-tender/types';
|
|
2
|
+
import { AppState } from '../app';
|
|
3
|
+
export interface GeoLocationState {
|
|
4
|
+
latLng: LatLng | null;
|
|
5
|
+
error: RequestError;
|
|
6
|
+
loading: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const resetGeolocation: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"geolocation/resetGeolocation">, setGeoLatLng: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "geolocation/setGeoLatLng">, setGeoError: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "geolocation/setGeoError">, setGeoLoading: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"geolocation/setGeoLoading">;
|
|
9
|
+
export declare const selectGeo: (state: AppState) => GeoLocationState;
|
|
10
|
+
export declare const selectGeoLatLng: (state: AppState) => LatLng | null;
|
|
11
|
+
export declare const geolocationReducer: import("redux").Reducer<GeoLocationState, import("redux").AnyAction>;
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var _a;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.geolocationReducer = exports.selectGeoLatLng = exports.selectGeo = exports.setGeoLoading = exports.setGeoError = exports.setGeoLatLng = exports.resetGeolocation = void 0;
|
|
5
|
-
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
-
const initialState = {
|
|
7
|
-
latLng: null,
|
|
8
|
-
error: null,
|
|
9
|
-
loading: false
|
|
10
|
-
};
|
|
11
|
-
const geolocationSlice = (0, toolkit_1.createSlice)({
|
|
12
|
-
name: 'geolocation',
|
|
13
|
-
initialState,
|
|
14
|
-
reducers: {
|
|
15
|
-
resetGeolocation: () => initialState,
|
|
16
|
-
setGeoLatLng: (state, action) => {
|
|
17
|
-
state.latLng = action.payload;
|
|
18
|
-
state.error = null;
|
|
19
|
-
state.loading = false;
|
|
20
|
-
},
|
|
21
|
-
setGeoError: (state, action) => {
|
|
22
|
-
state.latLng = null;
|
|
23
|
-
state.error = action.payload;
|
|
24
|
-
state.loading = false;
|
|
25
|
-
},
|
|
26
|
-
setGeoLoading: state => {
|
|
27
|
-
state.loading = true;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
_a = geolocationSlice.actions, exports.resetGeolocation = _a.resetGeolocation, exports.setGeoLatLng = _a.setGeoLatLng, exports.setGeoError = _a.setGeoError, exports.setGeoLoading = _a.setGeoLoading;
|
|
32
|
-
const selectGeo = (state) => state.geolocation;
|
|
33
|
-
exports.selectGeo = selectGeo;
|
|
34
|
-
const selectGeoLatLng = (state) => state.geolocation.latLng;
|
|
35
|
-
exports.selectGeoLatLng = selectGeoLatLng;
|
|
36
|
-
exports.geolocationReducer = geolocationSlice.reducer;
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.geolocationReducer = exports.selectGeoLatLng = exports.selectGeo = exports.setGeoLoading = exports.setGeoError = exports.setGeoLatLng = exports.resetGeolocation = void 0;
|
|
5
|
+
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
+
const initialState = {
|
|
7
|
+
latLng: null,
|
|
8
|
+
error: null,
|
|
9
|
+
loading: false
|
|
10
|
+
};
|
|
11
|
+
const geolocationSlice = (0, toolkit_1.createSlice)({
|
|
12
|
+
name: 'geolocation',
|
|
13
|
+
initialState,
|
|
14
|
+
reducers: {
|
|
15
|
+
resetGeolocation: () => initialState,
|
|
16
|
+
setGeoLatLng: (state, action) => {
|
|
17
|
+
state.latLng = action.payload;
|
|
18
|
+
state.error = null;
|
|
19
|
+
state.loading = false;
|
|
20
|
+
},
|
|
21
|
+
setGeoError: (state, action) => {
|
|
22
|
+
state.latLng = null;
|
|
23
|
+
state.error = action.payload;
|
|
24
|
+
state.loading = false;
|
|
25
|
+
},
|
|
26
|
+
setGeoLoading: state => {
|
|
27
|
+
state.loading = true;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
_a = geolocationSlice.actions, exports.resetGeolocation = _a.resetGeolocation, exports.setGeoLatLng = _a.setGeoLatLng, exports.setGeoError = _a.setGeoError, exports.setGeoLoading = _a.setGeoLoading;
|
|
32
|
+
const selectGeo = (state) => state.geolocation;
|
|
33
|
+
exports.selectGeo = selectGeo;
|
|
34
|
+
const selectGeoLatLng = (state) => state.geolocation.latLng;
|
|
35
|
+
exports.selectGeoLatLng = selectGeoLatLng;
|
|
36
|
+
exports.geolocationReducer = geolocationSlice.reducer;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { AppState } from '../app';
|
|
2
|
-
import { GiftCardsPurchase, GiftCardsPurchased, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
-
export interface GiftCardsState {
|
|
4
|
-
loading: RequestStatus;
|
|
5
|
-
error: RequestError;
|
|
6
|
-
success: boolean;
|
|
7
|
-
giftCards: GiftCardsPurchased;
|
|
8
|
-
}
|
|
9
|
-
export declare enum GiftCardsActionType {
|
|
10
|
-
PurchaseGiftCards = "giftCards/purchaseGiftCards"
|
|
11
|
-
}
|
|
12
|
-
export declare const purchaseGiftCards: import("@reduxjs/toolkit").AsyncThunk<GiftCardsPurchased, {
|
|
13
|
-
data: GiftCardsPurchase;
|
|
14
|
-
callback?: (() => void) | undefined;
|
|
15
|
-
}, {
|
|
16
|
-
state: AppState;
|
|
17
|
-
rejectValue: RequestError;
|
|
18
|
-
dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
|
|
19
|
-
extra?: unknown;
|
|
20
|
-
serializedErrorType?: unknown;
|
|
21
|
-
pendingMeta?: unknown;
|
|
22
|
-
fulfilledMeta?: unknown;
|
|
23
|
-
rejectedMeta?: unknown;
|
|
24
|
-
}>;
|
|
25
|
-
export declare const resetGiftCards: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"giftCards/resetGiftCards">;
|
|
26
|
-
export declare const selectGiftCards: (state: AppState) => GiftCardsState;
|
|
27
|
-
export declare const giftCardsReducer: import("redux").Reducer<GiftCardsState, import("redux").AnyAction>;
|
|
1
|
+
import { AppState } from '../app';
|
|
2
|
+
import { GiftCardsPurchase, GiftCardsPurchased, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
+
export interface GiftCardsState {
|
|
4
|
+
loading: RequestStatus;
|
|
5
|
+
error: RequestError;
|
|
6
|
+
success: boolean;
|
|
7
|
+
giftCards: GiftCardsPurchased;
|
|
8
|
+
}
|
|
9
|
+
export declare enum GiftCardsActionType {
|
|
10
|
+
PurchaseGiftCards = "giftCards/purchaseGiftCards"
|
|
11
|
+
}
|
|
12
|
+
export declare const purchaseGiftCards: import("@reduxjs/toolkit").AsyncThunk<GiftCardsPurchased, {
|
|
13
|
+
data: GiftCardsPurchase;
|
|
14
|
+
callback?: (() => void) | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
state: AppState;
|
|
17
|
+
rejectValue: RequestError;
|
|
18
|
+
dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
|
|
19
|
+
extra?: unknown;
|
|
20
|
+
serializedErrorType?: unknown;
|
|
21
|
+
pendingMeta?: unknown;
|
|
22
|
+
fulfilledMeta?: unknown;
|
|
23
|
+
rejectedMeta?: unknown;
|
|
24
|
+
}>;
|
|
25
|
+
export declare const resetGiftCards: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"giftCards/resetGiftCards">;
|
|
26
|
+
export declare const selectGiftCards: (state: AppState) => GiftCardsState;
|
|
27
|
+
export declare const giftCardsReducer: import("redux").Reducer<GiftCardsState, import("redux").AnyAction>;
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.giftCardsReducer = exports.selectGiftCards = exports.resetGiftCards = exports.purchaseGiftCards = exports.GiftCardsActionType = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
-
const types_1 = require("./types");
|
|
7
|
-
const initialState = {
|
|
8
|
-
loading: 'idle',
|
|
9
|
-
error: null,
|
|
10
|
-
success: false,
|
|
11
|
-
giftCards: []
|
|
12
|
-
};
|
|
13
|
-
var GiftCardsActionType;
|
|
14
|
-
(function (GiftCardsActionType) {
|
|
15
|
-
GiftCardsActionType["PurchaseGiftCards"] = "giftCards/purchaseGiftCards";
|
|
16
|
-
})(GiftCardsActionType = exports.GiftCardsActionType || (exports.GiftCardsActionType = {}));
|
|
17
|
-
exports.purchaseGiftCards = (0, toolkit_1.createAsyncThunk)(GiftCardsActionType.PurchaseGiftCards, ({ data, callback }, { getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
-
const { api } = getState().config;
|
|
19
|
-
if (!api)
|
|
20
|
-
return;
|
|
21
|
-
try {
|
|
22
|
-
const giftCards = yield api.postPurchaseGiftCards(data);
|
|
23
|
-
if (callback)
|
|
24
|
-
callback();
|
|
25
|
-
return giftCards;
|
|
26
|
-
}
|
|
27
|
-
catch (err) {
|
|
28
|
-
return rejectWithValue(err);
|
|
29
|
-
}
|
|
30
|
-
}));
|
|
31
|
-
const giftCardsSlice = (0, toolkit_1.createSlice)({
|
|
32
|
-
name: types_1.ReducerType.GiftCards,
|
|
33
|
-
initialState,
|
|
34
|
-
reducers: {
|
|
35
|
-
resetGiftCards: () => initialState
|
|
36
|
-
},
|
|
37
|
-
extraReducers: builder => {
|
|
38
|
-
builder
|
|
39
|
-
.addCase(exports.purchaseGiftCards.fulfilled, (state, action) => {
|
|
40
|
-
state.success = true;
|
|
41
|
-
state.giftCards = action.payload;
|
|
42
|
-
state.loading = 'idle';
|
|
43
|
-
state.error = null;
|
|
44
|
-
})
|
|
45
|
-
.addCase(exports.purchaseGiftCards.pending, state => {
|
|
46
|
-
state.loading = 'pending';
|
|
47
|
-
})
|
|
48
|
-
.addCase(exports.purchaseGiftCards.rejected, (state, action) => {
|
|
49
|
-
state.loading = 'idle';
|
|
50
|
-
state.success = false;
|
|
51
|
-
state.error = action.payload;
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
exports.resetGiftCards = giftCardsSlice.actions.resetGiftCards;
|
|
56
|
-
const selectGiftCards = (state) => state.giftCards;
|
|
57
|
-
exports.selectGiftCards = selectGiftCards;
|
|
58
|
-
exports.giftCardsReducer = giftCardsSlice.reducer;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.giftCardsReducer = exports.selectGiftCards = exports.resetGiftCards = exports.purchaseGiftCards = exports.GiftCardsActionType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
+
const types_1 = require("./types");
|
|
7
|
+
const initialState = {
|
|
8
|
+
loading: 'idle',
|
|
9
|
+
error: null,
|
|
10
|
+
success: false,
|
|
11
|
+
giftCards: []
|
|
12
|
+
};
|
|
13
|
+
var GiftCardsActionType;
|
|
14
|
+
(function (GiftCardsActionType) {
|
|
15
|
+
GiftCardsActionType["PurchaseGiftCards"] = "giftCards/purchaseGiftCards";
|
|
16
|
+
})(GiftCardsActionType = exports.GiftCardsActionType || (exports.GiftCardsActionType = {}));
|
|
17
|
+
exports.purchaseGiftCards = (0, toolkit_1.createAsyncThunk)(GiftCardsActionType.PurchaseGiftCards, ({ data, callback }, { getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
const { api } = getState().config;
|
|
19
|
+
if (!api)
|
|
20
|
+
return;
|
|
21
|
+
try {
|
|
22
|
+
const giftCards = yield api.postPurchaseGiftCards(data);
|
|
23
|
+
if (callback)
|
|
24
|
+
callback();
|
|
25
|
+
return giftCards;
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
return rejectWithValue(err);
|
|
29
|
+
}
|
|
30
|
+
}));
|
|
31
|
+
const giftCardsSlice = (0, toolkit_1.createSlice)({
|
|
32
|
+
name: types_1.ReducerType.GiftCards,
|
|
33
|
+
initialState,
|
|
34
|
+
reducers: {
|
|
35
|
+
resetGiftCards: () => initialState
|
|
36
|
+
},
|
|
37
|
+
extraReducers: builder => {
|
|
38
|
+
builder
|
|
39
|
+
.addCase(exports.purchaseGiftCards.fulfilled, (state, action) => {
|
|
40
|
+
state.success = true;
|
|
41
|
+
state.giftCards = action.payload;
|
|
42
|
+
state.loading = 'idle';
|
|
43
|
+
state.error = null;
|
|
44
|
+
})
|
|
45
|
+
.addCase(exports.purchaseGiftCards.pending, state => {
|
|
46
|
+
state.loading = 'pending';
|
|
47
|
+
})
|
|
48
|
+
.addCase(exports.purchaseGiftCards.rejected, (state, action) => {
|
|
49
|
+
state.loading = 'idle';
|
|
50
|
+
state.success = false;
|
|
51
|
+
state.error = action.payload;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
exports.resetGiftCards = giftCardsSlice.actions.resetGiftCards;
|
|
56
|
+
const selectGiftCards = (state) => state.giftCards;
|
|
57
|
+
exports.selectGiftCards = selectGiftCards;
|
|
58
|
+
exports.giftCardsReducer = giftCardsSlice.reducer;
|