@open-tender/cloud 0.1.85 → 0.1.87
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/dist/cjs/slices/checkout.d.ts +1 -1
- package/dist/cjs/slices/checkout.js +19 -4
- package/dist/cjs/slices/customer/loyalty.d.ts +71 -1
- package/dist/cjs/slices/customer/loyalty.js +4 -3
- package/dist/esm/slices/checkout.d.ts +1 -1
- package/dist/esm/slices/checkout.js +19 -4
- package/dist/esm/slices/customer/loyalty.d.ts +71 -1
- package/dist/esm/slices/customer/loyalty.js +4 -2
- package/package.json +1 -1
|
@@ -41,7 +41,7 @@ export declare const submitOrder: import("@reduxjs/toolkit").AsyncThunk<Order, v
|
|
|
41
41
|
}>;
|
|
42
42
|
export declare const submitOrderPay: import("@reduxjs/toolkit").AsyncThunk<Order | null, boolean | undefined, {
|
|
43
43
|
state: AppState;
|
|
44
|
-
rejectValue:
|
|
44
|
+
rejectValue: CheckoutErrorMessages;
|
|
45
45
|
dispatch?: Dispatch<import("redux").AnyAction> | undefined;
|
|
46
46
|
extra?: unknown;
|
|
47
47
|
serializedErrorType?: unknown;
|
|
@@ -152,14 +152,16 @@ exports.submitOrder = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.SubmitO
|
|
|
152
152
|
};
|
|
153
153
|
dispatch((0, order_1.setAlert)(alert));
|
|
154
154
|
const preparedOrder = assembleOrder(getState());
|
|
155
|
-
if (!preparedOrder)
|
|
155
|
+
if (!preparedOrder) {
|
|
156
156
|
return dispatch((0, order_1.setAlert)({ type: 'close' }));
|
|
157
|
+
}
|
|
157
158
|
try {
|
|
158
159
|
const completedOrder = yield api.postOrder(preparedOrder, token);
|
|
159
160
|
const auth = getState().customer.account.auth;
|
|
160
161
|
const { email, password } = preparedOrder.customer || {};
|
|
161
|
-
if (password && !auth)
|
|
162
|
+
if (password && !auth) {
|
|
162
163
|
yield dispatch((0, customer_1.loginCustomer)({ email: email, password }));
|
|
164
|
+
}
|
|
163
165
|
dispatch((0, order_1.setAlert)({ type: 'close' }));
|
|
164
166
|
return completedOrder;
|
|
165
167
|
}
|
|
@@ -183,14 +185,16 @@ exports.submitOrderPay = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.Subm
|
|
|
183
185
|
dispatch((0, order_1.setAlert)(alert));
|
|
184
186
|
}
|
|
185
187
|
const preparedOrder = assembleOrder(getState());
|
|
186
|
-
if (!preparedOrder)
|
|
188
|
+
if (!preparedOrder) {
|
|
187
189
|
return dispatch((0, order_1.setAlert)({ type: 'close' }));
|
|
190
|
+
}
|
|
188
191
|
try {
|
|
189
192
|
const completedOrder = yield api.postOrder(preparedOrder, token);
|
|
190
193
|
const auth = getState().customer.account.auth;
|
|
191
194
|
const { email, password } = preparedOrder.customer || {};
|
|
192
|
-
if (password && !auth)
|
|
195
|
+
if (password && !auth) {
|
|
193
196
|
yield dispatch((0, customer_1.loginCustomer)({ email: email, password }));
|
|
197
|
+
}
|
|
194
198
|
dispatch((0, order_1.setAlert)({ type: 'close' }));
|
|
195
199
|
return completedOrder;
|
|
196
200
|
}
|
|
@@ -278,6 +282,17 @@ const checkoutSlice = (0, toolkit_1.createSlice)({
|
|
|
278
282
|
state.loading = 'idle';
|
|
279
283
|
state.submitting = false;
|
|
280
284
|
state.errors = action.payload || {};
|
|
285
|
+
})
|
|
286
|
+
.addCase(exports.submitOrderPay.fulfilled, (_, action) => {
|
|
287
|
+
return Object.assign(Object.assign({}, initialState), { completedOrder: action.payload });
|
|
288
|
+
})
|
|
289
|
+
.addCase(exports.submitOrderPay.pending, state => {
|
|
290
|
+
state.loading = 'pending';
|
|
291
|
+
})
|
|
292
|
+
.addCase(exports.submitOrderPay.rejected, (state, action) => {
|
|
293
|
+
state.loading = 'idle';
|
|
294
|
+
state.submitting = false;
|
|
295
|
+
state.errors = action.payload || {};
|
|
281
296
|
});
|
|
282
297
|
}
|
|
283
298
|
});
|
|
@@ -23,10 +23,80 @@ export declare const fetchCustomerLoyalty: import("@reduxjs/toolkit").AsyncThunk
|
|
|
23
23
|
}>;
|
|
24
24
|
export declare const resetCustomerLoyalty: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"loyalty/resetCustomerLoyalty">, resetCustomerLoyaltyError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"loyalty/resetCustomerLoyaltyError">, setCustomerLoyalty: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "loyalty/setCustomerLoyalty">;
|
|
25
25
|
export declare const selectCustomerLoyalty: (state: AppState) => CustomerLoyaltyState;
|
|
26
|
-
export declare const selectCustomerLoyaltyProgram: (state:
|
|
26
|
+
export declare const selectCustomerLoyaltyProgram: ((state: import("redux").EmptyObject & {
|
|
27
|
+
alerts: import("@open-tender/types").Alerts;
|
|
28
|
+
allergens: import("..").AllergensState;
|
|
29
|
+
announcements: import("..").AnnouncementsState;
|
|
30
|
+
checkout: import("..").CheckoutState;
|
|
31
|
+
completedOrders: import("..").CompletedOrdersState;
|
|
32
|
+
config: import("..").ConfigState;
|
|
33
|
+
confirmation: import("..").ConfirmationState;
|
|
34
|
+
customer: import("redux").CombinedState<{
|
|
35
|
+
account: import("./account").AccountState;
|
|
36
|
+
communicationPreferences: import("./communicationPreferences").CustomerCommunicationPrefsState;
|
|
37
|
+
creditCards: import("./creditCards").CustomerCreditCardsState;
|
|
38
|
+
allergens: import("./allergens").CustomerAllergensState;
|
|
39
|
+
addresses: import("./addresses").CustomerAddressesState;
|
|
40
|
+
favorites: import("./favorites").CustomerFavoritesState;
|
|
41
|
+
fcmToken: import("./fcmToken").CustomerFcmTokenState;
|
|
42
|
+
giftCards: import("./giftCards").CustomerGiftCardsState;
|
|
43
|
+
groupOrders: import("./groupOrders").CustomerGroupOrdersState;
|
|
44
|
+
houseAccounts: import("./houseAccounts").CustomerHouseAccountsState;
|
|
45
|
+
loyalty: CustomerLoyaltyState;
|
|
46
|
+
order: import("./order").CustomerOrderState;
|
|
47
|
+
orders: import("./orders").CustomerOrdersState;
|
|
48
|
+
pointsShop: import("./pointsShop").PointsShopState;
|
|
49
|
+
qrcode: import("./qrCode").CustomerQRCodeState;
|
|
50
|
+
rewards: import("./rewards").CustomerRewardsState;
|
|
51
|
+
thanx: import("./thanx").CustomerThanxState;
|
|
52
|
+
tpls: import("./tpls").CustomerTplsState;
|
|
53
|
+
}>;
|
|
54
|
+
deals: import("..").DealsState;
|
|
55
|
+
donations: import("..").DonationState;
|
|
56
|
+
geolocation: import("..").GeoLocationState;
|
|
57
|
+
giftCards: import("..").GiftCardsState;
|
|
58
|
+
groupOrder: import("..").GroupOrderState;
|
|
59
|
+
guest: import("..").GuestState;
|
|
60
|
+
loader: import("..").LoaderState;
|
|
61
|
+
menu: import("..").MenuState;
|
|
62
|
+
menuDisplay: import("..").MenuDisplayState;
|
|
63
|
+
menuItems: import("..").MenuItemsState;
|
|
64
|
+
modal: import("@open-tender/types").Modal;
|
|
65
|
+
misc: import("..").MiscState;
|
|
66
|
+
nav: import("..").NavState;
|
|
67
|
+
navSite: import("..").NavSiteState;
|
|
68
|
+
notifications: import("@open-tender/types").Notifications;
|
|
69
|
+
oneTimePasscode: import("..").OneTimePasscodeState;
|
|
70
|
+
order: import("..").OrderState;
|
|
71
|
+
orderFulfillment: import("..").OrderFulfillmentState;
|
|
72
|
+
orderRating: import("..").OrderRatingState;
|
|
73
|
+
posts: import("..").PostsSlice;
|
|
74
|
+
qr: import("..").QrState;
|
|
75
|
+
resetPassword: import("..").ResetPasswordState;
|
|
76
|
+
revenueCenters: import("..").RevenueCentersState;
|
|
77
|
+
sidebar: import("..").SidebarState;
|
|
78
|
+
sidebarModal: import("..").SidebarModalState;
|
|
79
|
+
signUp: import("..").SignUpState;
|
|
80
|
+
tags: import("..").TagsState;
|
|
81
|
+
terms: import("..").TermsSlice;
|
|
82
|
+
validTimes: import("..").ValidTimesState;
|
|
83
|
+
verifyAccount: import("..").VerifyAccountState;
|
|
84
|
+
}) => {
|
|
85
|
+
program: import("@open-tender/types").CustomerLoyalty | null;
|
|
86
|
+
loading: RequestStatus;
|
|
87
|
+
error: RequestError;
|
|
88
|
+
}) & import("reselect").OutputSelectorFields<(args_0: {
|
|
89
|
+
entities: CustomerLoyalties;
|
|
90
|
+
loading: RequestStatus;
|
|
91
|
+
error: RequestError;
|
|
92
|
+
}) => {
|
|
27
93
|
program: import("@open-tender/types").CustomerLoyalty | null;
|
|
28
94
|
loading: RequestStatus;
|
|
29
95
|
error: RequestError;
|
|
96
|
+
}, {
|
|
97
|
+
clearCache: () => void;
|
|
98
|
+
}> & {
|
|
99
|
+
clearCache: () => void;
|
|
30
100
|
};
|
|
31
101
|
export declare const selectCustomerPointsProgram: (orderType: OrderType | null) => ((state: import("redux").EmptyObject & {
|
|
32
102
|
alerts: import("@open-tender/types").Alerts;
|
|
@@ -64,14 +64,15 @@ const customerLoyaltySlice = (0, toolkit_1.createSlice)({
|
|
|
64
64
|
_a = customerLoyaltySlice.actions, exports.resetCustomerLoyalty = _a.resetCustomerLoyalty, exports.resetCustomerLoyaltyError = _a.resetCustomerLoyaltyError, exports.setCustomerLoyalty = _a.setCustomerLoyalty;
|
|
65
65
|
const selectCustomerLoyalty = (state) => state.customer.loyalty;
|
|
66
66
|
exports.selectCustomerLoyalty = selectCustomerLoyalty;
|
|
67
|
-
|
|
67
|
+
exports.selectCustomerLoyaltyProgram = (0, toolkit_1.createSelector)((state) => {
|
|
68
68
|
const { entities, loading, error } = state.customer.loyalty;
|
|
69
|
+
return { entities, loading, error };
|
|
70
|
+
}, ({ entities, loading, error }) => {
|
|
69
71
|
const programs = entities.filter(i => (i.loyalty_type === 'CREDIT' || i.loyalty_type === 'POINTS') &&
|
|
70
72
|
(i.spend.order_type === null || i.spend.order_type === 'OLO'));
|
|
71
73
|
const program = programs.length ? programs[0] : null;
|
|
72
74
|
return { program, loading, error };
|
|
73
|
-
};
|
|
74
|
-
exports.selectCustomerLoyaltyProgram = selectCustomerLoyaltyProgram;
|
|
75
|
+
});
|
|
75
76
|
const selectCustomerPointsProgram = (orderType) => (0, toolkit_1.createSelector)((state) => {
|
|
76
77
|
const { loyalty } = state.customer;
|
|
77
78
|
return { loyalty };
|
|
@@ -41,7 +41,7 @@ export declare const submitOrder: import("@reduxjs/toolkit").AsyncThunk<Order, v
|
|
|
41
41
|
}>;
|
|
42
42
|
export declare const submitOrderPay: import("@reduxjs/toolkit").AsyncThunk<Order | null, boolean | undefined, {
|
|
43
43
|
state: AppState;
|
|
44
|
-
rejectValue:
|
|
44
|
+
rejectValue: CheckoutErrorMessages;
|
|
45
45
|
dispatch?: Dispatch<import("redux").AnyAction> | undefined;
|
|
46
46
|
extra?: unknown;
|
|
47
47
|
serializedErrorType?: unknown;
|
|
@@ -148,14 +148,16 @@ export const submitOrder = createAsyncThunk(CheckoutActionType.SubmitOrder, (_,
|
|
|
148
148
|
};
|
|
149
149
|
dispatch(setAlert(alert));
|
|
150
150
|
const preparedOrder = assembleOrder(getState());
|
|
151
|
-
if (!preparedOrder)
|
|
151
|
+
if (!preparedOrder) {
|
|
152
152
|
return dispatch(setAlert({ type: 'close' }));
|
|
153
|
+
}
|
|
153
154
|
try {
|
|
154
155
|
const completedOrder = yield api.postOrder(preparedOrder, token);
|
|
155
156
|
const auth = getState().customer.account.auth;
|
|
156
157
|
const { email, password } = preparedOrder.customer || {};
|
|
157
|
-
if (password && !auth)
|
|
158
|
+
if (password && !auth) {
|
|
158
159
|
yield dispatch(loginCustomer({ email: email, password }));
|
|
160
|
+
}
|
|
159
161
|
dispatch(setAlert({ type: 'close' }));
|
|
160
162
|
return completedOrder;
|
|
161
163
|
}
|
|
@@ -179,14 +181,16 @@ export const submitOrderPay = createAsyncThunk(CheckoutActionType.SubmitOrderPay
|
|
|
179
181
|
dispatch(setAlert(alert));
|
|
180
182
|
}
|
|
181
183
|
const preparedOrder = assembleOrder(getState());
|
|
182
|
-
if (!preparedOrder)
|
|
184
|
+
if (!preparedOrder) {
|
|
183
185
|
return dispatch(setAlert({ type: 'close' }));
|
|
186
|
+
}
|
|
184
187
|
try {
|
|
185
188
|
const completedOrder = yield api.postOrder(preparedOrder, token);
|
|
186
189
|
const auth = getState().customer.account.auth;
|
|
187
190
|
const { email, password } = preparedOrder.customer || {};
|
|
188
|
-
if (password && !auth)
|
|
191
|
+
if (password && !auth) {
|
|
189
192
|
yield dispatch(loginCustomer({ email: email, password }));
|
|
193
|
+
}
|
|
190
194
|
dispatch(setAlert({ type: 'close' }));
|
|
191
195
|
return completedOrder;
|
|
192
196
|
}
|
|
@@ -274,6 +278,17 @@ const checkoutSlice = createSlice({
|
|
|
274
278
|
state.loading = 'idle';
|
|
275
279
|
state.submitting = false;
|
|
276
280
|
state.errors = action.payload || {};
|
|
281
|
+
})
|
|
282
|
+
.addCase(submitOrderPay.fulfilled, (_, action) => {
|
|
283
|
+
return Object.assign(Object.assign({}, initialState), { completedOrder: action.payload });
|
|
284
|
+
})
|
|
285
|
+
.addCase(submitOrderPay.pending, state => {
|
|
286
|
+
state.loading = 'pending';
|
|
287
|
+
})
|
|
288
|
+
.addCase(submitOrderPay.rejected, (state, action) => {
|
|
289
|
+
state.loading = 'idle';
|
|
290
|
+
state.submitting = false;
|
|
291
|
+
state.errors = action.payload || {};
|
|
277
292
|
});
|
|
278
293
|
}
|
|
279
294
|
});
|
|
@@ -23,10 +23,80 @@ export declare const fetchCustomerLoyalty: import("@reduxjs/toolkit").AsyncThunk
|
|
|
23
23
|
}>;
|
|
24
24
|
export declare const resetCustomerLoyalty: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"loyalty/resetCustomerLoyalty">, resetCustomerLoyaltyError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"loyalty/resetCustomerLoyaltyError">, setCustomerLoyalty: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, "loyalty/setCustomerLoyalty">;
|
|
25
25
|
export declare const selectCustomerLoyalty: (state: AppState) => CustomerLoyaltyState;
|
|
26
|
-
export declare const selectCustomerLoyaltyProgram: (state:
|
|
26
|
+
export declare const selectCustomerLoyaltyProgram: ((state: import("redux").EmptyObject & {
|
|
27
|
+
alerts: import("@open-tender/types").Alerts;
|
|
28
|
+
allergens: import("..").AllergensState;
|
|
29
|
+
announcements: import("..").AnnouncementsState;
|
|
30
|
+
checkout: import("..").CheckoutState;
|
|
31
|
+
completedOrders: import("..").CompletedOrdersState;
|
|
32
|
+
config: import("..").ConfigState;
|
|
33
|
+
confirmation: import("..").ConfirmationState;
|
|
34
|
+
customer: import("redux").CombinedState<{
|
|
35
|
+
account: import("./account").AccountState;
|
|
36
|
+
communicationPreferences: import("./communicationPreferences").CustomerCommunicationPrefsState;
|
|
37
|
+
creditCards: import("./creditCards").CustomerCreditCardsState;
|
|
38
|
+
allergens: import("./allergens").CustomerAllergensState;
|
|
39
|
+
addresses: import("./addresses").CustomerAddressesState;
|
|
40
|
+
favorites: import("./favorites").CustomerFavoritesState;
|
|
41
|
+
fcmToken: import("./fcmToken").CustomerFcmTokenState;
|
|
42
|
+
giftCards: import("./giftCards").CustomerGiftCardsState;
|
|
43
|
+
groupOrders: import("./groupOrders").CustomerGroupOrdersState;
|
|
44
|
+
houseAccounts: import("./houseAccounts").CustomerHouseAccountsState;
|
|
45
|
+
loyalty: CustomerLoyaltyState;
|
|
46
|
+
order: import("./order").CustomerOrderState;
|
|
47
|
+
orders: import("./orders").CustomerOrdersState;
|
|
48
|
+
pointsShop: import("./pointsShop").PointsShopState;
|
|
49
|
+
qrcode: import("./qrCode").CustomerQRCodeState;
|
|
50
|
+
rewards: import("./rewards").CustomerRewardsState;
|
|
51
|
+
thanx: import("./thanx").CustomerThanxState;
|
|
52
|
+
tpls: import("./tpls").CustomerTplsState;
|
|
53
|
+
}>;
|
|
54
|
+
deals: import("..").DealsState;
|
|
55
|
+
donations: import("..").DonationState;
|
|
56
|
+
geolocation: import("..").GeoLocationState;
|
|
57
|
+
giftCards: import("..").GiftCardsState;
|
|
58
|
+
groupOrder: import("..").GroupOrderState;
|
|
59
|
+
guest: import("..").GuestState;
|
|
60
|
+
loader: import("..").LoaderState;
|
|
61
|
+
menu: import("..").MenuState;
|
|
62
|
+
menuDisplay: import("..").MenuDisplayState;
|
|
63
|
+
menuItems: import("..").MenuItemsState;
|
|
64
|
+
modal: import("@open-tender/types").Modal;
|
|
65
|
+
misc: import("..").MiscState;
|
|
66
|
+
nav: import("..").NavState;
|
|
67
|
+
navSite: import("..").NavSiteState;
|
|
68
|
+
notifications: import("@open-tender/types").Notifications;
|
|
69
|
+
oneTimePasscode: import("..").OneTimePasscodeState;
|
|
70
|
+
order: import("..").OrderState;
|
|
71
|
+
orderFulfillment: import("..").OrderFulfillmentState;
|
|
72
|
+
orderRating: import("..").OrderRatingState;
|
|
73
|
+
posts: import("..").PostsSlice;
|
|
74
|
+
qr: import("..").QrState;
|
|
75
|
+
resetPassword: import("..").ResetPasswordState;
|
|
76
|
+
revenueCenters: import("..").RevenueCentersState;
|
|
77
|
+
sidebar: import("..").SidebarState;
|
|
78
|
+
sidebarModal: import("..").SidebarModalState;
|
|
79
|
+
signUp: import("..").SignUpState;
|
|
80
|
+
tags: import("..").TagsState;
|
|
81
|
+
terms: import("..").TermsSlice;
|
|
82
|
+
validTimes: import("..").ValidTimesState;
|
|
83
|
+
verifyAccount: import("..").VerifyAccountState;
|
|
84
|
+
}) => {
|
|
85
|
+
program: import("@open-tender/types").CustomerLoyalty | null;
|
|
86
|
+
loading: RequestStatus;
|
|
87
|
+
error: RequestError;
|
|
88
|
+
}) & import("reselect").OutputSelectorFields<(args_0: {
|
|
89
|
+
entities: CustomerLoyalties;
|
|
90
|
+
loading: RequestStatus;
|
|
91
|
+
error: RequestError;
|
|
92
|
+
}) => {
|
|
27
93
|
program: import("@open-tender/types").CustomerLoyalty | null;
|
|
28
94
|
loading: RequestStatus;
|
|
29
95
|
error: RequestError;
|
|
96
|
+
}, {
|
|
97
|
+
clearCache: () => void;
|
|
98
|
+
}> & {
|
|
99
|
+
clearCache: () => void;
|
|
30
100
|
};
|
|
31
101
|
export declare const selectCustomerPointsProgram: (orderType: OrderType | null) => ((state: import("redux").EmptyObject & {
|
|
32
102
|
alerts: import("@open-tender/types").Alerts;
|
|
@@ -59,13 +59,15 @@ const customerLoyaltySlice = createSlice({
|
|
|
59
59
|
});
|
|
60
60
|
export const { resetCustomerLoyalty, resetCustomerLoyaltyError, setCustomerLoyalty } = customerLoyaltySlice.actions;
|
|
61
61
|
export const selectCustomerLoyalty = (state) => state.customer.loyalty;
|
|
62
|
-
export const selectCustomerLoyaltyProgram = (state) => {
|
|
62
|
+
export const selectCustomerLoyaltyProgram = createSelector((state) => {
|
|
63
63
|
const { entities, loading, error } = state.customer.loyalty;
|
|
64
|
+
return { entities, loading, error };
|
|
65
|
+
}, ({ entities, loading, error }) => {
|
|
64
66
|
const programs = entities.filter(i => (i.loyalty_type === 'CREDIT' || i.loyalty_type === 'POINTS') &&
|
|
65
67
|
(i.spend.order_type === null || i.spend.order_type === 'OLO'));
|
|
66
68
|
const program = programs.length ? programs[0] : null;
|
|
67
69
|
return { program, loading, error };
|
|
68
|
-
};
|
|
70
|
+
});
|
|
69
71
|
export const selectCustomerPointsProgram = (orderType) => createSelector((state) => {
|
|
70
72
|
const { loyalty } = state.customer;
|
|
71
73
|
return { loyalty };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-tender/cloud",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.87",
|
|
4
4
|
"description": "A library of hooks, reducers, utility functions, and types for use with Open Tender applications that utilize our cloud-based Order API.",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|