@open-tender/cloud 0.5.8 → 0.5.9
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 -96
- 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 -90
- 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
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { AppState } from '../app';
|
|
2
|
-
import { Customer, CustomerCreate, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
-
export interface SignUpState {
|
|
4
|
-
loading: RequestStatus;
|
|
5
|
-
error: RequestError;
|
|
6
|
-
}
|
|
7
|
-
export declare enum SignUpActionType {
|
|
8
|
-
SignUpCustomer = "signUp/signUpCustomer"
|
|
9
|
-
}
|
|
10
|
-
export declare const signUpCustomer: import("@reduxjs/toolkit").AsyncThunk<void, {
|
|
11
|
-
data: CustomerCreate;
|
|
12
|
-
callback?: ((data: Customer) => void) | undefined;
|
|
13
|
-
}, {
|
|
14
|
-
state: AppState;
|
|
15
|
-
rejectValue: RequestError;
|
|
16
|
-
dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
|
|
17
|
-
extra?: unknown;
|
|
18
|
-
serializedErrorType?: unknown;
|
|
19
|
-
pendingMeta?: unknown;
|
|
20
|
-
fulfilledMeta?: unknown;
|
|
21
|
-
rejectedMeta?: unknown;
|
|
22
|
-
}>;
|
|
23
|
-
export declare const resetSignUp: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"signUp/resetSignUp">;
|
|
24
|
-
export declare const selectSignUp: (state: AppState) => SignUpState;
|
|
25
|
-
export declare const signUpReducer: import("redux").Reducer<SignUpState, import("redux").AnyAction>;
|
|
1
|
+
import { AppState } from '../app';
|
|
2
|
+
import { Customer, CustomerCreate, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
+
export interface SignUpState {
|
|
4
|
+
loading: RequestStatus;
|
|
5
|
+
error: RequestError;
|
|
6
|
+
}
|
|
7
|
+
export declare enum SignUpActionType {
|
|
8
|
+
SignUpCustomer = "signUp/signUpCustomer"
|
|
9
|
+
}
|
|
10
|
+
export declare const signUpCustomer: import("@reduxjs/toolkit").AsyncThunk<void, {
|
|
11
|
+
data: CustomerCreate;
|
|
12
|
+
callback?: ((data: Customer) => void) | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
state: AppState;
|
|
15
|
+
rejectValue: RequestError;
|
|
16
|
+
dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
|
|
17
|
+
extra?: unknown;
|
|
18
|
+
serializedErrorType?: unknown;
|
|
19
|
+
pendingMeta?: unknown;
|
|
20
|
+
fulfilledMeta?: unknown;
|
|
21
|
+
rejectedMeta?: unknown;
|
|
22
|
+
}>;
|
|
23
|
+
export declare const resetSignUp: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"signUp/resetSignUp">;
|
|
24
|
+
export declare const selectSignUp: (state: AppState) => SignUpState;
|
|
25
|
+
export declare const signUpReducer: import("redux").Reducer<SignUpState, import("redux").AnyAction>;
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
|
-
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
3
|
-
import { ReducerType } from './types';
|
|
4
|
-
import { fetchCustomer, loginCustomer, setCustomerAuth } from './customer';
|
|
5
|
-
const initialState = {
|
|
6
|
-
loading: 'idle',
|
|
7
|
-
error: null
|
|
8
|
-
};
|
|
9
|
-
export var SignUpActionType;
|
|
10
|
-
(function (SignUpActionType) {
|
|
11
|
-
SignUpActionType["SignUpCustomer"] = "signUp/signUpCustomer";
|
|
12
|
-
})(SignUpActionType || (SignUpActionType = {}));
|
|
13
|
-
export const signUpCustomer = createAsyncThunk(SignUpActionType.SignUpCustomer, ({ data, callback }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
-
try {
|
|
15
|
-
const { api, brand } = getState().config;
|
|
16
|
-
const response = yield api.postSignUp(data);
|
|
17
|
-
const { email, password } = data;
|
|
18
|
-
if (email && password) {
|
|
19
|
-
if ((brand === null || brand === void 0 ? void 0 : brand.tpls) && (brand === null || brand === void 0 ? void 0 : brand.tpls) !== 'SPARKFLY') {
|
|
20
|
-
const resp = yield api.postCustomerSignIn(data);
|
|
21
|
-
dispatch(setCustomerAuth(resp));
|
|
22
|
-
yield dispatch(fetchCustomer());
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
dispatch(loginCustomer({ email, password }));
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
if (callback)
|
|
29
|
-
callback(response);
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
catch (err) {
|
|
33
|
-
return rejectWithValue(err);
|
|
34
|
-
}
|
|
35
|
-
}));
|
|
36
|
-
const signUpSlice = createSlice({
|
|
37
|
-
name: ReducerType.SignUp,
|
|
38
|
-
initialState,
|
|
39
|
-
reducers: {
|
|
40
|
-
resetSignUp: () => initialState
|
|
41
|
-
},
|
|
42
|
-
extraReducers: builder => {
|
|
43
|
-
builder
|
|
44
|
-
.addCase(signUpCustomer.fulfilled, () => initialState)
|
|
45
|
-
.addCase(signUpCustomer.pending, state => {
|
|
46
|
-
state.loading = 'pending';
|
|
47
|
-
})
|
|
48
|
-
.addCase(signUpCustomer.rejected, (state, action) => {
|
|
49
|
-
state.loading = 'idle';
|
|
50
|
-
state.error = action.payload;
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
});
|
|
54
|
-
export const { resetSignUp } = signUpSlice.actions;
|
|
55
|
-
export const selectSignUp = (state) => state.signUp;
|
|
56
|
-
export const signUpReducer = signUpSlice.reducer;
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
|
|
3
|
+
import { ReducerType } from './types';
|
|
4
|
+
import { fetchCustomer, loginCustomer, setCustomerAuth } from './customer';
|
|
5
|
+
const initialState = {
|
|
6
|
+
loading: 'idle',
|
|
7
|
+
error: null
|
|
8
|
+
};
|
|
9
|
+
export var SignUpActionType;
|
|
10
|
+
(function (SignUpActionType) {
|
|
11
|
+
SignUpActionType["SignUpCustomer"] = "signUp/signUpCustomer";
|
|
12
|
+
})(SignUpActionType || (SignUpActionType = {}));
|
|
13
|
+
export const signUpCustomer = createAsyncThunk(SignUpActionType.SignUpCustomer, ({ data, callback }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
+
try {
|
|
15
|
+
const { api, brand } = getState().config;
|
|
16
|
+
const response = yield api.postSignUp(data);
|
|
17
|
+
const { email, password } = data;
|
|
18
|
+
if (email && password) {
|
|
19
|
+
if ((brand === null || brand === void 0 ? void 0 : brand.tpls) && (brand === null || brand === void 0 ? void 0 : brand.tpls) !== 'SPARKFLY') {
|
|
20
|
+
const resp = yield api.postCustomerSignIn(data);
|
|
21
|
+
dispatch(setCustomerAuth(resp));
|
|
22
|
+
yield dispatch(fetchCustomer());
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
dispatch(loginCustomer({ email, password }));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
if (callback)
|
|
29
|
+
callback(response);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
return rejectWithValue(err);
|
|
34
|
+
}
|
|
35
|
+
}));
|
|
36
|
+
const signUpSlice = createSlice({
|
|
37
|
+
name: ReducerType.SignUp,
|
|
38
|
+
initialState,
|
|
39
|
+
reducers: {
|
|
40
|
+
resetSignUp: () => initialState
|
|
41
|
+
},
|
|
42
|
+
extraReducers: builder => {
|
|
43
|
+
builder
|
|
44
|
+
.addCase(signUpCustomer.fulfilled, () => initialState)
|
|
45
|
+
.addCase(signUpCustomer.pending, state => {
|
|
46
|
+
state.loading = 'pending';
|
|
47
|
+
})
|
|
48
|
+
.addCase(signUpCustomer.rejected, (state, action) => {
|
|
49
|
+
state.loading = 'idle';
|
|
50
|
+
state.error = action.payload;
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
export const { resetSignUp } = signUpSlice.actions;
|
|
55
|
+
export const selectSignUp = (state) => state.signUp;
|
|
56
|
+
export const signUpReducer = signUpSlice.reducer;
|
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
import { AppState } from '../app';
|
|
2
|
-
import { TagLookupEnhanced, Tags, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
-
export interface TagsState {
|
|
4
|
-
entities: Tags;
|
|
5
|
-
error: RequestError;
|
|
6
|
-
loading: RequestStatus;
|
|
7
|
-
selectedTags: Tags;
|
|
8
|
-
lookup: TagLookupEnhanced;
|
|
9
|
-
}
|
|
10
|
-
export declare enum TagsActionType {
|
|
11
|
-
FetchTags = "tags/fetchTags"
|
|
12
|
-
}
|
|
13
|
-
export interface TagsPayload {
|
|
14
|
-
data: Tags;
|
|
15
|
-
lookup: TagLookupEnhanced;
|
|
16
|
-
}
|
|
17
|
-
export declare const fetchTags: import("@reduxjs/toolkit").AsyncThunk<TagsPayload, void, {
|
|
18
|
-
state: AppState;
|
|
19
|
-
rejectValue: RequestError;
|
|
20
|
-
dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
|
|
21
|
-
extra?: unknown;
|
|
22
|
-
serializedErrorType?: unknown;
|
|
23
|
-
pendingMeta?: unknown;
|
|
24
|
-
fulfilledMeta?: unknown;
|
|
25
|
-
rejectedMeta?: unknown;
|
|
26
|
-
}>;
|
|
27
|
-
export declare const resetTags: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"tags/resetTags">, setSelectedTags: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "tags/setSelectedTags">, toggleTag: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "tags/toggleTag">;
|
|
28
|
-
export declare const selectTags: (state: AppState) => TagsState;
|
|
29
|
-
export declare const selectSelectedTags: (state: AppState) => Tags;
|
|
30
|
-
export declare const selectSelectedTagNames: ((state: import("redux").EmptyObject & {
|
|
31
|
-
alerts: import("@open-tender/types").Alerts;
|
|
32
|
-
allergens: import("./allergens").AllergensState;
|
|
33
|
-
announcements: import("./announcements").AnnouncementsState;
|
|
34
|
-
checkout: import("./checkout").CheckoutState;
|
|
35
|
-
completedOrders: import("./completedOrders").CompletedOrdersState;
|
|
36
|
-
config: import("./config").ConfigState;
|
|
37
|
-
confirmation: import("./confirmation").ConfirmationState;
|
|
38
|
-
customer: import("redux").CombinedState<{
|
|
39
|
-
account: import("./customer").AccountState;
|
|
40
|
-
communicationPreferences: import("./customer").CustomerCommunicationPrefsState;
|
|
41
|
-
creditCards: import("./customer").CustomerCreditCardsState;
|
|
42
|
-
allergens: import("./customer").CustomerAllergensState;
|
|
43
|
-
addresses: import("./customer").CustomerAddressesState;
|
|
44
|
-
favorites: import("./customer").CustomerFavoritesState;
|
|
45
|
-
fcmToken: import("./customer").CustomerFcmTokenState;
|
|
46
|
-
giftCards: import("./customer").CustomerGiftCardsState;
|
|
47
|
-
groupOrders: import("./customer").CustomerGroupOrdersState;
|
|
48
|
-
history: import("./customer").CustomerHistoryState;
|
|
49
|
-
houseAccounts: import("./customer").CustomerHouseAccountsState;
|
|
50
|
-
loyalty: import("./customer").CustomerLoyaltyState;
|
|
51
|
-
order: import("./customer").CustomerOrderState;
|
|
52
|
-
orders: import("./customer").CustomerOrdersState;
|
|
53
|
-
pointsShop: import("./customer").PointsShopState;
|
|
54
|
-
tplsPointsShop: import("./customer").TplsPointsShopState;
|
|
55
|
-
qrcode: import("./customer").CustomerQRCodeState;
|
|
56
|
-
rewards: import("./customer").CustomerRewardsState;
|
|
57
|
-
thanx: import("./customer").CustomerThanxState;
|
|
58
|
-
tpls: import("./customer").CustomerTplsState;
|
|
59
|
-
}>;
|
|
60
|
-
deals: import("./deals").DealsState;
|
|
61
|
-
donations: import("./donations").DonationState;
|
|
62
|
-
geolocation: import("./geolocation").GeoLocationState;
|
|
63
|
-
giftCards: import("./giftCards").GiftCardsState;
|
|
64
|
-
groupOrder: import("./groupOrder").GroupOrderState;
|
|
65
|
-
guest: import("./guest").GuestState;
|
|
66
|
-
loader: import("./loader").LoaderState;
|
|
67
|
-
menu: import("./menu").MenuState;
|
|
68
|
-
menuDisplay: import("./menuDisplay").MenuDisplayState;
|
|
69
|
-
menuItems: import("./menuItems").MenuItemsState;
|
|
70
|
-
modal: import("@open-tender/types").Modal;
|
|
71
|
-
misc: import("./misc").MiscState;
|
|
72
|
-
nav: import("./nav").NavState;
|
|
73
|
-
navSite: import("./navSite").NavSiteState;
|
|
74
|
-
notifications: import("@open-tender/types").Notifications;
|
|
75
|
-
oneTimePasscode: import("./oneTimePasscode").OneTimePasscodeState;
|
|
76
|
-
order: import("./order").OrderState;
|
|
77
|
-
orderFulfillment: import("./orderFulfillment").OrderFulfillmentState;
|
|
78
|
-
orderRating: import("./orderRating").OrderRatingState;
|
|
79
|
-
posts: import("./posts").PostsSlice;
|
|
80
|
-
pushNotifications: import("./pushNotifications").PushNotificationsState;
|
|
81
|
-
qr: import("./qr").QrState;
|
|
82
|
-
quote: import("./quote").QuoteState;
|
|
83
|
-
resetPassword: import("./resetPassword").ResetPasswordState;
|
|
84
|
-
revenueCenters: import("./revenueCenters").RevenueCentersState;
|
|
85
|
-
sidebar: import("./sidebar").SidebarState;
|
|
86
|
-
sidebarModal: import("./sidebarModal").SidebarModalState;
|
|
87
|
-
signUp: import("./signUp").SignUpState;
|
|
88
|
-
tags: TagsState;
|
|
89
|
-
terms: import("./terms").TermsSlice;
|
|
90
|
-
Unsubscribe: import("./unsubscribe").UnsubscribeState;
|
|
91
|
-
validTimes: import("./validTimes").ValidTimesState;
|
|
92
|
-
verifyAccount: import("./verifyAccount").VerifyAccountState;
|
|
93
|
-
}) => string[]) & import("reselect").OutputSelectorFields<(args_0: {
|
|
94
|
-
tags: Tags;
|
|
95
|
-
selectedTags: Tags;
|
|
96
|
-
}) => string[], {
|
|
97
|
-
clearCache: () => void;
|
|
98
|
-
}> & {
|
|
99
|
-
clearCache: () => void;
|
|
100
|
-
};
|
|
101
|
-
export declare const tagsReducer: import("redux").Reducer<TagsState, import("redux").AnyAction>;
|
|
1
|
+
import { AppState } from '../app';
|
|
2
|
+
import { TagLookupEnhanced, Tags, RequestError, RequestStatus } from '@open-tender/types';
|
|
3
|
+
export interface TagsState {
|
|
4
|
+
entities: Tags;
|
|
5
|
+
error: RequestError;
|
|
6
|
+
loading: RequestStatus;
|
|
7
|
+
selectedTags: Tags;
|
|
8
|
+
lookup: TagLookupEnhanced;
|
|
9
|
+
}
|
|
10
|
+
export declare enum TagsActionType {
|
|
11
|
+
FetchTags = "tags/fetchTags"
|
|
12
|
+
}
|
|
13
|
+
export interface TagsPayload {
|
|
14
|
+
data: Tags;
|
|
15
|
+
lookup: TagLookupEnhanced;
|
|
16
|
+
}
|
|
17
|
+
export declare const fetchTags: import("@reduxjs/toolkit").AsyncThunk<TagsPayload, void, {
|
|
18
|
+
state: AppState;
|
|
19
|
+
rejectValue: RequestError;
|
|
20
|
+
dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
|
|
21
|
+
extra?: unknown;
|
|
22
|
+
serializedErrorType?: unknown;
|
|
23
|
+
pendingMeta?: unknown;
|
|
24
|
+
fulfilledMeta?: unknown;
|
|
25
|
+
rejectedMeta?: unknown;
|
|
26
|
+
}>;
|
|
27
|
+
export declare const resetTags: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"tags/resetTags">, setSelectedTags: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "tags/setSelectedTags">, toggleTag: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "tags/toggleTag">;
|
|
28
|
+
export declare const selectTags: (state: AppState) => TagsState;
|
|
29
|
+
export declare const selectSelectedTags: (state: AppState) => Tags;
|
|
30
|
+
export declare const selectSelectedTagNames: ((state: import("redux").EmptyObject & {
|
|
31
|
+
alerts: import("@open-tender/types").Alerts;
|
|
32
|
+
allergens: import("./allergens").AllergensState;
|
|
33
|
+
announcements: import("./announcements").AnnouncementsState;
|
|
34
|
+
checkout: import("./checkout").CheckoutState;
|
|
35
|
+
completedOrders: import("./completedOrders").CompletedOrdersState;
|
|
36
|
+
config: import("./config").ConfigState;
|
|
37
|
+
confirmation: import("./confirmation").ConfirmationState;
|
|
38
|
+
customer: import("redux").CombinedState<{
|
|
39
|
+
account: import("./customer").AccountState;
|
|
40
|
+
communicationPreferences: import("./customer").CustomerCommunicationPrefsState;
|
|
41
|
+
creditCards: import("./customer").CustomerCreditCardsState;
|
|
42
|
+
allergens: import("./customer").CustomerAllergensState;
|
|
43
|
+
addresses: import("./customer").CustomerAddressesState;
|
|
44
|
+
favorites: import("./customer").CustomerFavoritesState;
|
|
45
|
+
fcmToken: import("./customer").CustomerFcmTokenState;
|
|
46
|
+
giftCards: import("./customer").CustomerGiftCardsState;
|
|
47
|
+
groupOrders: import("./customer").CustomerGroupOrdersState;
|
|
48
|
+
history: import("./customer").CustomerHistoryState;
|
|
49
|
+
houseAccounts: import("./customer").CustomerHouseAccountsState;
|
|
50
|
+
loyalty: import("./customer").CustomerLoyaltyState;
|
|
51
|
+
order: import("./customer").CustomerOrderState;
|
|
52
|
+
orders: import("./customer").CustomerOrdersState;
|
|
53
|
+
pointsShop: import("./customer").PointsShopState;
|
|
54
|
+
tplsPointsShop: import("./customer").TplsPointsShopState;
|
|
55
|
+
qrcode: import("./customer").CustomerQRCodeState;
|
|
56
|
+
rewards: import("./customer").CustomerRewardsState;
|
|
57
|
+
thanx: import("./customer").CustomerThanxState;
|
|
58
|
+
tpls: import("./customer").CustomerTplsState;
|
|
59
|
+
}>;
|
|
60
|
+
deals: import("./deals").DealsState;
|
|
61
|
+
donations: import("./donations").DonationState;
|
|
62
|
+
geolocation: import("./geolocation").GeoLocationState;
|
|
63
|
+
giftCards: import("./giftCards").GiftCardsState;
|
|
64
|
+
groupOrder: import("./groupOrder").GroupOrderState;
|
|
65
|
+
guest: import("./guest").GuestState;
|
|
66
|
+
loader: import("./loader").LoaderState;
|
|
67
|
+
menu: import("./menu").MenuState;
|
|
68
|
+
menuDisplay: import("./menuDisplay").MenuDisplayState;
|
|
69
|
+
menuItems: import("./menuItems").MenuItemsState;
|
|
70
|
+
modal: import("@open-tender/types").Modal;
|
|
71
|
+
misc: import("./misc").MiscState;
|
|
72
|
+
nav: import("./nav").NavState;
|
|
73
|
+
navSite: import("./navSite").NavSiteState;
|
|
74
|
+
notifications: import("@open-tender/types").Notifications;
|
|
75
|
+
oneTimePasscode: import("./oneTimePasscode").OneTimePasscodeState;
|
|
76
|
+
order: import("./order").OrderState;
|
|
77
|
+
orderFulfillment: import("./orderFulfillment").OrderFulfillmentState;
|
|
78
|
+
orderRating: import("./orderRating").OrderRatingState;
|
|
79
|
+
posts: import("./posts").PostsSlice;
|
|
80
|
+
pushNotifications: import("./pushNotifications").PushNotificationsState;
|
|
81
|
+
qr: import("./qr").QrState;
|
|
82
|
+
quote: import("./quote").QuoteState;
|
|
83
|
+
resetPassword: import("./resetPassword").ResetPasswordState;
|
|
84
|
+
revenueCenters: import("./revenueCenters").RevenueCentersState;
|
|
85
|
+
sidebar: import("./sidebar").SidebarState;
|
|
86
|
+
sidebarModal: import("./sidebarModal").SidebarModalState;
|
|
87
|
+
signUp: import("./signUp").SignUpState;
|
|
88
|
+
tags: TagsState;
|
|
89
|
+
terms: import("./terms").TermsSlice;
|
|
90
|
+
Unsubscribe: import("./unsubscribe").UnsubscribeState;
|
|
91
|
+
validTimes: import("./validTimes").ValidTimesState;
|
|
92
|
+
verifyAccount: import("./verifyAccount").VerifyAccountState;
|
|
93
|
+
}) => string[]) & import("reselect").OutputSelectorFields<(args_0: {
|
|
94
|
+
tags: Tags;
|
|
95
|
+
selectedTags: Tags;
|
|
96
|
+
}) => string[], {
|
|
97
|
+
clearCache: () => void;
|
|
98
|
+
}> & {
|
|
99
|
+
clearCache: () => void;
|
|
100
|
+
};
|
|
101
|
+
export declare const tagsReducer: import("redux").Reducer<TagsState, import("redux").AnyAction>;
|
package/dist/esm/slices/tags.js
CHANGED
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
import { __awaiter } from "tslib";
|
|
2
|
-
import { createAsyncThunk, createSelector, createSlice } from '@reduxjs/toolkit';
|
|
3
|
-
import { ReducerType } from './types';
|
|
4
|
-
import { makeImageMap } from '@open-tender/utils';
|
|
5
|
-
const makeTagLookup = (data) => {
|
|
6
|
-
return data.reduce((obj, i) => {
|
|
7
|
-
const imageMap = i.images ? makeImageMap(i.images) : {};
|
|
8
|
-
const imageUrl = imageMap.SMALL_IMAGE || imageMap.APP_IMAGE || imageMap.LARGE_IMAGE || '';
|
|
9
|
-
const tag = Object.assign(Object.assign({}, i), { imageUrl });
|
|
10
|
-
return Object.assign(Object.assign({}, obj), { [i.name]: tag });
|
|
11
|
-
}, {});
|
|
12
|
-
};
|
|
13
|
-
const initialState = {
|
|
14
|
-
entities: [],
|
|
15
|
-
error: null,
|
|
16
|
-
loading: 'idle',
|
|
17
|
-
selectedTags: [],
|
|
18
|
-
lookup: {}
|
|
19
|
-
};
|
|
20
|
-
export var TagsActionType;
|
|
21
|
-
(function (TagsActionType) {
|
|
22
|
-
TagsActionType["FetchTags"] = "tags/fetchTags";
|
|
23
|
-
})(TagsActionType || (TagsActionType = {}));
|
|
24
|
-
export const fetchTags = createAsyncThunk(TagsActionType.FetchTags, (_, { getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
-
try {
|
|
26
|
-
const api = getState().config.api;
|
|
27
|
-
const { data } = yield api.getTags();
|
|
28
|
-
const lookup = makeTagLookup(data);
|
|
29
|
-
return { data, lookup };
|
|
30
|
-
}
|
|
31
|
-
catch (err) {
|
|
32
|
-
return rejectWithValue(err);
|
|
33
|
-
}
|
|
34
|
-
}));
|
|
35
|
-
const tagsSlice = createSlice({
|
|
36
|
-
name: ReducerType.Tags,
|
|
37
|
-
initialState,
|
|
38
|
-
reducers: {
|
|
39
|
-
resetTags: () => initialState,
|
|
40
|
-
setSelectedTags: (state, action) => {
|
|
41
|
-
state.selectedTags = action.payload;
|
|
42
|
-
},
|
|
43
|
-
toggleTag: (state, action) => {
|
|
44
|
-
const tag = action.payload;
|
|
45
|
-
const exists = state.selectedTags.find(i => i.tag_id === tag.tag_id);
|
|
46
|
-
state.selectedTags = exists
|
|
47
|
-
? state.selectedTags.filter(i => i.tag_id !== tag.tag_id)
|
|
48
|
-
: [...state.selectedTags, tag];
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
extraReducers: builder => {
|
|
52
|
-
builder
|
|
53
|
-
.addCase(fetchTags.fulfilled, (state, action) => {
|
|
54
|
-
state.entities = action.payload.data;
|
|
55
|
-
state.lookup = action.payload.lookup;
|
|
56
|
-
state.loading = 'idle';
|
|
57
|
-
state.error = null;
|
|
58
|
-
})
|
|
59
|
-
.addCase(fetchTags.pending, state => {
|
|
60
|
-
state.loading = 'pending';
|
|
61
|
-
})
|
|
62
|
-
.addCase(fetchTags.rejected, (state, action) => {
|
|
63
|
-
state.error = action.payload;
|
|
64
|
-
state.loading = 'idle';
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
export const { resetTags, setSelectedTags, toggleTag } = tagsSlice.actions;
|
|
69
|
-
export const selectTags = (state) => state.tags;
|
|
70
|
-
export const selectSelectedTags = (state) => state.tags.selectedTags;
|
|
71
|
-
export const selectSelectedTagNames = createSelector((state) => {
|
|
72
|
-
const { entities: tags, selectedTags } = state.tags;
|
|
73
|
-
return { tags, selectedTags };
|
|
74
|
-
}, ({ tags, selectedTags }) => {
|
|
75
|
-
if (!selectedTags)
|
|
76
|
-
return [];
|
|
77
|
-
const selected = selectedTags.map(i => {
|
|
78
|
-
var _a;
|
|
79
|
-
const tag = tags.find(a => a.tag_id === i.tag_id);
|
|
80
|
-
return tag ? (_a = tag.name) !== null && _a !== void 0 ? _a : '' : '';
|
|
81
|
-
});
|
|
82
|
-
return selected;
|
|
83
|
-
});
|
|
84
|
-
export const tagsReducer = tagsSlice.reducer;
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { createAsyncThunk, createSelector, createSlice } from '@reduxjs/toolkit';
|
|
3
|
+
import { ReducerType } from './types';
|
|
4
|
+
import { makeImageMap } from '@open-tender/utils';
|
|
5
|
+
const makeTagLookup = (data) => {
|
|
6
|
+
return data.reduce((obj, i) => {
|
|
7
|
+
const imageMap = i.images ? makeImageMap(i.images) : {};
|
|
8
|
+
const imageUrl = imageMap.SMALL_IMAGE || imageMap.APP_IMAGE || imageMap.LARGE_IMAGE || '';
|
|
9
|
+
const tag = Object.assign(Object.assign({}, i), { imageUrl });
|
|
10
|
+
return Object.assign(Object.assign({}, obj), { [i.name]: tag });
|
|
11
|
+
}, {});
|
|
12
|
+
};
|
|
13
|
+
const initialState = {
|
|
14
|
+
entities: [],
|
|
15
|
+
error: null,
|
|
16
|
+
loading: 'idle',
|
|
17
|
+
selectedTags: [],
|
|
18
|
+
lookup: {}
|
|
19
|
+
};
|
|
20
|
+
export var TagsActionType;
|
|
21
|
+
(function (TagsActionType) {
|
|
22
|
+
TagsActionType["FetchTags"] = "tags/fetchTags";
|
|
23
|
+
})(TagsActionType || (TagsActionType = {}));
|
|
24
|
+
export const fetchTags = createAsyncThunk(TagsActionType.FetchTags, (_, { getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
try {
|
|
26
|
+
const api = getState().config.api;
|
|
27
|
+
const { data } = yield api.getTags();
|
|
28
|
+
const lookup = makeTagLookup(data);
|
|
29
|
+
return { data, lookup };
|
|
30
|
+
}
|
|
31
|
+
catch (err) {
|
|
32
|
+
return rejectWithValue(err);
|
|
33
|
+
}
|
|
34
|
+
}));
|
|
35
|
+
const tagsSlice = createSlice({
|
|
36
|
+
name: ReducerType.Tags,
|
|
37
|
+
initialState,
|
|
38
|
+
reducers: {
|
|
39
|
+
resetTags: () => initialState,
|
|
40
|
+
setSelectedTags: (state, action) => {
|
|
41
|
+
state.selectedTags = action.payload;
|
|
42
|
+
},
|
|
43
|
+
toggleTag: (state, action) => {
|
|
44
|
+
const tag = action.payload;
|
|
45
|
+
const exists = state.selectedTags.find(i => i.tag_id === tag.tag_id);
|
|
46
|
+
state.selectedTags = exists
|
|
47
|
+
? state.selectedTags.filter(i => i.tag_id !== tag.tag_id)
|
|
48
|
+
: [...state.selectedTags, tag];
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
extraReducers: builder => {
|
|
52
|
+
builder
|
|
53
|
+
.addCase(fetchTags.fulfilled, (state, action) => {
|
|
54
|
+
state.entities = action.payload.data;
|
|
55
|
+
state.lookup = action.payload.lookup;
|
|
56
|
+
state.loading = 'idle';
|
|
57
|
+
state.error = null;
|
|
58
|
+
})
|
|
59
|
+
.addCase(fetchTags.pending, state => {
|
|
60
|
+
state.loading = 'pending';
|
|
61
|
+
})
|
|
62
|
+
.addCase(fetchTags.rejected, (state, action) => {
|
|
63
|
+
state.error = action.payload;
|
|
64
|
+
state.loading = 'idle';
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
export const { resetTags, setSelectedTags, toggleTag } = tagsSlice.actions;
|
|
69
|
+
export const selectTags = (state) => state.tags;
|
|
70
|
+
export const selectSelectedTags = (state) => state.tags.selectedTags;
|
|
71
|
+
export const selectSelectedTagNames = createSelector((state) => {
|
|
72
|
+
const { entities: tags, selectedTags } = state.tags;
|
|
73
|
+
return { tags, selectedTags };
|
|
74
|
+
}, ({ tags, selectedTags }) => {
|
|
75
|
+
if (!selectedTags)
|
|
76
|
+
return [];
|
|
77
|
+
const selected = selectedTags.map(i => {
|
|
78
|
+
var _a;
|
|
79
|
+
const tag = tags.find(a => a.tag_id === i.tag_id);
|
|
80
|
+
return tag ? (_a = tag.name) !== null && _a !== void 0 ? _a : '' : '';
|
|
81
|
+
});
|
|
82
|
+
return selected;
|
|
83
|
+
});
|
|
84
|
+
export const tagsReducer = tagsSlice.reducer;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { RequestError, RequestStatus, TPLSTerms } from '@open-tender/types';
|
|
2
|
-
import { AppState } from '../app';
|
|
3
|
-
export interface TermsSlice {
|
|
4
|
-
terms: TPLSTerms | null;
|
|
5
|
-
loading: RequestStatus;
|
|
6
|
-
error: RequestError;
|
|
7
|
-
}
|
|
8
|
-
export declare const fetchTerms: import("@reduxjs/toolkit").AsyncThunk<TPLSTerms, void, {
|
|
9
|
-
state: AppState;
|
|
10
|
-
rejectValue: RequestError;
|
|
11
|
-
dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
|
|
12
|
-
extra?: unknown;
|
|
13
|
-
serializedErrorType?: unknown;
|
|
14
|
-
pendingMeta?: unknown;
|
|
15
|
-
fulfilledMeta?: unknown;
|
|
16
|
-
rejectedMeta?: unknown;
|
|
17
|
-
}>;
|
|
18
|
-
export declare const resetTerms: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"terms/resetTerms">;
|
|
19
|
-
export declare const selectTerms: (state: AppState) => TermsSlice;
|
|
20
|
-
export declare const termsReducer: import("redux").Reducer<TermsSlice, import("redux").AnyAction>;
|
|
1
|
+
import { RequestError, RequestStatus, TPLSTerms } from '@open-tender/types';
|
|
2
|
+
import { AppState } from '../app';
|
|
3
|
+
export interface TermsSlice {
|
|
4
|
+
terms: TPLSTerms | null;
|
|
5
|
+
loading: RequestStatus;
|
|
6
|
+
error: RequestError;
|
|
7
|
+
}
|
|
8
|
+
export declare const fetchTerms: import("@reduxjs/toolkit").AsyncThunk<TPLSTerms, void, {
|
|
9
|
+
state: AppState;
|
|
10
|
+
rejectValue: RequestError;
|
|
11
|
+
dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
|
|
12
|
+
extra?: unknown;
|
|
13
|
+
serializedErrorType?: unknown;
|
|
14
|
+
pendingMeta?: unknown;
|
|
15
|
+
fulfilledMeta?: unknown;
|
|
16
|
+
rejectedMeta?: unknown;
|
|
17
|
+
}>;
|
|
18
|
+
export declare const resetTerms: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"terms/resetTerms">;
|
|
19
|
+
export declare const selectTerms: (state: AppState) => TermsSlice;
|
|
20
|
+
export declare const termsReducer: import("redux").Reducer<TermsSlice, import("redux").AnyAction>;
|