@open-tender/cloud 0.0.1
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 -0
- package/README.md +3 -0
- package/dist/cjs/app/hooks.d.ts +50 -0
- package/dist/cjs/app/hooks.js +8 -0
- package/dist/cjs/app/index.d.ts +1 -0
- package/dist/cjs/app/index.js +4 -0
- package/dist/cjs/app/store.d.ts +146 -0
- package/dist/cjs/app/store.js +51 -0
- package/dist/cjs/index.d.ts +3 -0
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/services/api.d.ts +162 -0
- package/dist/cjs/services/api.js +691 -0
- package/dist/cjs/services/errors.d.ts +50 -0
- package/dist/cjs/services/errors.js +53 -0
- package/dist/cjs/services/index.d.ts +2 -0
- package/dist/cjs/services/index.js +6 -0
- package/dist/cjs/slices/alerts.d.ts +5 -0
- package/dist/cjs/slices/alerts.js +28 -0
- package/dist/cjs/slices/allergens.d.ts +19 -0
- package/dist/cjs/slices/allergens.js +66 -0
- package/dist/cjs/slices/announcements.d.ts +28 -0
- package/dist/cjs/slices/announcements.js +77 -0
- package/dist/cjs/slices/checkout.d.ts +38 -0
- package/dist/cjs/slices/checkout.js +276 -0
- package/dist/cjs/slices/completedOrders.d.ts +25 -0
- package/dist/cjs/slices/completedOrders.js +61 -0
- package/dist/cjs/slices/config.d.ts +87 -0
- package/dist/cjs/slices/config.js +121 -0
- package/dist/cjs/slices/confirmation.d.ts +8 -0
- package/dist/cjs/slices/confirmation.js +22 -0
- package/dist/cjs/slices/customer/account.d.ts +59 -0
- package/dist/cjs/slices/customer/account.js +288 -0
- package/dist/cjs/slices/customer/addresses.d.ts +37 -0
- package/dist/cjs/slices/customer/addresses.js +134 -0
- package/dist/cjs/slices/customer/allergens.d.ts +25 -0
- package/dist/cjs/slices/customer/allergens.js +94 -0
- package/dist/cjs/slices/customer/communicationPreferences.d.ts +44 -0
- package/dist/cjs/slices/customer/communicationPreferences.js +165 -0
- package/dist/cjs/slices/customer/creditCards.d.ts +46 -0
- package/dist/cjs/slices/customer/creditCards.js +172 -0
- package/dist/cjs/slices/customer/favorites.d.ts +45 -0
- package/dist/cjs/slices/customer/favorites.js +176 -0
- package/dist/cjs/slices/customer/fcmToken.d.ts +31 -0
- package/dist/cjs/slices/customer/fcmToken.js +110 -0
- package/dist/cjs/slices/customer/giftCards.d.ts +62 -0
- package/dist/cjs/slices/customer/giftCards.js +196 -0
- package/dist/cjs/slices/customer/groupOrders.d.ts +33 -0
- package/dist/cjs/slices/customer/groupOrders.js +148 -0
- package/dist/cjs/slices/customer/houseAccounts.d.ts +20 -0
- package/dist/cjs/slices/customer/houseAccounts.js +67 -0
- package/dist/cjs/slices/customer/index.d.ts +29 -0
- package/dist/cjs/slices/customer/index.js +52 -0
- package/dist/cjs/slices/customer/levelup.d.ts +36 -0
- package/dist/cjs/slices/customer/levelup.js +128 -0
- package/dist/cjs/slices/customer/loyalty.d.ts +27 -0
- package/dist/cjs/slices/customer/loyalty.js +87 -0
- package/dist/cjs/slices/customer/order.d.ts +25 -0
- package/dist/cjs/slices/customer/order.js +84 -0
- package/dist/cjs/slices/customer/orders.d.ts +20 -0
- package/dist/cjs/slices/customer/orders.js +67 -0
- package/dist/cjs/slices/customer/qrCode.d.ts +17 -0
- package/dist/cjs/slices/customer/qrCode.js +57 -0
- package/dist/cjs/slices/customer/rewards.d.ts +20 -0
- package/dist/cjs/slices/customer/rewards.js +67 -0
- package/dist/cjs/slices/customer/thanx.d.ts +17 -0
- package/dist/cjs/slices/customer/thanx.js +57 -0
- package/dist/cjs/slices/deals.d.ts +19 -0
- package/dist/cjs/slices/deals.js +97 -0
- package/dist/cjs/slices/donations.d.ts +26 -0
- package/dist/cjs/slices/donations.js +62 -0
- package/dist/cjs/slices/giftCards.d.ts +26 -0
- package/dist/cjs/slices/giftCards.js +63 -0
- package/dist/cjs/slices/groupOrder.d.ts +80 -0
- package/dist/cjs/slices/groupOrder.js +226 -0
- package/dist/cjs/slices/guest.d.ts +38 -0
- package/dist/cjs/slices/guest.js +101 -0
- package/dist/cjs/slices/index.d.ts +27 -0
- package/dist/cjs/slices/index.js +30 -0
- package/dist/cjs/slices/levelup.d.ts +18 -0
- package/dist/cjs/slices/levelup.js +51 -0
- package/dist/cjs/slices/menu.d.ts +22 -0
- package/dist/cjs/slices/menu.js +86 -0
- package/dist/cjs/slices/menuDisplay.d.ts +26 -0
- package/dist/cjs/slices/menuDisplay.js +59 -0
- package/dist/cjs/slices/menuItems.d.ts +20 -0
- package/dist/cjs/slices/menuItems.js +57 -0
- package/dist/cjs/slices/notifications.d.ts +5 -0
- package/dist/cjs/slices/notifications.js +27 -0
- package/dist/cjs/slices/order.d.ts +77 -0
- package/dist/cjs/slices/order.js +426 -0
- package/dist/cjs/slices/orderFulfillment.d.ts +29 -0
- package/dist/cjs/slices/orderFulfillment.js +83 -0
- package/dist/cjs/slices/orderRating.d.ts +34 -0
- package/dist/cjs/slices/orderRating.js +108 -0
- package/dist/cjs/slices/orders.d.ts +86 -0
- package/dist/cjs/slices/orders.js +311 -0
- package/dist/cjs/slices/resetPassword.d.ts +29 -0
- package/dist/cjs/slices/resetPassword.js +83 -0
- package/dist/cjs/slices/revenueCenters.d.ts +35 -0
- package/dist/cjs/slices/revenueCenters.js +95 -0
- package/dist/cjs/slices/signUp.d.ts +19 -0
- package/dist/cjs/slices/signUp.js +52 -0
- package/dist/cjs/slices/types.d.ts +43 -0
- package/dist/cjs/slices/types.js +47 -0
- package/dist/cjs/slices/validTimes.d.ts +17 -0
- package/dist/cjs/slices/validTimes.js +57 -0
- package/dist/cjs/slices/verifyAccount.d.ts +17 -0
- package/dist/cjs/slices/verifyAccount.js +54 -0
- package/dist/esm/app/hooks.d.ts +50 -0
- package/dist/esm/app/hooks.js +4 -0
- package/dist/esm/app/index.d.ts +1 -0
- package/dist/esm/app/index.js +1 -0
- package/dist/esm/app/store.d.ts +146 -0
- package/dist/esm/app/store.js +48 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/services/api.d.ts +162 -0
- package/dist/esm/services/api.js +689 -0
- package/dist/esm/services/errors.d.ts +50 -0
- package/dist/esm/services/errors.js +50 -0
- package/dist/esm/services/index.d.ts +2 -0
- package/dist/esm/services/index.js +2 -0
- package/dist/esm/slices/alerts.d.ts +5 -0
- package/dist/esm/slices/alerts.js +23 -0
- package/dist/esm/slices/allergens.d.ts +19 -0
- package/dist/esm/slices/allergens.js +60 -0
- package/dist/esm/slices/announcements.d.ts +28 -0
- package/dist/esm/slices/announcements.js +71 -0
- package/dist/esm/slices/checkout.d.ts +38 -0
- package/dist/esm/slices/checkout.js +268 -0
- package/dist/esm/slices/completedOrders.d.ts +25 -0
- package/dist/esm/slices/completedOrders.js +57 -0
- package/dist/esm/slices/config.d.ts +87 -0
- package/dist/esm/slices/config.js +102 -0
- package/dist/esm/slices/confirmation.d.ts +8 -0
- package/dist/esm/slices/confirmation.js +18 -0
- package/dist/esm/slices/customer/account.d.ts +59 -0
- package/dist/esm/slices/customer/account.js +282 -0
- package/dist/esm/slices/customer/addresses.d.ts +37 -0
- package/dist/esm/slices/customer/addresses.js +129 -0
- package/dist/esm/slices/customer/allergens.d.ts +25 -0
- package/dist/esm/slices/customer/allergens.js +89 -0
- package/dist/esm/slices/customer/communicationPreferences.d.ts +44 -0
- package/dist/esm/slices/customer/communicationPreferences.js +161 -0
- package/dist/esm/slices/customer/creditCards.d.ts +46 -0
- package/dist/esm/slices/customer/creditCards.js +166 -0
- package/dist/esm/slices/customer/favorites.d.ts +45 -0
- package/dist/esm/slices/customer/favorites.js +171 -0
- package/dist/esm/slices/customer/fcmToken.d.ts +31 -0
- package/dist/esm/slices/customer/fcmToken.js +106 -0
- package/dist/esm/slices/customer/giftCards.d.ts +62 -0
- package/dist/esm/slices/customer/giftCards.js +191 -0
- package/dist/esm/slices/customer/groupOrders.d.ts +33 -0
- package/dist/esm/slices/customer/groupOrders.js +143 -0
- package/dist/esm/slices/customer/houseAccounts.d.ts +20 -0
- package/dist/esm/slices/customer/houseAccounts.js +62 -0
- package/dist/esm/slices/customer/index.d.ts +29 -0
- package/dist/esm/slices/customer/index.js +48 -0
- package/dist/esm/slices/customer/levelup.d.ts +36 -0
- package/dist/esm/slices/customer/levelup.js +123 -0
- package/dist/esm/slices/customer/loyalty.d.ts +27 -0
- package/dist/esm/slices/customer/loyalty.js +79 -0
- package/dist/esm/slices/customer/order.d.ts +25 -0
- package/dist/esm/slices/customer/order.js +79 -0
- package/dist/esm/slices/customer/orders.d.ts +20 -0
- package/dist/esm/slices/customer/orders.js +62 -0
- package/dist/esm/slices/customer/qrCode.d.ts +17 -0
- package/dist/esm/slices/customer/qrCode.js +53 -0
- package/dist/esm/slices/customer/rewards.d.ts +20 -0
- package/dist/esm/slices/customer/rewards.js +62 -0
- package/dist/esm/slices/customer/thanx.d.ts +17 -0
- package/dist/esm/slices/customer/thanx.js +53 -0
- package/dist/esm/slices/deals.d.ts +19 -0
- package/dist/esm/slices/deals.js +91 -0
- package/dist/esm/slices/donations.d.ts +26 -0
- package/dist/esm/slices/donations.js +58 -0
- package/dist/esm/slices/giftCards.d.ts +26 -0
- package/dist/esm/slices/giftCards.js +59 -0
- package/dist/esm/slices/groupOrder.d.ts +80 -0
- package/dist/esm/slices/groupOrder.js +216 -0
- package/dist/esm/slices/guest.d.ts +38 -0
- package/dist/esm/slices/guest.js +97 -0
- package/dist/esm/slices/index.d.ts +27 -0
- package/dist/esm/slices/index.js +27 -0
- package/dist/esm/slices/levelup.d.ts +18 -0
- package/dist/esm/slices/levelup.js +48 -0
- package/dist/esm/slices/menu.d.ts +22 -0
- package/dist/esm/slices/menu.js +81 -0
- package/dist/esm/slices/menuDisplay.d.ts +26 -0
- package/dist/esm/slices/menuDisplay.js +55 -0
- package/dist/esm/slices/menuItems.d.ts +20 -0
- package/dist/esm/slices/menuItems.js +52 -0
- package/dist/esm/slices/notifications.d.ts +5 -0
- package/dist/esm/slices/notifications.js +22 -0
- package/dist/esm/slices/order.d.ts +77 -0
- package/dist/esm/slices/order.js +423 -0
- package/dist/esm/slices/orderFulfillment.d.ts +29 -0
- package/dist/esm/slices/orderFulfillment.js +79 -0
- package/dist/esm/slices/orderRating.d.ts +34 -0
- package/dist/esm/slices/orderRating.js +104 -0
- package/dist/esm/slices/orders.d.ts +86 -0
- package/dist/esm/slices/orders.js +302 -0
- package/dist/esm/slices/resetPassword.d.ts +29 -0
- package/dist/esm/slices/resetPassword.js +79 -0
- package/dist/esm/slices/revenueCenters.d.ts +35 -0
- package/dist/esm/slices/revenueCenters.js +89 -0
- package/dist/esm/slices/signUp.d.ts +19 -0
- package/dist/esm/slices/signUp.js +48 -0
- package/dist/esm/slices/types.d.ts +43 -0
- package/dist/esm/slices/types.js +44 -0
- package/dist/esm/slices/validTimes.d.ts +17 -0
- package/dist/esm/slices/validTimes.js +52 -0
- package/dist/esm/slices/verifyAccount.d.ts +17 -0
- package/dist/esm/slices/verifyAccount.js +50 -0
- package/package.json +61 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.customerCreditCardsReducer = exports.selectCustomerCreditCardsForPayment = exports.selectCustomerCreditCards = exports.setCustomerCreditCards = exports.resetCustomerCreditCardsError = exports.resetCustomerCreditCards = exports.addCustomerCreditCard = exports.removeCustomerCreditCard = exports.updateCustomerCreditCard = exports.fetchCustomerCreditCards = exports.CustomerCreditCardsActionType = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const toolkit_1 = require("@reduxjs/toolkit");
|
|
7
|
+
const types_1 = require("../types");
|
|
8
|
+
const types_2 = require("@open-tender/types");
|
|
9
|
+
const account_1 = require("./account");
|
|
10
|
+
const notifications_1 = require("../notifications");
|
|
11
|
+
const utils_1 = require("@open-tender/utils");
|
|
12
|
+
const initialState = {
|
|
13
|
+
entities: [],
|
|
14
|
+
lookup: {},
|
|
15
|
+
loading: 'idle',
|
|
16
|
+
error: null
|
|
17
|
+
};
|
|
18
|
+
var CustomerCreditCardsActionType;
|
|
19
|
+
(function (CustomerCreditCardsActionType) {
|
|
20
|
+
CustomerCreditCardsActionType["FetchCustomerCreditCards"] = "customer/fetchCustomerCreditCards";
|
|
21
|
+
CustomerCreditCardsActionType["UpdateCustomerCreditCard"] = "customer/updateCustomerCreditCard";
|
|
22
|
+
CustomerCreditCardsActionType["RemoveCustomerCreditCard"] = "customer/removeCustomerCreditCard";
|
|
23
|
+
CustomerCreditCardsActionType["AddCustomerCreditCard"] = "customer/addCustomerCreditCard";
|
|
24
|
+
})(CustomerCreditCardsActionType = exports.CustomerCreditCardsActionType || (exports.CustomerCreditCardsActionType = {}));
|
|
25
|
+
exports.fetchCustomerCreditCards = (0, toolkit_1.createAsyncThunk)(CustomerCreditCardsActionType.FetchCustomerCreditCards, (includeLinked, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
try {
|
|
27
|
+
const api = getState().config.api;
|
|
28
|
+
const token = (0, account_1.selectToken)(getState());
|
|
29
|
+
if (!token)
|
|
30
|
+
throw new Error(types_2.MISSING_CUSTOMER);
|
|
31
|
+
const creditCards = yield api.getCustomerCreditCards(token, includeLinked);
|
|
32
|
+
return creditCards;
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
const error = err;
|
|
36
|
+
return (0, account_1.checkAuth)(error, dispatch, () => rejectWithValue(error));
|
|
37
|
+
}
|
|
38
|
+
}));
|
|
39
|
+
exports.updateCustomerCreditCard = (0, toolkit_1.createAsyncThunk)(CustomerCreditCardsActionType.UpdateCustomerCreditCard, (requestData, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
try {
|
|
41
|
+
const api = getState().config.api;
|
|
42
|
+
const token = (0, account_1.selectToken)(getState());
|
|
43
|
+
if (!token)
|
|
44
|
+
throw new Error(types_2.MISSING_CUSTOMER);
|
|
45
|
+
yield api.putCustomerCreditCard(token, requestData.cardId, requestData.data);
|
|
46
|
+
const includeLinked = true;
|
|
47
|
+
const creditCards = yield api.getCustomerCreditCards(token, includeLinked);
|
|
48
|
+
dispatch((0, notifications_1.showNotification)('Credit card updated!'));
|
|
49
|
+
if (requestData.callback)
|
|
50
|
+
requestData.callback();
|
|
51
|
+
return creditCards;
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
const error = err;
|
|
55
|
+
const errors = (0, utils_1.makeFormErrors)(error);
|
|
56
|
+
return (0, account_1.checkAuth)(error, dispatch, () => rejectWithValue(errors));
|
|
57
|
+
}
|
|
58
|
+
}));
|
|
59
|
+
exports.removeCustomerCreditCard = (0, toolkit_1.createAsyncThunk)(CustomerCreditCardsActionType.RemoveCustomerCreditCard, (requestData, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
+
try {
|
|
61
|
+
const api = getState().config.api;
|
|
62
|
+
const token = (0, account_1.selectToken)(getState());
|
|
63
|
+
if (!token)
|
|
64
|
+
throw new Error(types_2.MISSING_CUSTOMER);
|
|
65
|
+
yield api.deleteCustomerCreditCard(token, requestData.cardId);
|
|
66
|
+
const includeLinked = true;
|
|
67
|
+
const creditCards = yield api.getCustomerCreditCards(token, includeLinked);
|
|
68
|
+
dispatch((0, notifications_1.showNotification)('Credit card removed!'));
|
|
69
|
+
if (requestData.callback)
|
|
70
|
+
requestData.callback();
|
|
71
|
+
return creditCards;
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
const error = err;
|
|
75
|
+
return (0, account_1.checkAuth)(error, dispatch, () => rejectWithValue(error));
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
78
|
+
exports.addCustomerCreditCard = (0, toolkit_1.createAsyncThunk)(CustomerCreditCardsActionType.AddCustomerCreditCard, (requestData, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
79
|
+
try {
|
|
80
|
+
const api = getState().config.api;
|
|
81
|
+
const token = (0, account_1.selectToken)(getState());
|
|
82
|
+
if (!token)
|
|
83
|
+
throw new Error(types_2.MISSING_CUSTOMER);
|
|
84
|
+
yield api.postCustomerCreditCard(token, requestData.data);
|
|
85
|
+
const includeLinked = true;
|
|
86
|
+
const creditCards = yield api.getCustomerCreditCards(token, includeLinked);
|
|
87
|
+
dispatch((0, notifications_1.showNotification)('Credit card added!'));
|
|
88
|
+
if (requestData.callback)
|
|
89
|
+
requestData.callback();
|
|
90
|
+
return creditCards;
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
const error = err;
|
|
94
|
+
const errors = (0, utils_1.makeFormErrors)(error);
|
|
95
|
+
return (0, account_1.checkAuth)(error, dispatch, () => rejectWithValue(errors));
|
|
96
|
+
}
|
|
97
|
+
}));
|
|
98
|
+
const customerCreditCardsSlice = (0, toolkit_1.createSlice)({
|
|
99
|
+
name: types_1.ReducerType.CreditCards,
|
|
100
|
+
initialState,
|
|
101
|
+
reducers: {
|
|
102
|
+
resetCustomerCreditCards: () => initialState,
|
|
103
|
+
resetCustomerCreditCardsError: state => {
|
|
104
|
+
state.error = null;
|
|
105
|
+
state.loading = 'idle';
|
|
106
|
+
},
|
|
107
|
+
setCustomerCreditCards: (state, action) => {
|
|
108
|
+
state.entities = action.payload;
|
|
109
|
+
state.error = null;
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
extraReducers: builder => {
|
|
113
|
+
builder
|
|
114
|
+
.addCase(exports.fetchCustomerCreditCards.fulfilled, (state, action) => {
|
|
115
|
+
state.entities = action.payload;
|
|
116
|
+
state.loading = 'idle';
|
|
117
|
+
state.error = null;
|
|
118
|
+
})
|
|
119
|
+
.addCase(exports.fetchCustomerCreditCards.pending, state => {
|
|
120
|
+
state.loading = 'pending';
|
|
121
|
+
})
|
|
122
|
+
.addCase(exports.fetchCustomerCreditCards.rejected, (state, action) => {
|
|
123
|
+
state.error = action.payload;
|
|
124
|
+
state.loading = 'idle';
|
|
125
|
+
})
|
|
126
|
+
.addCase(exports.updateCustomerCreditCard.fulfilled, (state, action) => {
|
|
127
|
+
state.entities = action.payload;
|
|
128
|
+
state.loading = 'idle';
|
|
129
|
+
state.error = null;
|
|
130
|
+
})
|
|
131
|
+
.addCase(exports.updateCustomerCreditCard.pending, state => {
|
|
132
|
+
state.loading = 'pending';
|
|
133
|
+
})
|
|
134
|
+
.addCase(exports.updateCustomerCreditCard.rejected, (state, action) => {
|
|
135
|
+
state.error = action.payload;
|
|
136
|
+
state.loading = 'idle';
|
|
137
|
+
})
|
|
138
|
+
.addCase(exports.removeCustomerCreditCard.fulfilled, (state, action) => {
|
|
139
|
+
state.entities = action.payload;
|
|
140
|
+
state.loading = 'idle';
|
|
141
|
+
state.error = null;
|
|
142
|
+
})
|
|
143
|
+
.addCase(exports.removeCustomerCreditCard.pending, state => {
|
|
144
|
+
state.loading = 'pending';
|
|
145
|
+
})
|
|
146
|
+
.addCase(exports.removeCustomerCreditCard.rejected, (state, action) => {
|
|
147
|
+
state.error = action.payload;
|
|
148
|
+
state.loading = 'idle';
|
|
149
|
+
})
|
|
150
|
+
.addCase(exports.addCustomerCreditCard.fulfilled, (state, action) => {
|
|
151
|
+
state.entities = action.payload;
|
|
152
|
+
state.loading = 'idle';
|
|
153
|
+
state.error = null;
|
|
154
|
+
})
|
|
155
|
+
.addCase(exports.addCustomerCreditCard.pending, state => {
|
|
156
|
+
state.loading = 'pending';
|
|
157
|
+
})
|
|
158
|
+
.addCase(exports.addCustomerCreditCard.rejected, (state, action) => {
|
|
159
|
+
state.error = action.payload;
|
|
160
|
+
state.loading = 'idle';
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
_a = customerCreditCardsSlice.actions, exports.resetCustomerCreditCards = _a.resetCustomerCreditCards, exports.resetCustomerCreditCardsError = _a.resetCustomerCreditCardsError, exports.setCustomerCreditCards = _a.setCustomerCreditCards;
|
|
165
|
+
const selectCustomerCreditCards = (state) => state.customer.creditCards;
|
|
166
|
+
exports.selectCustomerCreditCards = selectCustomerCreditCards;
|
|
167
|
+
const selectCustomerCreditCardsForPayment = (state) => {
|
|
168
|
+
const creditCards = state.customer.creditCards.entities;
|
|
169
|
+
return creditCards.filter(i => i.has_profile);
|
|
170
|
+
};
|
|
171
|
+
exports.selectCustomerCreditCardsForPayment = selectCustomerCreditCardsForPayment;
|
|
172
|
+
exports.customerCreditCardsReducer = customerCreditCardsSlice.reducer;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AppState } from '../../app';
|
|
2
|
+
import { Favorite, Favorites, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
+
export interface CustomerFavoritesState {
|
|
4
|
+
entities: Favorites;
|
|
5
|
+
error: RequestError;
|
|
6
|
+
loading: RequestStatus;
|
|
7
|
+
lookup: {
|
|
8
|
+
[key: number]: number;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare enum CustomerFavoritesActionType {
|
|
12
|
+
FetchCustomerFavorites = "customer/fetchCustomerFavorites",
|
|
13
|
+
UpdateCustomerFavorite = "customer/updateCustomerFavorite",
|
|
14
|
+
RemoveCustomerFavorite = "customer/removeCustomerFavorite",
|
|
15
|
+
AddCustomerFavorite = "customer/addCustomerFavorite"
|
|
16
|
+
}
|
|
17
|
+
export declare const fetchCustomerFavorites: import("@reduxjs/toolkit").AsyncThunk<Favorites, void, {
|
|
18
|
+
state: AppState;
|
|
19
|
+
rejectValue: RequestError;
|
|
20
|
+
}>;
|
|
21
|
+
export declare const updateCustomerFavorite: import("@reduxjs/toolkit").AsyncThunk<Favorites, {
|
|
22
|
+
favoriteId: number;
|
|
23
|
+
data: Favorite;
|
|
24
|
+
callback?: (() => void) | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
state: AppState;
|
|
27
|
+
rejectValue: RequestError;
|
|
28
|
+
}>;
|
|
29
|
+
export declare const removeCustomerFavorite: import("@reduxjs/toolkit").AsyncThunk<Favorites, {
|
|
30
|
+
favoriteId: number;
|
|
31
|
+
callback?: (() => void) | undefined;
|
|
32
|
+
}, {
|
|
33
|
+
state: AppState;
|
|
34
|
+
rejectValue: RequestError;
|
|
35
|
+
}>;
|
|
36
|
+
export declare const addCustomerFavorite: import("@reduxjs/toolkit").AsyncThunk<Favorites, {
|
|
37
|
+
data: Favorite;
|
|
38
|
+
callback?: (() => void) | undefined;
|
|
39
|
+
}, {
|
|
40
|
+
state: AppState;
|
|
41
|
+
rejectValue: RequestError;
|
|
42
|
+
}>;
|
|
43
|
+
export declare const resetCustomerFavorites: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetCustomerFavoritesError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setCustomerFavorites: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setCustomerFavoritesLookup: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>;
|
|
44
|
+
export declare const selectCustomerFavorites: (state: AppState) => CustomerFavoritesState;
|
|
45
|
+
export declare const customerFavoritesReducer: import("redux").Reducer<CustomerFavoritesState, import("redux").AnyAction>;
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.customerFavoritesReducer = exports.selectCustomerFavorites = exports.setCustomerFavoritesLookup = exports.setCustomerFavorites = exports.resetCustomerFavoritesError = exports.resetCustomerFavorites = exports.addCustomerFavorite = exports.removeCustomerFavorite = exports.updateCustomerFavorite = exports.fetchCustomerFavorites = exports.CustomerFavoritesActionType = void 0;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const toolkit_1 = require("@reduxjs/toolkit");
|
|
7
|
+
const types_1 = require("../types");
|
|
8
|
+
const types_2 = require("@open-tender/types");
|
|
9
|
+
const account_1 = require("./account");
|
|
10
|
+
const notifications_1 = require("../notifications");
|
|
11
|
+
const utils_1 = require("@open-tender/utils");
|
|
12
|
+
const initialState = {
|
|
13
|
+
entities: [],
|
|
14
|
+
error: null,
|
|
15
|
+
loading: 'idle',
|
|
16
|
+
lookup: {}
|
|
17
|
+
};
|
|
18
|
+
var CustomerFavoritesActionType;
|
|
19
|
+
(function (CustomerFavoritesActionType) {
|
|
20
|
+
CustomerFavoritesActionType["FetchCustomerFavorites"] = "customer/fetchCustomerFavorites";
|
|
21
|
+
CustomerFavoritesActionType["UpdateCustomerFavorite"] = "customer/updateCustomerFavorite";
|
|
22
|
+
CustomerFavoritesActionType["RemoveCustomerFavorite"] = "customer/removeCustomerFavorite";
|
|
23
|
+
CustomerFavoritesActionType["AddCustomerFavorite"] = "customer/addCustomerFavorite";
|
|
24
|
+
})(CustomerFavoritesActionType = exports.CustomerFavoritesActionType || (exports.CustomerFavoritesActionType = {}));
|
|
25
|
+
exports.fetchCustomerFavorites = (0, toolkit_1.createAsyncThunk)(CustomerFavoritesActionType.FetchCustomerFavorites, (_, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
try {
|
|
27
|
+
const api = getState().config.api;
|
|
28
|
+
const token = (0, account_1.selectToken)(getState());
|
|
29
|
+
if (!token)
|
|
30
|
+
throw new Error(types_2.MISSING_CUSTOMER);
|
|
31
|
+
const { data: favorites } = yield api.getCustomerFavorites(token);
|
|
32
|
+
const lookup = (0, utils_1.makeFavoritesLookup)(favorites);
|
|
33
|
+
dispatch((0, exports.setCustomerFavoritesLookup)(lookup));
|
|
34
|
+
return favorites;
|
|
35
|
+
}
|
|
36
|
+
catch (err) {
|
|
37
|
+
const error = err;
|
|
38
|
+
return (0, account_1.checkAuth)(error, dispatch, () => rejectWithValue(error));
|
|
39
|
+
}
|
|
40
|
+
}));
|
|
41
|
+
exports.updateCustomerFavorite = (0, toolkit_1.createAsyncThunk)(CustomerFavoritesActionType.UpdateCustomerFavorite, (requestData, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
+
try {
|
|
43
|
+
const api = getState().config.api;
|
|
44
|
+
const token = (0, account_1.selectToken)(getState());
|
|
45
|
+
if (!token)
|
|
46
|
+
throw new Error(types_2.MISSING_CUSTOMER);
|
|
47
|
+
yield api.putCustomerFavorite(token, requestData.favoriteId, requestData.data);
|
|
48
|
+
const { data: favorites } = yield api.getCustomerFavorites(token);
|
|
49
|
+
const lookup = (0, utils_1.makeFavoritesLookup)(favorites);
|
|
50
|
+
dispatch((0, exports.setCustomerFavoritesLookup)(lookup));
|
|
51
|
+
dispatch((0, notifications_1.showNotification)('Favorite updated!'));
|
|
52
|
+
if (requestData.callback)
|
|
53
|
+
requestData.callback();
|
|
54
|
+
return favorites;
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
const error = err;
|
|
58
|
+
const errors = (0, utils_1.makeFormErrors)(error);
|
|
59
|
+
return (0, account_1.checkAuth)(error, dispatch, () => rejectWithValue(errors));
|
|
60
|
+
}
|
|
61
|
+
}));
|
|
62
|
+
exports.removeCustomerFavorite = (0, toolkit_1.createAsyncThunk)(CustomerFavoritesActionType.RemoveCustomerFavorite, (requestData, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
+
try {
|
|
64
|
+
const api = getState().config.api;
|
|
65
|
+
const token = (0, account_1.selectToken)(getState());
|
|
66
|
+
if (!token)
|
|
67
|
+
throw new Error(types_2.MISSING_CUSTOMER);
|
|
68
|
+
yield api.deleteCustomerFavorite(token, requestData.favoriteId);
|
|
69
|
+
const { data: favorites } = yield api.getCustomerFavorites(token);
|
|
70
|
+
const lookup = (0, utils_1.makeFavoritesLookup)(favorites);
|
|
71
|
+
dispatch((0, exports.setCustomerFavoritesLookup)(lookup));
|
|
72
|
+
if (requestData.callback)
|
|
73
|
+
requestData.callback();
|
|
74
|
+
return favorites;
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
const error = err;
|
|
78
|
+
return (0, account_1.checkAuth)(error, dispatch, () => rejectWithValue(error));
|
|
79
|
+
}
|
|
80
|
+
}));
|
|
81
|
+
exports.addCustomerFavorite = (0, toolkit_1.createAsyncThunk)(CustomerFavoritesActionType.AddCustomerFavorite, (requestData, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
82
|
+
try {
|
|
83
|
+
const api = getState().config.api;
|
|
84
|
+
const token = (0, account_1.selectToken)(getState());
|
|
85
|
+
if (!token)
|
|
86
|
+
throw new Error(types_2.MISSING_CUSTOMER);
|
|
87
|
+
if (!requestData.data.name)
|
|
88
|
+
requestData.data.name = '';
|
|
89
|
+
yield api.postCustomerFavorite(token, requestData.data);
|
|
90
|
+
const { data: favorites } = yield api.getCustomerFavorites(token);
|
|
91
|
+
const lookup = (0, utils_1.makeFavoritesLookup)(favorites);
|
|
92
|
+
dispatch((0, exports.setCustomerFavoritesLookup)(lookup));
|
|
93
|
+
if (requestData.callback)
|
|
94
|
+
requestData.callback();
|
|
95
|
+
return favorites;
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
const error = err;
|
|
99
|
+
const errors = (0, utils_1.makeFormErrors)(error);
|
|
100
|
+
return (0, account_1.checkAuth)(error, dispatch, () => rejectWithValue(errors));
|
|
101
|
+
}
|
|
102
|
+
}));
|
|
103
|
+
const customerFavoritesSlice = (0, toolkit_1.createSlice)({
|
|
104
|
+
name: types_1.ReducerType.Favorites,
|
|
105
|
+
initialState,
|
|
106
|
+
reducers: {
|
|
107
|
+
resetCustomerFavorites: () => initialState,
|
|
108
|
+
resetCustomerFavoritesError: state => {
|
|
109
|
+
state.error = null;
|
|
110
|
+
state.loading = 'idle';
|
|
111
|
+
},
|
|
112
|
+
setCustomerFavorites: (state, action) => {
|
|
113
|
+
state.entities = action.payload;
|
|
114
|
+
state.error = null;
|
|
115
|
+
},
|
|
116
|
+
setCustomerFavoritesLookup: (state, action) => {
|
|
117
|
+
state.lookup = action.payload;
|
|
118
|
+
state.error = null;
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
extraReducers: builder => {
|
|
122
|
+
builder
|
|
123
|
+
.addCase(exports.fetchCustomerFavorites.fulfilled, (state, action) => {
|
|
124
|
+
state.entities = action.payload;
|
|
125
|
+
state.loading = 'idle';
|
|
126
|
+
state.error = null;
|
|
127
|
+
})
|
|
128
|
+
.addCase(exports.fetchCustomerFavorites.pending, state => {
|
|
129
|
+
state.loading = 'pending';
|
|
130
|
+
})
|
|
131
|
+
.addCase(exports.fetchCustomerFavorites.rejected, (state, action) => {
|
|
132
|
+
state.error = action.payload;
|
|
133
|
+
state.loading = 'idle';
|
|
134
|
+
})
|
|
135
|
+
.addCase(exports.updateCustomerFavorite.fulfilled, (state, action) => {
|
|
136
|
+
state.entities = action.payload;
|
|
137
|
+
state.loading = 'idle';
|
|
138
|
+
state.error = null;
|
|
139
|
+
})
|
|
140
|
+
.addCase(exports.updateCustomerFavorite.pending, state => {
|
|
141
|
+
state.loading = 'pending';
|
|
142
|
+
})
|
|
143
|
+
.addCase(exports.updateCustomerFavorite.rejected, (state, action) => {
|
|
144
|
+
state.error = action.payload;
|
|
145
|
+
state.loading = 'idle';
|
|
146
|
+
})
|
|
147
|
+
.addCase(exports.removeCustomerFavorite.fulfilled, (state, action) => {
|
|
148
|
+
state.entities = action.payload;
|
|
149
|
+
state.loading = 'idle';
|
|
150
|
+
state.error = null;
|
|
151
|
+
})
|
|
152
|
+
.addCase(exports.removeCustomerFavorite.pending, state => {
|
|
153
|
+
state.loading = 'pending';
|
|
154
|
+
})
|
|
155
|
+
.addCase(exports.removeCustomerFavorite.rejected, (state, action) => {
|
|
156
|
+
state.error = action.payload;
|
|
157
|
+
state.loading = 'idle';
|
|
158
|
+
})
|
|
159
|
+
.addCase(exports.addCustomerFavorite.fulfilled, (state, action) => {
|
|
160
|
+
state.entities = action.payload;
|
|
161
|
+
state.loading = 'idle';
|
|
162
|
+
state.error = null;
|
|
163
|
+
})
|
|
164
|
+
.addCase(exports.addCustomerFavorite.pending, state => {
|
|
165
|
+
state.loading = 'pending';
|
|
166
|
+
})
|
|
167
|
+
.addCase(exports.addCustomerFavorite.rejected, (state, action) => {
|
|
168
|
+
state.error = action.payload;
|
|
169
|
+
state.loading = 'idle';
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
_a = customerFavoritesSlice.actions, exports.resetCustomerFavorites = _a.resetCustomerFavorites, exports.resetCustomerFavoritesError = _a.resetCustomerFavoritesError, exports.setCustomerFavorites = _a.setCustomerFavorites, exports.setCustomerFavoritesLookup = _a.setCustomerFavoritesLookup;
|
|
174
|
+
const selectCustomerFavorites = (state) => state.customer.favorites;
|
|
175
|
+
exports.selectCustomerFavorites = selectCustomerFavorites;
|
|
176
|
+
exports.customerFavoritesReducer = customerFavoritesSlice.reducer;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { AppState } from '../../app';
|
|
2
|
+
import { RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
+
export interface CustomerFcmTokenState {
|
|
4
|
+
error: RequestError;
|
|
5
|
+
loading: RequestStatus;
|
|
6
|
+
}
|
|
7
|
+
export declare enum CustomerFcmTokenActionType {
|
|
8
|
+
FetchCustomerFcmTokens = "customer/fetchCustomerFcmTokens",
|
|
9
|
+
RemoveCustomerFcmTokens = "customer/removeCustomerFcmTokens",
|
|
10
|
+
AddCustomerFcmToken = "customer/addCustomerFcmToken"
|
|
11
|
+
}
|
|
12
|
+
export declare const fetchCustomerFcmTokens: import("@reduxjs/toolkit").AsyncThunk<void, void, {
|
|
13
|
+
state: AppState;
|
|
14
|
+
rejectValue: RequestError;
|
|
15
|
+
}>;
|
|
16
|
+
export declare const removeCustomerFcmTokens: import("@reduxjs/toolkit").AsyncThunk<void, {
|
|
17
|
+
callback?: (() => void) | undefined;
|
|
18
|
+
}, {
|
|
19
|
+
state: AppState;
|
|
20
|
+
rejectValue: RequestError;
|
|
21
|
+
}>;
|
|
22
|
+
export declare const addCustomerFcmToken: import("@reduxjs/toolkit").AsyncThunk<void, {
|
|
23
|
+
fcmToken: string;
|
|
24
|
+
callback?: (() => void) | undefined;
|
|
25
|
+
}, {
|
|
26
|
+
state: AppState;
|
|
27
|
+
rejectValue: RequestError;
|
|
28
|
+
}>;
|
|
29
|
+
export declare const resetCustomerFcmToken: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
|
|
30
|
+
export declare const selectCustomerFcmToken: (state: AppState) => CustomerFcmTokenState;
|
|
31
|
+
export declare const customerFcmTokenReducer: import("redux").Reducer<CustomerFcmTokenState, import("redux").AnyAction>;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.customerFcmTokenReducer = exports.selectCustomerFcmToken = exports.resetCustomerFcmToken = exports.addCustomerFcmToken = exports.removeCustomerFcmTokens = exports.fetchCustomerFcmTokens = exports.CustomerFcmTokenActionType = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const toolkit_1 = require("@reduxjs/toolkit");
|
|
6
|
+
const types_1 = require("../types");
|
|
7
|
+
const types_2 = require("@open-tender/types");
|
|
8
|
+
const account_1 = require("./account");
|
|
9
|
+
const initialState = {
|
|
10
|
+
error: null,
|
|
11
|
+
loading: 'idle'
|
|
12
|
+
};
|
|
13
|
+
var CustomerFcmTokenActionType;
|
|
14
|
+
(function (CustomerFcmTokenActionType) {
|
|
15
|
+
CustomerFcmTokenActionType["FetchCustomerFcmTokens"] = "customer/fetchCustomerFcmTokens";
|
|
16
|
+
CustomerFcmTokenActionType["RemoveCustomerFcmTokens"] = "customer/removeCustomerFcmTokens";
|
|
17
|
+
CustomerFcmTokenActionType["AddCustomerFcmToken"] = "customer/addCustomerFcmToken";
|
|
18
|
+
})(CustomerFcmTokenActionType = exports.CustomerFcmTokenActionType || (exports.CustomerFcmTokenActionType = {}));
|
|
19
|
+
exports.fetchCustomerFcmTokens = (0, toolkit_1.createAsyncThunk)(CustomerFcmTokenActionType.FetchCustomerFcmTokens, (_, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
20
|
+
try {
|
|
21
|
+
const api = getState().config.api;
|
|
22
|
+
const token = (0, account_1.selectToken)(getState());
|
|
23
|
+
if (!token)
|
|
24
|
+
throw new Error(types_2.MISSING_CUSTOMER);
|
|
25
|
+
return yield api.getCustomerFcmToken(token);
|
|
26
|
+
}
|
|
27
|
+
catch (err) {
|
|
28
|
+
const error = err;
|
|
29
|
+
return (0, account_1.checkAuth)(error, dispatch, () => rejectWithValue(error));
|
|
30
|
+
}
|
|
31
|
+
}));
|
|
32
|
+
exports.removeCustomerFcmTokens = (0, toolkit_1.createAsyncThunk)(CustomerFcmTokenActionType.RemoveCustomerFcmTokens, (requestData, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
+
try {
|
|
34
|
+
const api = getState().config.api;
|
|
35
|
+
const token = (0, account_1.selectToken)(getState());
|
|
36
|
+
if (!token)
|
|
37
|
+
throw new Error(types_2.MISSING_CUSTOMER);
|
|
38
|
+
const response = yield api.deleteCustomerFcmToken(token);
|
|
39
|
+
if (requestData.callback)
|
|
40
|
+
requestData.callback();
|
|
41
|
+
return response;
|
|
42
|
+
}
|
|
43
|
+
catch (err) {
|
|
44
|
+
const error = err;
|
|
45
|
+
return (0, account_1.checkAuth)(error, dispatch, () => rejectWithValue(error));
|
|
46
|
+
}
|
|
47
|
+
}));
|
|
48
|
+
exports.addCustomerFcmToken = (0, toolkit_1.createAsyncThunk)(CustomerFcmTokenActionType.AddCustomerFcmToken, (requestData, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
try {
|
|
50
|
+
const api = getState().config.api;
|
|
51
|
+
const token = (0, account_1.selectToken)(getState());
|
|
52
|
+
if (!token)
|
|
53
|
+
throw new Error(types_2.MISSING_CUSTOMER);
|
|
54
|
+
const response = yield api.postCustomerFcmToken(token, requestData.fcmToken);
|
|
55
|
+
if (requestData.callback)
|
|
56
|
+
requestData.callback();
|
|
57
|
+
return response;
|
|
58
|
+
}
|
|
59
|
+
catch (err) {
|
|
60
|
+
const error = err;
|
|
61
|
+
return (0, account_1.checkAuth)(error, dispatch, () => rejectWithValue(error));
|
|
62
|
+
}
|
|
63
|
+
}));
|
|
64
|
+
const customerFcmTokenSlice = (0, toolkit_1.createSlice)({
|
|
65
|
+
name: types_1.ReducerType.FcmToken,
|
|
66
|
+
initialState,
|
|
67
|
+
reducers: {
|
|
68
|
+
resetCustomerFcmToken: () => initialState
|
|
69
|
+
},
|
|
70
|
+
extraReducers: builder => {
|
|
71
|
+
builder
|
|
72
|
+
.addCase(exports.fetchCustomerFcmTokens.fulfilled, state => {
|
|
73
|
+
state.loading = 'idle';
|
|
74
|
+
state.error = null;
|
|
75
|
+
})
|
|
76
|
+
.addCase(exports.fetchCustomerFcmTokens.pending, state => {
|
|
77
|
+
state.loading = 'pending';
|
|
78
|
+
})
|
|
79
|
+
.addCase(exports.fetchCustomerFcmTokens.rejected, (state, action) => {
|
|
80
|
+
state.error = action.payload;
|
|
81
|
+
state.loading = 'idle';
|
|
82
|
+
})
|
|
83
|
+
.addCase(exports.removeCustomerFcmTokens.fulfilled, state => {
|
|
84
|
+
state.loading = 'idle';
|
|
85
|
+
state.error = null;
|
|
86
|
+
})
|
|
87
|
+
.addCase(exports.removeCustomerFcmTokens.pending, state => {
|
|
88
|
+
state.loading = 'pending';
|
|
89
|
+
})
|
|
90
|
+
.addCase(exports.removeCustomerFcmTokens.rejected, (state, action) => {
|
|
91
|
+
state.error = action.payload;
|
|
92
|
+
state.loading = 'idle';
|
|
93
|
+
})
|
|
94
|
+
.addCase(exports.addCustomerFcmToken.fulfilled, state => {
|
|
95
|
+
state.loading = 'idle';
|
|
96
|
+
state.error = null;
|
|
97
|
+
})
|
|
98
|
+
.addCase(exports.addCustomerFcmToken.pending, state => {
|
|
99
|
+
state.loading = 'pending';
|
|
100
|
+
})
|
|
101
|
+
.addCase(exports.addCustomerFcmToken.rejected, (state, action) => {
|
|
102
|
+
state.error = action.payload;
|
|
103
|
+
state.loading = 'idle';
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
exports.resetCustomerFcmToken = customerFcmTokenSlice.actions.resetCustomerFcmToken;
|
|
108
|
+
const selectCustomerFcmToken = (state) => state.customer.fcmToken;
|
|
109
|
+
exports.selectCustomerFcmToken = selectCustomerFcmToken;
|
|
110
|
+
exports.customerFcmTokenReducer = customerFcmTokenSlice.reducer;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { AppState } from '../../app';
|
|
2
|
+
import { CustomerGiftCard, CustomerGiftCards, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
+
export interface CustomerGiftCardsState {
|
|
4
|
+
entities: CustomerGiftCards;
|
|
5
|
+
error: RequestError;
|
|
6
|
+
loading: RequestStatus;
|
|
7
|
+
lookup: {
|
|
8
|
+
[key: number]: number;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare enum CustomerGiftCardsActionType {
|
|
12
|
+
FetchCustomerGiftCards = "customer/fetchCustomerGiftCards",
|
|
13
|
+
RemoveCustomerGiftCard = "customer/removeCustomerGiftCard",
|
|
14
|
+
AddCustomerGiftCard = "customer/addCustomerGiftCard",
|
|
15
|
+
AssignCustomerGiftCard = "customer/assignCustomerGiftCard",
|
|
16
|
+
AssignCustomerGiftCardOther = "customer/assignCustomerGiftCardOther",
|
|
17
|
+
UpdateCustomerGiftCard = "customer/updateCustomerGiftCard"
|
|
18
|
+
}
|
|
19
|
+
export declare const fetchCustomerGiftCards: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, void, {
|
|
20
|
+
state: AppState;
|
|
21
|
+
rejectValue: RequestError;
|
|
22
|
+
}>;
|
|
23
|
+
export declare const updateCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, {
|
|
24
|
+
giftCardId: number;
|
|
25
|
+
data: CustomerGiftCard;
|
|
26
|
+
callback?: (() => void) | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
state: AppState;
|
|
29
|
+
rejectValue: RequestError;
|
|
30
|
+
}>;
|
|
31
|
+
export declare const removeCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, {
|
|
32
|
+
giftCardId: number;
|
|
33
|
+
callback?: (() => void) | undefined;
|
|
34
|
+
}, {
|
|
35
|
+
state: AppState;
|
|
36
|
+
rejectValue: RequestError;
|
|
37
|
+
}>;
|
|
38
|
+
export declare const addCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, {
|
|
39
|
+
data: CustomerGiftCard;
|
|
40
|
+
callback?: (() => void) | undefined;
|
|
41
|
+
}, {
|
|
42
|
+
state: AppState;
|
|
43
|
+
rejectValue: RequestError;
|
|
44
|
+
}>;
|
|
45
|
+
export declare const assignCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, {
|
|
46
|
+
cardNumber: string;
|
|
47
|
+
callback?: (() => void) | undefined;
|
|
48
|
+
}, {
|
|
49
|
+
state: AppState;
|
|
50
|
+
rejectValue: RequestError;
|
|
51
|
+
}>;
|
|
52
|
+
export declare const assignCustomerGiftCardOther: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, {
|
|
53
|
+
giftCardId: number;
|
|
54
|
+
email: string;
|
|
55
|
+
callback?: (() => void) | undefined;
|
|
56
|
+
}, {
|
|
57
|
+
state: AppState;
|
|
58
|
+
rejectValue: RequestError;
|
|
59
|
+
}>;
|
|
60
|
+
export declare const resetCustomerGiftCards: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetCustomerGiftCardsError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setCustomerGiftCards: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>;
|
|
61
|
+
export declare const selectCustomerGiftCards: (state: AppState) => CustomerGiftCardsState;
|
|
62
|
+
export declare const customerGiftCardsReducer: import("redux").Reducer<CustomerGiftCardsState, import("redux").AnyAction>;
|