@open-tender/cloud 0.1.93 → 0.1.95

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.
@@ -11,7 +11,6 @@ export interface CheckoutState {
11
11
  loading: RequestStatus;
12
12
  }
13
13
  export declare enum CheckoutActionType {
14
- FetchCheckout = "checkout/fetchCheckout",
15
14
  ValidateOrder = "checkout/validateOrder",
16
15
  SubmitOrder = "checkout/SubmitOrder",
17
16
  SubmitOrderPay = "checkout/SubmitOrderPay"
@@ -30,7 +30,6 @@ const initialState = {
30
30
  };
31
31
  var CheckoutActionType;
32
32
  (function (CheckoutActionType) {
33
- CheckoutActionType["FetchCheckout"] = "checkout/fetchCheckout";
34
33
  CheckoutActionType["ValidateOrder"] = "checkout/validateOrder";
35
34
  CheckoutActionType["SubmitOrder"] = "checkout/SubmitOrder";
36
35
  CheckoutActionType["SubmitOrderPay"] = "checkout/SubmitOrderPay";
@@ -99,7 +98,7 @@ const handleOrderErrors = (err, preparedOrder, dispatch) => {
99
98
  return errors;
100
99
  }
101
100
  };
102
- exports.validateOrder = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.FetchCheckout, (order, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
101
+ exports.validateOrder = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.ValidateOrder, (order, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
103
102
  try {
104
103
  const { api } = getState().config;
105
104
  const token = (0, customer_1.selectToken)(getState());
@@ -159,9 +159,9 @@ exports.reopenGroupOrder = (0, toolkit_1.createAsyncThunk)(CustomerGroupOrdersAc
159
159
  const { cart: customerCart } = (0, utils_1.rehydrateCart)(menuItems, items);
160
160
  dispatch((0, order_1.setCart)(customerCart));
161
161
  const payload = Object.assign(Object.assign({}, (0, groupOrder_1.makeCartPayload)(response)), { isCartOwner: true, cartOwner: customer });
162
+ dispatch((0, groupOrder_1.adjustGroupOrder)(payload));
162
163
  dispatch((0, notifications_1.showNotification)('Group order reopened!'));
163
164
  dispatch((0, order_1.setAlert)({ type: 'groupOrder' }));
164
- return payload;
165
165
  }
166
166
  catch (err) {
167
167
  dispatch((0, order_1.resetAlert)());
@@ -222,8 +222,9 @@ const customerGroupOrdersSlice = (0, toolkit_1.createSlice)({
222
222
  state.error = action.payload;
223
223
  state.loading = 'idle';
224
224
  })
225
- .addCase(exports.reopenGroupOrder.fulfilled, (state, action) => {
226
- return Object.assign(Object.assign(Object.assign({}, state), action.payload), { loading: 'idle', error: null });
225
+ .addCase(exports.reopenGroupOrder.fulfilled, state => {
226
+ state.error = null;
227
+ state.loading = 'idle';
227
228
  })
228
229
  .addCase(exports.reopenGroupOrder.pending, state => {
229
230
  state.loading = 'pending';
@@ -157,7 +157,7 @@ export declare const selectCustomerPointsProgram: (orderType: OrderType | null)
157
157
  validTimes: import("..").ValidTimesState;
158
158
  verifyAccount: import("..").VerifyAccountState;
159
159
  }) => import("@open-tender/types").CustomerLoyalty | null) & import("reselect").OutputSelectorFields<(args_0: {
160
- loyalty: CustomerLoyaltyState;
160
+ loyaltyPrograms: CustomerLoyalties;
161
161
  }) => import("@open-tender/types").CustomerLoyalty | null, {
162
162
  clearCache: () => void;
163
163
  }> & {
@@ -75,11 +75,12 @@ exports.selectCustomerLoyaltyProgram = (0, toolkit_1.createSelector)((state) =>
75
75
  });
76
76
  const selectCustomerPointsProgram = (orderType) => (0, toolkit_1.createSelector)((state) => {
77
77
  const { loyalty } = state.customer;
78
- return { loyalty };
79
- }, ({ loyalty }) => {
80
- if (!loyalty)
78
+ const { entities: loyaltyPrograms } = loyalty;
79
+ return { loyaltyPrograms };
80
+ }, ({ loyaltyPrograms }) => {
81
+ if (!loyaltyPrograms)
81
82
  return null;
82
- const programs = loyalty.entities.filter(i => i.loyalty_type === 'POINTS' &&
83
+ const programs = loyaltyPrograms.filter(i => i.loyalty_type === 'POINTS' &&
83
84
  (i.spend.order_type === null || i.spend.order_type === orderType));
84
85
  return programs.length ? programs[0] : null;
85
86
  });
@@ -11,7 +11,6 @@ export interface CheckoutState {
11
11
  loading: RequestStatus;
12
12
  }
13
13
  export declare enum CheckoutActionType {
14
- FetchCheckout = "checkout/fetchCheckout",
15
14
  ValidateOrder = "checkout/validateOrder",
16
15
  SubmitOrder = "checkout/SubmitOrder",
17
16
  SubmitOrderPay = "checkout/SubmitOrderPay"
@@ -26,7 +26,6 @@ const initialState = {
26
26
  };
27
27
  export var CheckoutActionType;
28
28
  (function (CheckoutActionType) {
29
- CheckoutActionType["FetchCheckout"] = "checkout/fetchCheckout";
30
29
  CheckoutActionType["ValidateOrder"] = "checkout/validateOrder";
31
30
  CheckoutActionType["SubmitOrder"] = "checkout/SubmitOrder";
32
31
  CheckoutActionType["SubmitOrderPay"] = "checkout/SubmitOrderPay";
@@ -95,7 +94,7 @@ const handleOrderErrors = (err, preparedOrder, dispatch) => {
95
94
  return errors;
96
95
  }
97
96
  };
98
- export const validateOrder = createAsyncThunk(CheckoutActionType.FetchCheckout, (order, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
97
+ export const validateOrder = createAsyncThunk(CheckoutActionType.ValidateOrder, (order, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
99
98
  try {
100
99
  const { api } = getState().config;
101
100
  const token = selectToken(getState());
@@ -154,9 +154,9 @@ export const reopenGroupOrder = createAsyncThunk(CustomerGroupOrdersActionType.R
154
154
  const { cart: customerCart } = rehydrateCart(menuItems, items);
155
155
  dispatch(setCart(customerCart));
156
156
  const payload = Object.assign(Object.assign({}, makeCartPayload(response)), { isCartOwner: true, cartOwner: customer });
157
+ dispatch(adjustGroupOrder(payload));
157
158
  dispatch(showNotification('Group order reopened!'));
158
159
  dispatch(setAlert({ type: 'groupOrder' }));
159
- return payload;
160
160
  }
161
161
  catch (err) {
162
162
  dispatch(resetAlert());
@@ -217,8 +217,9 @@ const customerGroupOrdersSlice = createSlice({
217
217
  state.error = action.payload;
218
218
  state.loading = 'idle';
219
219
  })
220
- .addCase(reopenGroupOrder.fulfilled, (state, action) => {
221
- return Object.assign(Object.assign(Object.assign({}, state), action.payload), { loading: 'idle', error: null });
220
+ .addCase(reopenGroupOrder.fulfilled, state => {
221
+ state.error = null;
222
+ state.loading = 'idle';
222
223
  })
223
224
  .addCase(reopenGroupOrder.pending, state => {
224
225
  state.loading = 'pending';
@@ -157,7 +157,7 @@ export declare const selectCustomerPointsProgram: (orderType: OrderType | null)
157
157
  validTimes: import("..").ValidTimesState;
158
158
  verifyAccount: import("..").VerifyAccountState;
159
159
  }) => import("@open-tender/types").CustomerLoyalty | null) & import("reselect").OutputSelectorFields<(args_0: {
160
- loyalty: CustomerLoyaltyState;
160
+ loyaltyPrograms: CustomerLoyalties;
161
161
  }) => import("@open-tender/types").CustomerLoyalty | null, {
162
162
  clearCache: () => void;
163
163
  }> & {
@@ -70,11 +70,12 @@ export const selectCustomerLoyaltyProgram = createSelector((state) => {
70
70
  });
71
71
  export const selectCustomerPointsProgram = (orderType) => createSelector((state) => {
72
72
  const { loyalty } = state.customer;
73
- return { loyalty };
74
- }, ({ loyalty }) => {
75
- if (!loyalty)
73
+ const { entities: loyaltyPrograms } = loyalty;
74
+ return { loyaltyPrograms };
75
+ }, ({ loyaltyPrograms }) => {
76
+ if (!loyaltyPrograms)
76
77
  return null;
77
- const programs = loyalty.entities.filter(i => i.loyalty_type === 'POINTS' &&
78
+ const programs = loyaltyPrograms.filter(i => i.loyalty_type === 'POINTS' &&
78
79
  (i.spend.order_type === null || i.spend.order_type === orderType));
79
80
  return programs.length ? programs[0] : null;
80
81
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/cloud",
3
- "version": "0.1.93",
3
+ "version": "0.1.95",
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",