@open-tender/cloud 0.1.4 → 0.1.5

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.
@@ -1,5 +1,5 @@
1
1
  import { Dispatch } from '@reduxjs/toolkit';
2
- import { CheckoutCheck, CheckoutForm, Order, OrderCreate, RequestStatus } from '@open-tender/types';
2
+ import { CheckoutCheck, CheckoutForm, Order, OrderCreate, RequestError, RequestStatus } from '@open-tender/types';
3
3
  import { AppState } from '../app';
4
4
  export interface CheckoutState {
5
5
  check: CheckoutCheck | null;
@@ -19,9 +19,9 @@ export declare enum CheckoutActionType {
19
19
  export declare const validateOrder: import("@reduxjs/toolkit").AsyncThunk<{
20
20
  check: CheckoutCheck;
21
21
  errors: any;
22
- }, OrderCreate | null, {
22
+ }, OrderCreate | null | undefined, {
23
23
  state: AppState;
24
- rejectValue: any;
24
+ rejectValue: RequestError;
25
25
  dispatch?: Dispatch<import("redux").AnyAction> | undefined;
26
26
  extra?: unknown;
27
27
  serializedErrorType?: unknown;
@@ -31,7 +31,7 @@ export declare const validateOrder: import("@reduxjs/toolkit").AsyncThunk<{
31
31
  }>;
32
32
  export declare const submitOrder: import("@reduxjs/toolkit").AsyncThunk<Order, void, {
33
33
  state: AppState;
34
- rejectValue: any;
34
+ rejectValue: RequestError;
35
35
  dispatch?: Dispatch<import("redux").AnyAction> | undefined;
36
36
  extra?: unknown;
37
37
  serializedErrorType?: unknown;
@@ -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: any;
44
+ rejectValue: RequestError;
45
45
  dispatch?: Dispatch<import("redux").AnyAction> | undefined;
46
46
  extra?: unknown;
47
47
  serializedErrorType?: unknown;
@@ -99,6 +99,18 @@ const handleOrderErrors = (err, preparedOrder, dispatch, rejectWithValue) => {
99
99
  return rejectWithValue(errors);
100
100
  }
101
101
  };
102
+ const makeCheckError = (params) => {
103
+ if (!params || (0, utils_1.isEmpty)(params))
104
+ return null;
105
+ const error = {
106
+ code: 'CHECK_ERRORS',
107
+ detail: 'The parameters of your request were invalid.',
108
+ status: 400,
109
+ title: 'Checkout Errors',
110
+ params
111
+ };
112
+ return error;
113
+ };
102
114
  exports.validateOrder = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.FetchCheckout, (order, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
103
115
  try {
104
116
  const { api } = getState().config;
@@ -111,7 +123,8 @@ exports.validateOrder = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.Fetch
111
123
  return { check: null, errors };
112
124
  }
113
125
  const check = yield api.postOrderValidate(order, token);
114
- const errMessages = (0, utils_1.handleCheckoutErrors)({ params: check.errors });
126
+ const checkError = makeCheckError(check.errors);
127
+ const errMessages = (0, utils_1.handleCheckoutErrors)(checkError);
115
128
  const keys = Object.keys(errMessages);
116
129
  const args = makeRefreshArgs(order);
117
130
  if ((0, utils_1.contains)(keys, refreshKeys)) {
@@ -160,7 +173,7 @@ exports.submitOrder = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.SubmitO
160
173
  }
161
174
  catch (err) {
162
175
  dispatch((0, order_1.setAlert)({ type: 'close' }));
163
- return rejectWithValue(err);
176
+ handleOrderErrors(err, preparedOrder, dispatch, rejectWithValue);
164
177
  }
165
178
  }));
166
179
  exports.submitOrderPay = (0, toolkit_1.createAsyncThunk)(CheckoutActionType.SubmitOrderPay, (showAlert = false, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
@@ -1,17 +1,18 @@
1
- import { ConfigApp, ConfigBrand, ConfigContent, ConfigSettings, ConfigTheme, RequestError, RequestStatus } from '@open-tender/types';
1
+ import { AppTheme, ConfigApp, ConfigBrand, ConfigContent, ConfigSettings, RequestError, RequestStatus, Theme } from '@open-tender/types';
2
2
  import { AppState } from '../app';
3
3
  export interface ConfigState {
4
4
  api: any;
5
- itemTypes: any;
6
5
  app: ConfigApp | null;
6
+ appTheme: AppTheme | null;
7
7
  brand: ConfigBrand | null;
8
8
  content: ConfigContent | null;
9
9
  error: any;
10
+ itemTypes: any;
10
11
  isBackgroundFetch: boolean;
11
12
  loading: RequestStatus;
12
13
  retries: number;
13
14
  settings: ConfigSettings | null;
14
- theme: ConfigTheme | null;
15
+ theme: Theme | null;
15
16
  }
16
17
  export declare enum ConfigActionType {
17
18
  FetchConfig = "config/getConfig"
@@ -37,7 +38,7 @@ export declare const resetConfig: import("@reduxjs/toolkit").ActionCreatorWithou
37
38
  export declare const selectCateringOnly: (state: AppState) => boolean;
38
39
  export declare const selectConfig: (state: AppState) => ConfigState;
39
40
  export declare const selectBrand: (state: AppState) => ConfigBrand | null;
40
- export declare const selectTheme: (state: AppState) => ConfigTheme | null;
41
+ export declare const selectTheme: (state: AppState) => Theme | null;
41
42
  export declare const selectContent: (state: AppState) => ConfigContent | null;
42
43
  export declare const selectSettings: (state: AppState) => ConfigSettings | null;
43
44
  export declare const selectApi: (state: AppState) => any;
@@ -83,8 +84,8 @@ export declare const selectDisplaySettings: (state: AppState) => import("@open-t
83
84
  export declare const selectConfigRetries: (state: AppState) => number;
84
85
  export declare const selectLightColor: (state: AppState) => string;
85
86
  export declare const selectOptIns: (state: AppState) => {
86
- accepts_marketing: import("@open-tender/types").ConfigAcceptMarketing | undefined;
87
- order_notifications: import("@open-tender/types").ConfigOrderNotifications | undefined;
87
+ accepts_marketing: import("@open-tender/types").ConfigAcceptMarketing | null | undefined;
88
+ order_notifications: import("@open-tender/types").ConfigOrderNotifications | null | undefined;
88
89
  };
89
90
  export declare const selectFulfillment: (state: AppState) => import("@open-tender/types").ConfigFulfillment | undefined;
90
91
  export declare const selectRecaptcha: (state: AppState) => {
@@ -97,5 +98,5 @@ export declare const selectSoldOutMsg: (state: AppState) => string;
97
98
  export declare const selectHeaderHeight: (state: AppState) => (isBrowser: boolean) => number;
98
99
  export declare const selectOutpostName: (state: AppState) => string | undefined;
99
100
  export declare const selectHasCatering: (state: AppState) => boolean;
100
- export declare const selectCategoryType: (isMobile: boolean) => (state: AppState) => string;
101
+ export declare const selectCategoryType: (isMobile: boolean) => (state: AppState) => import("@open-tender/types").ThemeCategoryDisplayType;
101
102
  export declare const configReducer: import("redux").Reducer<ConfigState, import("redux").AnyAction>;
@@ -8,17 +8,18 @@ const utils_1 = require("@open-tender/utils");
8
8
  const types_1 = require("./types");
9
9
  const api_1 = tslib_1.__importDefault(require("../services/api"));
10
10
  const initialState = {
11
+ api: null,
11
12
  app: null,
13
+ appTheme: null,
12
14
  brand: null,
13
15
  content: null,
14
16
  theme: null,
15
- settings: null,
16
- api: null,
17
+ itemTypes: null,
18
+ isBackgroundFetch: false,
17
19
  loading: 'idle',
18
20
  error: null,
19
21
  retries: 0,
20
- isBackgroundFetch: false,
21
- itemTypes: null
22
+ settings: null
22
23
  };
23
24
  var ConfigActionType;
24
25
  (function (ConfigActionType) {
@@ -57,14 +58,17 @@ const configSlice = (0, toolkit_1.createSlice)({
57
58
  builder
58
59
  .addCase(exports.fetchConfig.fulfilled, (state, action) => {
59
60
  const { app, brand, content, theme, settings } = action.payload;
61
+ const isApp = action.meta.arg.isMobile;
60
62
  state.app = app;
63
+ state.appTheme = isApp && theme ? (0, utils_1.decorateTheme)(theme) : null;
61
64
  state.brand = brand;
62
65
  state.content = content;
63
- state.theme = theme
64
- ? action.meta.arg.isMobile
65
- ? (0, utils_1.decorateTheme)(theme)
66
- : theme
67
- : null;
66
+ state.theme = !isApp && theme ? theme : null;
67
+ // state.theme = theme
68
+ // ? action.meta.arg.isMobile
69
+ // ? decorateTheme(theme as Theme)
70
+ // : theme
71
+ // : null
68
72
  state.settings = settings;
69
73
  state.loading = 'idle';
70
74
  state.api = new api_1.default(app);
@@ -14,7 +14,7 @@ export declare const purchaseDonation: import("@reduxjs/toolkit").AsyncThunk<Don
14
14
  callback?: (() => void) | undefined;
15
15
  }, {
16
16
  state: AppState;
17
- rejectValue: RequestError | Record<string, any>;
17
+ rejectValue: RequestError;
18
18
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
19
19
  extra?: unknown;
20
20
  serializedErrorType?: unknown;
@@ -4,7 +4,6 @@ exports.donationsReducer = exports.selectDonation = exports.resetDonation = expo
4
4
  const tslib_1 = require("tslib");
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const types_1 = require("./types");
7
- const utils_1 = require("@open-tender/utils");
8
7
  const initialState = {
9
8
  donation: null,
10
9
  success: false,
@@ -26,8 +25,7 @@ exports.purchaseDonation = (0, toolkit_1.createAsyncThunk)(DonationActionType.Pu
26
25
  return donation;
27
26
  }
28
27
  catch (err) {
29
- const errors = (0, utils_1.makeFormErrors)(err);
30
- return rejectWithValue(errors);
28
+ return rejectWithValue(err);
31
29
  }
32
30
  }));
33
31
  const donationsSlice = (0, toolkit_1.createSlice)({
@@ -14,7 +14,7 @@ export declare const purchaseGiftCards: import("@reduxjs/toolkit").AsyncThunk<Cu
14
14
  callback?: (() => void) | undefined;
15
15
  }, {
16
16
  state: AppState;
17
- rejectValue: any;
17
+ rejectValue: RequestError;
18
18
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
19
19
  extra?: unknown;
20
20
  serializedErrorType?: unknown;
@@ -4,7 +4,6 @@ exports.giftCardsReducer = exports.selectGiftCards = exports.resetGiftCards = ex
4
4
  const tslib_1 = require("tslib");
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const types_1 = require("./types");
7
- const utils_1 = require("@open-tender/utils");
8
7
  const initialState = {
9
8
  loading: 'idle',
10
9
  error: null,
@@ -26,8 +25,7 @@ exports.purchaseGiftCards = (0, toolkit_1.createAsyncThunk)(GiftCardsActionType.
26
25
  return giftCards;
27
26
  }
28
27
  catch (err) {
29
- const errors = (0, utils_1.makeFormErrors)(err);
30
- return rejectWithValue(errors);
28
+ return rejectWithValue(err);
31
29
  }
32
30
  }));
33
31
  const giftCardsSlice = (0, toolkit_1.createSlice)({
@@ -47,7 +47,7 @@ export declare const joinGroupOrder: import("@reduxjs/toolkit").AsyncThunk<any,
47
47
  last_name: string;
48
48
  }, {
49
49
  state: AppState;
50
- rejectValue: any;
50
+ rejectValue: RequestError;
51
51
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
52
52
  extra?: unknown;
53
53
  serializedErrorType?: unknown;
@@ -67,7 +67,7 @@ export declare const fetchGroupOrder: import("@reduxjs/toolkit").AsyncThunk<void
67
67
  }>;
68
68
  export declare const updateGroupOrder: import("@reduxjs/toolkit").AsyncThunk<void | Partial<GroupOrderState>, void, {
69
69
  state: AppState;
70
- rejectValue: any;
70
+ rejectValue: RequestError;
71
71
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
72
72
  extra?: unknown;
73
73
  serializedErrorType?: unknown;
@@ -77,7 +77,7 @@ export declare const updateGroupOrder: import("@reduxjs/toolkit").AsyncThunk<voi
77
77
  }>;
78
78
  export declare const reloadGuestOrder: import("@reduxjs/toolkit").AsyncThunk<void, void, {
79
79
  state: AppState;
80
- rejectValue: any;
80
+ rejectValue: RequestError;
81
81
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
82
82
  extra?: unknown;
83
83
  serializedErrorType?: unknown;
@@ -1,9 +1,9 @@
1
1
  import { AppState } from '../app';
2
- import { MenuCategories, MenuVars, OrderRevenueCenter, RequestError, RequestStatus, SoldOut } from '@open-tender/types';
2
+ import { MenuCartErrors, MenuCategories, MenuVars, OrderRevenueCenter, RequestError, RequestStatus, SoldOut } from '@open-tender/types';
3
3
  export interface MenuState {
4
4
  loading: RequestStatus;
5
5
  error: RequestError;
6
- cartErrors: any;
6
+ cartErrors: MenuCartErrors | null;
7
7
  categories: MenuCategories;
8
8
  menuVars: MenuVars | null;
9
9
  previousMenuVars: MenuVars | null;
@@ -15,7 +15,7 @@ export declare enum MenuActionType {
15
15
  }
16
16
  export declare const fetchMenu: import("@reduxjs/toolkit").AsyncThunk<void | Partial<MenuState>, MenuVars, {
17
17
  state: AppState;
18
- rejectValue: any;
18
+ rejectValue: RequestError;
19
19
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
20
20
  extra?: unknown;
21
21
  serializedErrorType?: unknown;
@@ -24,7 +24,7 @@ export declare const updateOrderFulfillment: import("@reduxjs/toolkit").AsyncThu
24
24
  data: Partial<OrderFulfillment>;
25
25
  }, {
26
26
  state: AppState;
27
- rejectValue: any;
27
+ rejectValue: RequestError;
28
28
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
29
29
  extra?: unknown;
30
30
  serializedErrorType?: unknown;
@@ -4,7 +4,6 @@ exports.orderFulfillmentReducer = exports.selectOrderFulfillment = exports.reset
4
4
  const tslib_1 = require("tslib");
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const types_1 = require("./types");
7
- const utils_1 = require("@open-tender/utils");
8
7
  const initialState = {
9
8
  orderFulfillment: null,
10
9
  loading: 'idle',
@@ -36,8 +35,7 @@ exports.updateOrderFulfillment = (0, toolkit_1.createAsyncThunk)(OrderFulfillmen
36
35
  return response;
37
36
  }
38
37
  catch (err) {
39
- const errors = (0, utils_1.makeFormErrors)(err);
40
- return rejectWithValue(errors);
38
+ return rejectWithValue(err);
41
39
  }
42
40
  }));
43
41
  const orderFulfillmentSlice = (0, toolkit_1.createSlice)({
@@ -1,7 +1,7 @@
1
1
  import { AppState } from '../app';
2
- import { OrderRating, RequestError, RequestStatus } from '@open-tender/types';
2
+ import { OrderRating, OrderRatingWithOrder, RequestError, RequestStatus } from '@open-tender/types';
3
3
  export interface OrderRatingState {
4
- orderRating: OrderRating | null;
4
+ orderRating: OrderRatingWithOrder | null;
5
5
  error: RequestError;
6
6
  loading: RequestStatus;
7
7
  }
@@ -10,7 +10,7 @@ export declare enum OrderRatingActionType {
10
10
  UpdateOrderRating = "orderRating/updateOrderRating",
11
11
  UnsubscribeOrderRating = "orderRating/unsubscribeOrderRating"
12
12
  }
13
- export declare const fetchOrderRating: import("@reduxjs/toolkit").AsyncThunk<OrderRating, number, {
13
+ export declare const fetchOrderRating: import("@reduxjs/toolkit").AsyncThunk<OrderRatingWithOrder, number, {
14
14
  state: AppState;
15
15
  rejectValue: RequestError;
16
16
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
@@ -20,12 +20,12 @@ export declare const fetchOrderRating: import("@reduxjs/toolkit").AsyncThunk<Ord
20
20
  fulfilledMeta?: unknown;
21
21
  rejectedMeta?: unknown;
22
22
  }>;
23
- export declare const updateOrderRating: import("@reduxjs/toolkit").AsyncThunk<OrderRating, {
24
- orderId: number;
23
+ export declare const updateOrderRating: import("@reduxjs/toolkit").AsyncThunk<OrderRatingWithOrder, {
24
+ orderUuid: string;
25
25
  data: OrderRating;
26
26
  }, {
27
27
  state: AppState;
28
- rejectValue: any;
28
+ rejectValue: RequestError;
29
29
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
30
30
  extra?: unknown;
31
31
  serializedErrorType?: unknown;
@@ -35,7 +35,7 @@ export declare const updateOrderRating: import("@reduxjs/toolkit").AsyncThunk<Or
35
35
  }>;
36
36
  export declare const unsubscribeOrderRating: import("@reduxjs/toolkit").AsyncThunk<void, number, {
37
37
  state: AppState;
38
- rejectValue: any;
38
+ rejectValue: RequestError;
39
39
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
40
40
  extra?: unknown;
41
41
  serializedErrorType?: unknown;
@@ -45,7 +45,7 @@ export declare const unsubscribeOrderRating: import("@reduxjs/toolkit").AsyncThu
45
45
  }>;
46
46
  export declare const resetOrderRating: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"orderRating/resetOrderRating">;
47
47
  export declare const selectOrderRating: (state: AppState) => {
48
- orderRating: OrderRating | null;
48
+ orderRating: OrderRatingWithOrder | null;
49
49
  loading: RequestStatus;
50
50
  error: RequestError;
51
51
  };
@@ -4,7 +4,6 @@ exports.orderRatingReducer = exports.selectOrderRating = exports.resetOrderRatin
4
4
  const tslib_1 = require("tslib");
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const types_1 = require("./types");
7
- const utils_1 = require("@open-tender/utils");
8
7
  const initialState = {
9
8
  orderRating: null,
10
9
  loading: 'idle',
@@ -21,32 +20,30 @@ exports.fetchOrderRating = (0, toolkit_1.createAsyncThunk)(OrderRatingActionType
21
20
  if (!api)
22
21
  return;
23
22
  try {
24
- const response = yield api.getOrderRating(ratingUuid);
25
- return response;
23
+ return yield api.getOrderRating(ratingUuid);
26
24
  }
27
25
  catch (err) {
28
26
  return rejectWithValue(err);
29
27
  }
30
28
  }));
31
- exports.updateOrderRating = (0, toolkit_1.createAsyncThunk)(OrderRatingActionType.UpdateOrderRating, (requestData, { getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
29
+ exports.updateOrderRating = (0, toolkit_1.createAsyncThunk)(OrderRatingActionType.UpdateOrderRating, ({ orderUuid, data }, { getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
32
30
  const { api } = getState().config;
33
31
  if (!api)
34
32
  return;
35
33
  try {
36
- const response = yield api.putOrderRating(requestData.orderId, requestData.data);
34
+ const response = yield api.putOrderRating(orderUuid, data);
37
35
  return response;
38
36
  }
39
37
  catch (err) {
40
- const errors = (0, utils_1.makeFormErrors)(err);
41
- return rejectWithValue(errors);
38
+ return rejectWithValue(err);
42
39
  }
43
40
  }));
44
- exports.unsubscribeOrderRating = (0, toolkit_1.createAsyncThunk)(OrderRatingActionType.UnsubscribeOrderRating, (ratingUuid, { getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
41
+ exports.unsubscribeOrderRating = (0, toolkit_1.createAsyncThunk)(OrderRatingActionType.UnsubscribeOrderRating, (orderUuid, { getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
45
42
  const { api } = getState().config;
46
43
  if (!api)
47
44
  return;
48
45
  try {
49
- yield api.postOrderRatingUnsubscribe(ratingUuid);
46
+ yield api.postOrderRatingUnsubscribe(orderUuid);
50
47
  return;
51
48
  }
52
49
  catch (err) {
@@ -1,5 +1,5 @@
1
1
  import { Dispatch } from '@reduxjs/toolkit';
2
- import { CheckoutCheck, CheckoutForm, Order, OrderCreate, RequestStatus } from '@open-tender/types';
2
+ import { CheckoutCheck, CheckoutForm, Order, OrderCreate, RequestError, RequestStatus } from '@open-tender/types';
3
3
  import { AppState } from '../app';
4
4
  export interface CheckoutState {
5
5
  check: CheckoutCheck | null;
@@ -19,9 +19,9 @@ export declare enum CheckoutActionType {
19
19
  export declare const validateOrder: import("@reduxjs/toolkit").AsyncThunk<{
20
20
  check: CheckoutCheck;
21
21
  errors: any;
22
- }, OrderCreate | null, {
22
+ }, OrderCreate | null | undefined, {
23
23
  state: AppState;
24
- rejectValue: any;
24
+ rejectValue: RequestError;
25
25
  dispatch?: Dispatch<import("redux").AnyAction> | undefined;
26
26
  extra?: unknown;
27
27
  serializedErrorType?: unknown;
@@ -31,7 +31,7 @@ export declare const validateOrder: import("@reduxjs/toolkit").AsyncThunk<{
31
31
  }>;
32
32
  export declare const submitOrder: import("@reduxjs/toolkit").AsyncThunk<Order, void, {
33
33
  state: AppState;
34
- rejectValue: any;
34
+ rejectValue: RequestError;
35
35
  dispatch?: Dispatch<import("redux").AnyAction> | undefined;
36
36
  extra?: unknown;
37
37
  serializedErrorType?: unknown;
@@ -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: any;
44
+ rejectValue: RequestError;
45
45
  dispatch?: Dispatch<import("redux").AnyAction> | undefined;
46
46
  extra?: unknown;
47
47
  serializedErrorType?: unknown;
@@ -95,6 +95,18 @@ const handleOrderErrors = (err, preparedOrder, dispatch, rejectWithValue) => {
95
95
  return rejectWithValue(errors);
96
96
  }
97
97
  };
98
+ const makeCheckError = (params) => {
99
+ if (!params || isEmpty(params))
100
+ return null;
101
+ const error = {
102
+ code: 'CHECK_ERRORS',
103
+ detail: 'The parameters of your request were invalid.',
104
+ status: 400,
105
+ title: 'Checkout Errors',
106
+ params
107
+ };
108
+ return error;
109
+ };
98
110
  export const validateOrder = createAsyncThunk(CheckoutActionType.FetchCheckout, (order, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
99
111
  try {
100
112
  const { api } = getState().config;
@@ -107,7 +119,8 @@ export const validateOrder = createAsyncThunk(CheckoutActionType.FetchCheckout,
107
119
  return { check: null, errors };
108
120
  }
109
121
  const check = yield api.postOrderValidate(order, token);
110
- const errMessages = handleCheckoutErrors({ params: check.errors });
122
+ const checkError = makeCheckError(check.errors);
123
+ const errMessages = handleCheckoutErrors(checkError);
111
124
  const keys = Object.keys(errMessages);
112
125
  const args = makeRefreshArgs(order);
113
126
  if (contains(keys, refreshKeys)) {
@@ -156,7 +169,7 @@ export const submitOrder = createAsyncThunk(CheckoutActionType.SubmitOrder, (_,
156
169
  }
157
170
  catch (err) {
158
171
  dispatch(setAlert({ type: 'close' }));
159
- return rejectWithValue(err);
172
+ handleOrderErrors(err, preparedOrder, dispatch, rejectWithValue);
160
173
  }
161
174
  }));
162
175
  export const submitOrderPay = createAsyncThunk(CheckoutActionType.SubmitOrderPay, (showAlert = false, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
@@ -1,17 +1,18 @@
1
- import { ConfigApp, ConfigBrand, ConfigContent, ConfigSettings, ConfigTheme, RequestError, RequestStatus } from '@open-tender/types';
1
+ import { AppTheme, ConfigApp, ConfigBrand, ConfigContent, ConfigSettings, RequestError, RequestStatus, Theme } from '@open-tender/types';
2
2
  import { AppState } from '../app';
3
3
  export interface ConfigState {
4
4
  api: any;
5
- itemTypes: any;
6
5
  app: ConfigApp | null;
6
+ appTheme: AppTheme | null;
7
7
  brand: ConfigBrand | null;
8
8
  content: ConfigContent | null;
9
9
  error: any;
10
+ itemTypes: any;
10
11
  isBackgroundFetch: boolean;
11
12
  loading: RequestStatus;
12
13
  retries: number;
13
14
  settings: ConfigSettings | null;
14
- theme: ConfigTheme | null;
15
+ theme: Theme | null;
15
16
  }
16
17
  export declare enum ConfigActionType {
17
18
  FetchConfig = "config/getConfig"
@@ -37,7 +38,7 @@ export declare const resetConfig: import("@reduxjs/toolkit").ActionCreatorWithou
37
38
  export declare const selectCateringOnly: (state: AppState) => boolean;
38
39
  export declare const selectConfig: (state: AppState) => ConfigState;
39
40
  export declare const selectBrand: (state: AppState) => ConfigBrand | null;
40
- export declare const selectTheme: (state: AppState) => ConfigTheme | null;
41
+ export declare const selectTheme: (state: AppState) => Theme | null;
41
42
  export declare const selectContent: (state: AppState) => ConfigContent | null;
42
43
  export declare const selectSettings: (state: AppState) => ConfigSettings | null;
43
44
  export declare const selectApi: (state: AppState) => any;
@@ -83,8 +84,8 @@ export declare const selectDisplaySettings: (state: AppState) => import("@open-t
83
84
  export declare const selectConfigRetries: (state: AppState) => number;
84
85
  export declare const selectLightColor: (state: AppState) => string;
85
86
  export declare const selectOptIns: (state: AppState) => {
86
- accepts_marketing: import("@open-tender/types").ConfigAcceptMarketing | undefined;
87
- order_notifications: import("@open-tender/types").ConfigOrderNotifications | undefined;
87
+ accepts_marketing: import("@open-tender/types").ConfigAcceptMarketing | null | undefined;
88
+ order_notifications: import("@open-tender/types").ConfigOrderNotifications | null | undefined;
88
89
  };
89
90
  export declare const selectFulfillment: (state: AppState) => import("@open-tender/types").ConfigFulfillment | undefined;
90
91
  export declare const selectRecaptcha: (state: AppState) => {
@@ -97,5 +98,5 @@ export declare const selectSoldOutMsg: (state: AppState) => string;
97
98
  export declare const selectHeaderHeight: (state: AppState) => (isBrowser: boolean) => number;
98
99
  export declare const selectOutpostName: (state: AppState) => string | undefined;
99
100
  export declare const selectHasCatering: (state: AppState) => boolean;
100
- export declare const selectCategoryType: (isMobile: boolean) => (state: AppState) => string;
101
+ export declare const selectCategoryType: (isMobile: boolean) => (state: AppState) => import("@open-tender/types").ThemeCategoryDisplayType;
101
102
  export declare const configReducer: import("redux").Reducer<ConfigState, import("redux").AnyAction>;
@@ -4,17 +4,18 @@ import { capitalize, decorateTheme } from '@open-tender/utils';
4
4
  import { ReducerType } from './types';
5
5
  import OpenTenderAPI from '../services/api';
6
6
  const initialState = {
7
+ api: null,
7
8
  app: null,
9
+ appTheme: null,
8
10
  brand: null,
9
11
  content: null,
10
12
  theme: null,
11
- settings: null,
12
- api: null,
13
+ itemTypes: null,
14
+ isBackgroundFetch: false,
13
15
  loading: 'idle',
14
16
  error: null,
15
17
  retries: 0,
16
- isBackgroundFetch: false,
17
- itemTypes: null
18
+ settings: null
18
19
  };
19
20
  export var ConfigActionType;
20
21
  (function (ConfigActionType) {
@@ -53,14 +54,17 @@ const configSlice = createSlice({
53
54
  builder
54
55
  .addCase(fetchConfig.fulfilled, (state, action) => {
55
56
  const { app, brand, content, theme, settings } = action.payload;
57
+ const isApp = action.meta.arg.isMobile;
56
58
  state.app = app;
59
+ state.appTheme = isApp && theme ? decorateTheme(theme) : null;
57
60
  state.brand = brand;
58
61
  state.content = content;
59
- state.theme = theme
60
- ? action.meta.arg.isMobile
61
- ? decorateTheme(theme)
62
- : theme
63
- : null;
62
+ state.theme = !isApp && theme ? theme : null;
63
+ // state.theme = theme
64
+ // ? action.meta.arg.isMobile
65
+ // ? decorateTheme(theme as Theme)
66
+ // : theme
67
+ // : null
64
68
  state.settings = settings;
65
69
  state.loading = 'idle';
66
70
  state.api = new OpenTenderAPI(app);
@@ -14,7 +14,7 @@ export declare const purchaseDonation: import("@reduxjs/toolkit").AsyncThunk<Don
14
14
  callback?: (() => void) | undefined;
15
15
  }, {
16
16
  state: AppState;
17
- rejectValue: RequestError | Record<string, any>;
17
+ rejectValue: RequestError;
18
18
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
19
19
  extra?: unknown;
20
20
  serializedErrorType?: unknown;
@@ -1,7 +1,6 @@
1
1
  import { __awaiter } from "tslib";
2
2
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
3
3
  import { ReducerType } from './types';
4
- import { makeFormErrors } from '@open-tender/utils';
5
4
  const initialState = {
6
5
  donation: null,
7
6
  success: false,
@@ -23,8 +22,7 @@ export const purchaseDonation = createAsyncThunk(DonationActionType.PurchaseDona
23
22
  return donation;
24
23
  }
25
24
  catch (err) {
26
- const errors = makeFormErrors(err);
27
- return rejectWithValue(errors);
25
+ return rejectWithValue(err);
28
26
  }
29
27
  }));
30
28
  const donationsSlice = createSlice({
@@ -14,7 +14,7 @@ export declare const purchaseGiftCards: import("@reduxjs/toolkit").AsyncThunk<Cu
14
14
  callback?: (() => void) | undefined;
15
15
  }, {
16
16
  state: AppState;
17
- rejectValue: any;
17
+ rejectValue: RequestError;
18
18
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
19
19
  extra?: unknown;
20
20
  serializedErrorType?: unknown;
@@ -1,7 +1,6 @@
1
1
  import { __awaiter } from "tslib";
2
2
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
3
3
  import { ReducerType } from './types';
4
- import { makeFormErrors } from '@open-tender/utils';
5
4
  const initialState = {
6
5
  loading: 'idle',
7
6
  error: null,
@@ -23,8 +22,7 @@ export const purchaseGiftCards = createAsyncThunk(GiftCardsActionType.PurchaseGi
23
22
  return giftCards;
24
23
  }
25
24
  catch (err) {
26
- const errors = makeFormErrors(err);
27
- return rejectWithValue(errors);
25
+ return rejectWithValue(err);
28
26
  }
29
27
  }));
30
28
  const giftCardsSlice = createSlice({
@@ -47,7 +47,7 @@ export declare const joinGroupOrder: import("@reduxjs/toolkit").AsyncThunk<any,
47
47
  last_name: string;
48
48
  }, {
49
49
  state: AppState;
50
- rejectValue: any;
50
+ rejectValue: RequestError;
51
51
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
52
52
  extra?: unknown;
53
53
  serializedErrorType?: unknown;
@@ -67,7 +67,7 @@ export declare const fetchGroupOrder: import("@reduxjs/toolkit").AsyncThunk<void
67
67
  }>;
68
68
  export declare const updateGroupOrder: import("@reduxjs/toolkit").AsyncThunk<void | Partial<GroupOrderState>, void, {
69
69
  state: AppState;
70
- rejectValue: any;
70
+ rejectValue: RequestError;
71
71
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
72
72
  extra?: unknown;
73
73
  serializedErrorType?: unknown;
@@ -77,7 +77,7 @@ export declare const updateGroupOrder: import("@reduxjs/toolkit").AsyncThunk<voi
77
77
  }>;
78
78
  export declare const reloadGuestOrder: import("@reduxjs/toolkit").AsyncThunk<void, void, {
79
79
  state: AppState;
80
- rejectValue: any;
80
+ rejectValue: RequestError;
81
81
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
82
82
  extra?: unknown;
83
83
  serializedErrorType?: unknown;
@@ -1,9 +1,9 @@
1
1
  import { AppState } from '../app';
2
- import { MenuCategories, MenuVars, OrderRevenueCenter, RequestError, RequestStatus, SoldOut } from '@open-tender/types';
2
+ import { MenuCartErrors, MenuCategories, MenuVars, OrderRevenueCenter, RequestError, RequestStatus, SoldOut } from '@open-tender/types';
3
3
  export interface MenuState {
4
4
  loading: RequestStatus;
5
5
  error: RequestError;
6
- cartErrors: any;
6
+ cartErrors: MenuCartErrors | null;
7
7
  categories: MenuCategories;
8
8
  menuVars: MenuVars | null;
9
9
  previousMenuVars: MenuVars | null;
@@ -15,7 +15,7 @@ export declare enum MenuActionType {
15
15
  }
16
16
  export declare const fetchMenu: import("@reduxjs/toolkit").AsyncThunk<void | Partial<MenuState>, MenuVars, {
17
17
  state: AppState;
18
- rejectValue: any;
18
+ rejectValue: RequestError;
19
19
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
20
20
  extra?: unknown;
21
21
  serializedErrorType?: unknown;
@@ -24,7 +24,7 @@ export declare const updateOrderFulfillment: import("@reduxjs/toolkit").AsyncThu
24
24
  data: Partial<OrderFulfillment>;
25
25
  }, {
26
26
  state: AppState;
27
- rejectValue: any;
27
+ rejectValue: RequestError;
28
28
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
29
29
  extra?: unknown;
30
30
  serializedErrorType?: unknown;
@@ -1,7 +1,6 @@
1
1
  import { __awaiter } from "tslib";
2
2
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
3
3
  import { ReducerType } from './types';
4
- import { makeFormErrors } from '@open-tender/utils';
5
4
  const initialState = {
6
5
  orderFulfillment: null,
7
6
  loading: 'idle',
@@ -33,8 +32,7 @@ export const updateOrderFulfillment = createAsyncThunk(OrderFulfillmentActionTyp
33
32
  return response;
34
33
  }
35
34
  catch (err) {
36
- const errors = makeFormErrors(err);
37
- return rejectWithValue(errors);
35
+ return rejectWithValue(err);
38
36
  }
39
37
  }));
40
38
  const orderFulfillmentSlice = createSlice({
@@ -1,7 +1,7 @@
1
1
  import { AppState } from '../app';
2
- import { OrderRating, RequestError, RequestStatus } from '@open-tender/types';
2
+ import { OrderRating, OrderRatingWithOrder, RequestError, RequestStatus } from '@open-tender/types';
3
3
  export interface OrderRatingState {
4
- orderRating: OrderRating | null;
4
+ orderRating: OrderRatingWithOrder | null;
5
5
  error: RequestError;
6
6
  loading: RequestStatus;
7
7
  }
@@ -10,7 +10,7 @@ export declare enum OrderRatingActionType {
10
10
  UpdateOrderRating = "orderRating/updateOrderRating",
11
11
  UnsubscribeOrderRating = "orderRating/unsubscribeOrderRating"
12
12
  }
13
- export declare const fetchOrderRating: import("@reduxjs/toolkit").AsyncThunk<OrderRating, number, {
13
+ export declare const fetchOrderRating: import("@reduxjs/toolkit").AsyncThunk<OrderRatingWithOrder, number, {
14
14
  state: AppState;
15
15
  rejectValue: RequestError;
16
16
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
@@ -20,12 +20,12 @@ export declare const fetchOrderRating: import("@reduxjs/toolkit").AsyncThunk<Ord
20
20
  fulfilledMeta?: unknown;
21
21
  rejectedMeta?: unknown;
22
22
  }>;
23
- export declare const updateOrderRating: import("@reduxjs/toolkit").AsyncThunk<OrderRating, {
24
- orderId: number;
23
+ export declare const updateOrderRating: import("@reduxjs/toolkit").AsyncThunk<OrderRatingWithOrder, {
24
+ orderUuid: string;
25
25
  data: OrderRating;
26
26
  }, {
27
27
  state: AppState;
28
- rejectValue: any;
28
+ rejectValue: RequestError;
29
29
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
30
30
  extra?: unknown;
31
31
  serializedErrorType?: unknown;
@@ -35,7 +35,7 @@ export declare const updateOrderRating: import("@reduxjs/toolkit").AsyncThunk<Or
35
35
  }>;
36
36
  export declare const unsubscribeOrderRating: import("@reduxjs/toolkit").AsyncThunk<void, number, {
37
37
  state: AppState;
38
- rejectValue: any;
38
+ rejectValue: RequestError;
39
39
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
40
40
  extra?: unknown;
41
41
  serializedErrorType?: unknown;
@@ -45,7 +45,7 @@ export declare const unsubscribeOrderRating: import("@reduxjs/toolkit").AsyncThu
45
45
  }>;
46
46
  export declare const resetOrderRating: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"orderRating/resetOrderRating">;
47
47
  export declare const selectOrderRating: (state: AppState) => {
48
- orderRating: OrderRating | null;
48
+ orderRating: OrderRatingWithOrder | null;
49
49
  loading: RequestStatus;
50
50
  error: RequestError;
51
51
  };
@@ -1,7 +1,6 @@
1
1
  import { __awaiter } from "tslib";
2
2
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
3
3
  import { ReducerType } from './types';
4
- import { makeFormErrors } from '@open-tender/utils';
5
4
  const initialState = {
6
5
  orderRating: null,
7
6
  loading: 'idle',
@@ -18,32 +17,30 @@ export const fetchOrderRating = createAsyncThunk(OrderRatingActionType.FetchOrde
18
17
  if (!api)
19
18
  return;
20
19
  try {
21
- const response = yield api.getOrderRating(ratingUuid);
22
- return response;
20
+ return yield api.getOrderRating(ratingUuid);
23
21
  }
24
22
  catch (err) {
25
23
  return rejectWithValue(err);
26
24
  }
27
25
  }));
28
- export const updateOrderRating = createAsyncThunk(OrderRatingActionType.UpdateOrderRating, (requestData, { getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
26
+ export const updateOrderRating = createAsyncThunk(OrderRatingActionType.UpdateOrderRating, ({ orderUuid, data }, { getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
29
27
  const { api } = getState().config;
30
28
  if (!api)
31
29
  return;
32
30
  try {
33
- const response = yield api.putOrderRating(requestData.orderId, requestData.data);
31
+ const response = yield api.putOrderRating(orderUuid, data);
34
32
  return response;
35
33
  }
36
34
  catch (err) {
37
- const errors = makeFormErrors(err);
38
- return rejectWithValue(errors);
35
+ return rejectWithValue(err);
39
36
  }
40
37
  }));
41
- export const unsubscribeOrderRating = createAsyncThunk(OrderRatingActionType.UnsubscribeOrderRating, (ratingUuid, { getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
38
+ export const unsubscribeOrderRating = createAsyncThunk(OrderRatingActionType.UnsubscribeOrderRating, (orderUuid, { getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
42
39
  const { api } = getState().config;
43
40
  if (!api)
44
41
  return;
45
42
  try {
46
- yield api.postOrderRatingUnsubscribe(ratingUuid);
43
+ yield api.postOrderRatingUnsubscribe(orderUuid);
47
44
  return;
48
45
  }
49
46
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/cloud",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
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",
@@ -49,8 +49,8 @@
49
49
  "typescript": "^4.8.2"
50
50
  },
51
51
  "peerDependencies": {
52
- "@open-tender/types": "^0.1.8",
53
- "@open-tender/utils": "^0.1.11",
52
+ "@open-tender/types": "^0.2.4",
53
+ "@open-tender/utils": "^0.1.25",
54
54
  "@reduxjs/toolkit": "^1.8.5",
55
55
  "react": "^18.2.0"
56
56
  },