@open-tender/cloud 0.1.37 → 0.1.39

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.
@@ -163,7 +163,7 @@ exports.submitOrder = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.SubmitO
163
163
  catch (err) {
164
164
  dispatch((0, order_1.setAlert)({ type: 'close' }));
165
165
  const errors = handleOrderErrors(err, preparedOrder, dispatch);
166
- rejectWithValue(errors);
166
+ return rejectWithValue(errors);
167
167
  }
168
168
  }));
169
169
  exports.submitOrderPay = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.SubmitOrderPay, (showAlert = false, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
@@ -194,7 +194,7 @@ exports.submitOrderPay = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.Subm
194
194
  catch (err) {
195
195
  dispatch((0, order_1.setAlert)({ type: 'close' }));
196
196
  const errors = handleOrderErrors(err, preparedOrder, dispatch);
197
- rejectWithValue(errors);
197
+ return rejectWithValue(errors);
198
198
  }
199
199
  }));
200
200
  const checkoutSlice = (0, toolkit_1.createSlice)({
@@ -1,9 +1,14 @@
1
1
  import { AppState } from '../app';
2
- import { CartOwner, GroupOrder, ISOString, SimpleCart, RequestError, RequestStatus, ServiceType, RequestedAt } from '@open-tender/types';
2
+ import { CartOwner, GroupOrder, ISOString, SimpleCart, RequestError, RequestStatus, ServiceType, RequestedAt, GroupOrderGuests } from '@open-tender/types';
3
+ export interface GroupOrderGuestState {
4
+ cartGuestId: number;
5
+ firstName: string;
6
+ lastName: string;
7
+ }
3
8
  export interface GroupOrderState {
4
9
  cart: SimpleCart;
5
- cartGuest: any;
6
- cartGuests: any;
10
+ cartGuest: GroupOrderGuestState | null;
11
+ cartGuests: GroupOrderGuests;
7
12
  cartId: number | null;
8
13
  cartOwner: CartOwner | null;
9
14
  closed: boolean;
@@ -26,7 +31,7 @@ export declare enum GroupOrderActionType {
26
31
  ReloadGuestOrder = "groupOrder/reloadGuestOrder",
27
32
  AddCustomerGroupOrder = "customer/addCustomerGroupOrder"
28
33
  }
29
- export declare const makeCartPayload: (response: GroupOrder, cartGuestId?: number) => {
34
+ export declare const makeCartPayload: (response: GroupOrder, cartGuestId?: number | null) => {
30
35
  cartId: number;
31
36
  token: string;
32
37
  revenueCenterId: number;
@@ -39,7 +44,7 @@ export declare const makeCartPayload: (response: GroupOrder, cartGuestId?: numbe
39
44
  closed: boolean;
40
45
  cartOwner: CartOwner | null;
41
46
  cart: SimpleCart;
42
- cartGuests: import("@open-tender/types").GroupOrderGuests;
47
+ cartGuests: GroupOrderGuests;
43
48
  };
44
49
  export declare const joinGroupOrder: import("@reduxjs/toolkit").AsyncThunk<any, {
45
50
  cart_id: number;
@@ -102,7 +107,7 @@ export declare const resetGroupOrder: import("@reduxjs/toolkit").ActionCreatorWi
102
107
  export declare const selectGroupOrder: (state: AppState) => GroupOrderState;
103
108
  export declare const selectGroupOrderToken: (state: AppState) => string | null;
104
109
  export declare const selectSpendingLimit: (state: AppState) => number | null;
105
- export declare const selectGroupOrderClosed: (state: AppState) => any;
110
+ export declare const selectGroupOrderClosed: (state: AppState) => boolean | null;
106
111
  export declare const selectGroupOrderTests: (state: AppState) => {
107
112
  closed: boolean;
108
113
  pastCutoff: boolean;
@@ -97,14 +97,16 @@ exports.fetchGroupOrder = (0, toolkit_1.createAsyncThunk)(GroupOrderActionType.F
97
97
  }
98
98
  }));
99
99
  exports.updateGroupOrder = (0, toolkit_1.createAsyncThunk)(GroupOrderActionType.UpdateGroupOrder, (_, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
100
- var _a;
101
100
  const { api } = getState().config;
102
101
  if (!api)
103
102
  return;
104
103
  const { cartId, cartGuest } = getState().groupOrder;
104
+ const orderCart = getState().order.cart;
105
+ if (!orderCart || !cartGuest)
106
+ return;
105
107
  try {
106
108
  const data = {
107
- cart: (0, utils_1.makeSimpleCart)((_a = getState().order.cart) !== null && _a !== void 0 ? _a : []),
109
+ cart: (0, utils_1.makeSimpleCart)(orderCart),
108
110
  cart_guest_id: cartGuest.cartGuestId
109
111
  };
110
112
  const response = yield api.putCart(cartId, data);
@@ -159,7 +159,7 @@ export const submitOrder = createAsyncThunk(CheckoutActionType.SubmitOrder, (_,
159
159
  catch (err) {
160
160
  dispatch(setAlert({ type: 'close' }));
161
161
  const errors = handleOrderErrors(err, preparedOrder, dispatch);
162
- rejectWithValue(errors);
162
+ return rejectWithValue(errors);
163
163
  }
164
164
  }));
165
165
  export const submitOrderPay = createAsyncThunk(CheckoutActionType.SubmitOrderPay, (showAlert = false, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
@@ -190,7 +190,7 @@ export const submitOrderPay = createAsyncThunk(CheckoutActionType.SubmitOrderPay
190
190
  catch (err) {
191
191
  dispatch(setAlert({ type: 'close' }));
192
192
  const errors = handleOrderErrors(err, preparedOrder, dispatch);
193
- rejectWithValue(errors);
193
+ return rejectWithValue(errors);
194
194
  }
195
195
  }));
196
196
  const checkoutSlice = createSlice({
@@ -1,9 +1,14 @@
1
1
  import { AppState } from '../app';
2
- import { CartOwner, GroupOrder, ISOString, SimpleCart, RequestError, RequestStatus, ServiceType, RequestedAt } from '@open-tender/types';
2
+ import { CartOwner, GroupOrder, ISOString, SimpleCart, RequestError, RequestStatus, ServiceType, RequestedAt, GroupOrderGuests } from '@open-tender/types';
3
+ export interface GroupOrderGuestState {
4
+ cartGuestId: number;
5
+ firstName: string;
6
+ lastName: string;
7
+ }
3
8
  export interface GroupOrderState {
4
9
  cart: SimpleCart;
5
- cartGuest: any;
6
- cartGuests: any;
10
+ cartGuest: GroupOrderGuestState | null;
11
+ cartGuests: GroupOrderGuests;
7
12
  cartId: number | null;
8
13
  cartOwner: CartOwner | null;
9
14
  closed: boolean;
@@ -26,7 +31,7 @@ export declare enum GroupOrderActionType {
26
31
  ReloadGuestOrder = "groupOrder/reloadGuestOrder",
27
32
  AddCustomerGroupOrder = "customer/addCustomerGroupOrder"
28
33
  }
29
- export declare const makeCartPayload: (response: GroupOrder, cartGuestId?: number) => {
34
+ export declare const makeCartPayload: (response: GroupOrder, cartGuestId?: number | null) => {
30
35
  cartId: number;
31
36
  token: string;
32
37
  revenueCenterId: number;
@@ -39,7 +44,7 @@ export declare const makeCartPayload: (response: GroupOrder, cartGuestId?: numbe
39
44
  closed: boolean;
40
45
  cartOwner: CartOwner | null;
41
46
  cart: SimpleCart;
42
- cartGuests: import("@open-tender/types").GroupOrderGuests;
47
+ cartGuests: GroupOrderGuests;
43
48
  };
44
49
  export declare const joinGroupOrder: import("@reduxjs/toolkit").AsyncThunk<any, {
45
50
  cart_id: number;
@@ -102,7 +107,7 @@ export declare const resetGroupOrder: import("@reduxjs/toolkit").ActionCreatorWi
102
107
  export declare const selectGroupOrder: (state: AppState) => GroupOrderState;
103
108
  export declare const selectGroupOrderToken: (state: AppState) => string | null;
104
109
  export declare const selectSpendingLimit: (state: AppState) => number | null;
105
- export declare const selectGroupOrderClosed: (state: AppState) => any;
110
+ export declare const selectGroupOrderClosed: (state: AppState) => boolean | null;
106
111
  export declare const selectGroupOrderTests: (state: AppState) => {
107
112
  closed: boolean;
108
113
  pastCutoff: boolean;
@@ -93,14 +93,16 @@ export const fetchGroupOrder = createAsyncThunk(GroupOrderActionType.FetchGroupO
93
93
  }
94
94
  }));
95
95
  export const updateGroupOrder = createAsyncThunk(GroupOrderActionType.UpdateGroupOrder, (_, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
96
- var _a;
97
96
  const { api } = getState().config;
98
97
  if (!api)
99
98
  return;
100
99
  const { cartId, cartGuest } = getState().groupOrder;
100
+ const orderCart = getState().order.cart;
101
+ if (!orderCart || !cartGuest)
102
+ return;
101
103
  try {
102
104
  const data = {
103
- cart: makeSimpleCart((_a = getState().order.cart) !== null && _a !== void 0 ? _a : []),
105
+ cart: makeSimpleCart(orderCart),
104
106
  cart_guest_id: cartGuest.cartGuestId
105
107
  };
106
108
  const response = yield api.putCart(cartId, data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/cloud",
3
- "version": "0.1.37",
3
+ "version": "0.1.39",
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",