@open-tender/cloud 0.1.5 → 0.1.7

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,9 +1,9 @@
1
1
  import { AnyAction, ThunkDispatch } from '@reduxjs/toolkit';
2
2
  import { AppState } from '../../app';
3
- import { Auth, LoginData, Profile, RequestError, RequestStatus } from '@open-tender/types';
3
+ import { Auth, Customer, CustomerCreate, LoginData, RequestError, RequestStatus } from '@open-tender/types';
4
4
  export interface AccountState {
5
5
  auth: Auth | null;
6
- profile: Partial<Profile> | null;
6
+ profile: Customer | null;
7
7
  loading: RequestStatus;
8
8
  error: any;
9
9
  }
@@ -17,7 +17,7 @@ export declare enum AccountActionType {
17
17
  DeleteCustomer = "customer/deleteCustomer"
18
18
  }
19
19
  export declare const checkAuth: (err: RequestError, dispatch: ThunkDispatch<AppState, unknown, AnyAction>, rejectWithValue: () => any) => Promise<any>;
20
- export declare const fetchCustomer: import("@reduxjs/toolkit").AsyncThunk<Partial<Profile>, void, {
20
+ export declare const fetchCustomer: import("@reduxjs/toolkit").AsyncThunk<Customer, void, {
21
21
  state: AppState;
22
22
  rejectValue: RequestError;
23
23
  dispatch?: import("redux").Dispatch<AnyAction> | undefined;
@@ -57,9 +57,9 @@ export declare const linkPosToken: import("@reduxjs/toolkit").AsyncThunk<void, s
57
57
  fulfilledMeta?: unknown;
58
58
  rejectedMeta?: unknown;
59
59
  }>;
60
- export declare const updateCustomer: import("@reduxjs/toolkit").AsyncThunk<Partial<Profile>, {
61
- data: Partial<Profile>;
62
- callback?: ((data: Partial<Profile>) => void) | undefined;
60
+ export declare const updateCustomer: import("@reduxjs/toolkit").AsyncThunk<Customer, {
61
+ data: CustomerCreate;
62
+ callback?: ((data: CustomerCreate) => void) | undefined;
63
63
  }, {
64
64
  state: AppState;
65
65
  rejectValue: RequestError;
@@ -108,8 +108,8 @@ export declare const authCustomerThanx: import("@reduxjs/toolkit").AsyncThunk<Au
108
108
  rejectedMeta?: unknown;
109
109
  }>;
110
110
  export declare const deleteCustomer: import("@reduxjs/toolkit").AsyncThunk<void, {
111
- data?: Partial<Profile> | undefined;
112
- callback?: ((data?: Partial<Profile>) => void) | undefined;
111
+ data?: CustomerCreate | undefined;
112
+ callback?: ((data?: CustomerCreate) => void) | undefined;
113
113
  }, {
114
114
  state: AppState;
115
115
  rejectValue: RequestError;
@@ -6,6 +6,7 @@ const tslib_1 = require("tslib");
6
6
  const toolkit_1 = require("@reduxjs/toolkit");
7
7
  const types_1 = require("../types");
8
8
  const types_2 = require("@open-tender/types");
9
+ const utils_1 = require("@open-tender/utils");
9
10
  const notifications_1 = require("../notifications");
10
11
  const allergens_1 = require("./allergens");
11
12
  const allergens_2 = require("../allergens");
@@ -21,7 +22,6 @@ const communicationPreferences_1 = require("./communicationPreferences");
21
22
  const giftCards_1 = require("./giftCards");
22
23
  const levelup_1 = require("./levelup");
23
24
  const order_2 = require("../order");
24
- const utils_1 = require("@open-tender/utils");
25
25
  const checkout_1 = require("../checkout");
26
26
  const groupOrder_1 = require("../groupOrder");
27
27
  const guest_1 = require("../guest");
@@ -138,17 +138,17 @@ exports.linkPosToken = (0, toolkit_1.createAsyncThunk)(AccountActionType.LinkPos
138
138
  return rejectWithValue(error);
139
139
  }
140
140
  }));
141
- exports.updateCustomer = (0, toolkit_1.createAsyncThunk)(AccountActionType.UpdateCustomer, (data, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
141
+ exports.updateCustomer = (0, toolkit_1.createAsyncThunk)(AccountActionType.UpdateCustomer, ({ data, callback }, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
142
142
  try {
143
143
  const token = (0, exports.selectToken)(getState());
144
144
  const api = getState().config.api;
145
145
  if (!token)
146
146
  throw new Error(types_2.MISSING_CUSTOMER);
147
- const customer = yield api.putCustomer(token, data.data);
147
+ const customer = yield api.putCustomer(token, data);
148
148
  const profile = (0, utils_1.makeCustomerProfile)(customer);
149
149
  dispatch((0, notifications_1.showNotification)('Account updated!'));
150
- if (data.callback)
151
- data.callback(data.data);
150
+ if (callback)
151
+ callback(data);
152
152
  return profile;
153
153
  }
154
154
  catch (err) {
@@ -204,7 +204,7 @@ exports.authCustomerThanx = (0, toolkit_1.createAsyncThunk)(AccountActionType.Lo
204
204
  return rejectWithValue(err);
205
205
  }
206
206
  }));
207
- exports.deleteCustomer = (0, toolkit_1.createAsyncThunk)(AccountActionType.DeleteCustomer, (requestData, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
207
+ exports.deleteCustomer = (0, toolkit_1.createAsyncThunk)(AccountActionType.DeleteCustomer, ({ data, callback }, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
208
208
  try {
209
209
  const token = (0, exports.selectToken)(getState());
210
210
  const api = getState().config.api;
@@ -228,8 +228,8 @@ exports.deleteCustomer = (0, toolkit_1.createAsyncThunk)(AccountActionType.Delet
228
228
  dispatch((0, communicationPreferences_1.resetCustomerCommunicationPreferences)());
229
229
  dispatch((0, guest_1.resetGuest)());
230
230
  dispatch((0, notifications_1.showNotification)('Account deleted!'));
231
- if (requestData.callback)
232
- requestData.callback(requestData.data);
231
+ if (callback)
232
+ callback(data);
233
233
  return;
234
234
  }
235
235
  catch (err) {
@@ -1,5 +1,5 @@
1
1
  import { AppState } from '../../app';
2
- import { CustomerNotificationPrefs, NotificationArea, NotificationChannel, RequestError, RequestStatus } from '@open-tender/types';
2
+ import { CustomerNotificationPrefs, CustomerNotificationPrefsCreate, NotificationArea, NotificationChannel, RequestError, RequestStatus } from '@open-tender/types';
3
3
  export interface CustomerCommunicationPrefsState {
4
4
  entities: CustomerNotificationPrefs;
5
5
  error: RequestError;
@@ -52,7 +52,7 @@ export declare const removeCustomerCommunicationPreference: import("@reduxjs/too
52
52
  rejectedMeta?: unknown;
53
53
  }>;
54
54
  export declare const setCustomerCommunicationDefaultPreferences: import("@reduxjs/toolkit").AsyncThunk<CustomerNotificationPrefs, {
55
- prefs: CustomerNotificationPrefs;
55
+ prefs: CustomerNotificationPrefsCreate;
56
56
  callback?: (() => void) | undefined;
57
57
  }, {
58
58
  state: AppState;
@@ -1,7 +1,7 @@
1
1
  import { AppState } from '../../app';
2
- import { CustomerGiftCard, CustomerGiftCards, RequestError, RequestStatus } from '@open-tender/types';
2
+ import { GiftCard, GiftCardPurchase, GiftCards, RequestError, RequestStatus } from '@open-tender/types';
3
3
  export interface CustomerGiftCardsState {
4
- entities: CustomerGiftCards;
4
+ entities: GiftCards;
5
5
  error: RequestError;
6
6
  loading: RequestStatus;
7
7
  lookup: {
@@ -16,7 +16,7 @@ export declare enum CustomerGiftCardsActionType {
16
16
  AssignCustomerGiftCardOther = "customer/assignCustomerGiftCardOther",
17
17
  UpdateCustomerGiftCard = "customer/updateCustomerGiftCard"
18
18
  }
19
- export declare const fetchCustomerGiftCards: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, void, {
19
+ export declare const fetchCustomerGiftCards: import("@reduxjs/toolkit").AsyncThunk<GiftCards, void, {
20
20
  state: AppState;
21
21
  rejectValue: RequestError;
22
22
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
@@ -26,9 +26,9 @@ export declare const fetchCustomerGiftCards: import("@reduxjs/toolkit").AsyncThu
26
26
  fulfilledMeta?: unknown;
27
27
  rejectedMeta?: unknown;
28
28
  }>;
29
- export declare const updateCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, {
29
+ export declare const updateCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<GiftCards, {
30
30
  giftCardId: number;
31
- data: CustomerGiftCard;
31
+ data: GiftCard;
32
32
  callback?: (() => void) | undefined;
33
33
  }, {
34
34
  state: AppState;
@@ -40,7 +40,7 @@ export declare const updateCustomerGiftCard: import("@reduxjs/toolkit").AsyncThu
40
40
  fulfilledMeta?: unknown;
41
41
  rejectedMeta?: unknown;
42
42
  }>;
43
- export declare const removeCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, {
43
+ export declare const removeCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<GiftCards, {
44
44
  giftCardId: number;
45
45
  callback?: (() => void) | undefined;
46
46
  }, {
@@ -53,8 +53,8 @@ export declare const removeCustomerGiftCard: import("@reduxjs/toolkit").AsyncThu
53
53
  fulfilledMeta?: unknown;
54
54
  rejectedMeta?: unknown;
55
55
  }>;
56
- export declare const addCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, {
57
- data: CustomerGiftCard;
56
+ export declare const addCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<GiftCards, {
57
+ data: GiftCardPurchase;
58
58
  callback?: (() => void) | undefined;
59
59
  }, {
60
60
  state: AppState;
@@ -66,7 +66,7 @@ export declare const addCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<
66
66
  fulfilledMeta?: unknown;
67
67
  rejectedMeta?: unknown;
68
68
  }>;
69
- export declare const assignCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, {
69
+ export declare const assignCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<GiftCards, {
70
70
  cardNumber: number;
71
71
  callback?: (() => void) | undefined;
72
72
  }, {
@@ -79,7 +79,7 @@ export declare const assignCustomerGiftCard: import("@reduxjs/toolkit").AsyncThu
79
79
  fulfilledMeta?: unknown;
80
80
  rejectedMeta?: unknown;
81
81
  }>;
82
- export declare const assignCustomerGiftCardOther: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, {
82
+ export declare const assignCustomerGiftCardOther: import("@reduxjs/toolkit").AsyncThunk<GiftCards, {
83
83
  giftCardId: number;
84
84
  email: string;
85
85
  callback?: (() => void) | undefined;
@@ -36,17 +36,17 @@ exports.fetchCustomerGiftCards = (0, toolkit_1.createAsyncThunk)(CustomerGiftCar
36
36
  return (0, account_1.checkAuth)(error, dispatch, () => rejectWithValue(error));
37
37
  }
38
38
  }));
39
- exports.updateCustomerGiftCard = (0, toolkit_1.createAsyncThunk)(CustomerGiftCardsActionType.UpdateCustomerGiftCard, (requestData, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
39
+ exports.updateCustomerGiftCard = (0, toolkit_1.createAsyncThunk)(CustomerGiftCardsActionType.UpdateCustomerGiftCard, ({ giftCardId, data, callback }, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
40
40
  try {
41
41
  const api = getState().config.api;
42
42
  const token = (0, account_1.selectToken)(getState());
43
43
  if (!token)
44
44
  throw new Error(types_2.MISSING_CUSTOMER);
45
- yield api.putCustomerGiftCard(token, requestData.giftCardId, requestData.data);
45
+ yield api.putCustomerGiftCard(token, giftCardId, data);
46
46
  const giftCards = yield api.getCustomerGiftCards(token);
47
47
  dispatch((0, notifications_1.showNotification)('Gift card balance updated!'));
48
- if (requestData.callback)
49
- requestData.callback();
48
+ if (callback)
49
+ callback();
50
50
  return giftCards;
51
51
  }
52
52
  catch (err) {
@@ -54,17 +54,17 @@ exports.updateCustomerGiftCard = (0, toolkit_1.createAsyncThunk)(CustomerGiftCar
54
54
  return (0, account_1.checkAuth)(error, dispatch, () => rejectWithValue(error));
55
55
  }
56
56
  }));
57
- exports.removeCustomerGiftCard = (0, toolkit_1.createAsyncThunk)(CustomerGiftCardsActionType.RemoveCustomerGiftCard, (requestData, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
57
+ exports.removeCustomerGiftCard = (0, toolkit_1.createAsyncThunk)(CustomerGiftCardsActionType.RemoveCustomerGiftCard, ({ giftCardId, callback }, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
58
58
  try {
59
59
  const api = getState().config.api;
60
60
  const token = (0, account_1.selectToken)(getState());
61
61
  if (!token)
62
62
  throw new Error(types_2.MISSING_CUSTOMER);
63
- yield api.deleteCustomerGiftCard(token, requestData.giftCardId);
63
+ yield api.deleteCustomerGiftCard(token, giftCardId);
64
64
  const giftCards = yield api.getCustomerGiftCards(token);
65
65
  dispatch((0, notifications_1.showNotification)('Gift card removed!'));
66
- if (requestData.callback)
67
- requestData.callback();
66
+ if (callback)
67
+ callback();
68
68
  return giftCards;
69
69
  }
70
70
  catch (err) {
@@ -72,17 +72,17 @@ exports.removeCustomerGiftCard = (0, toolkit_1.createAsyncThunk)(CustomerGiftCar
72
72
  return (0, account_1.checkAuth)(error, dispatch, () => rejectWithValue(error));
73
73
  }
74
74
  }));
75
- exports.addCustomerGiftCard = (0, toolkit_1.createAsyncThunk)(CustomerGiftCardsActionType.AddCustomerGiftCard, (requestData, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
75
+ exports.addCustomerGiftCard = (0, toolkit_1.createAsyncThunk)(CustomerGiftCardsActionType.AddCustomerGiftCard, ({ data, callback }, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
76
76
  try {
77
77
  const api = getState().config.api;
78
78
  const token = (0, account_1.selectToken)(getState());
79
79
  if (!token)
80
80
  throw new Error(types_2.MISSING_CUSTOMER);
81
- yield api.postCustomerGiftCard(token, requestData.data);
81
+ yield api.postCustomerGiftCard(token, data);
82
82
  const giftCards = yield api.getCustomerGiftCards(token);
83
83
  dispatch((0, notifications_1.showNotification)('Gift card added!'));
84
- if (requestData.callback)
85
- requestData.callback();
84
+ if (callback)
85
+ callback();
86
86
  return giftCards;
87
87
  }
88
88
  catch (err) {
@@ -90,17 +90,17 @@ exports.addCustomerGiftCard = (0, toolkit_1.createAsyncThunk)(CustomerGiftCardsA
90
90
  return (0, account_1.checkAuth)(error, dispatch, () => rejectWithValue(error));
91
91
  }
92
92
  }));
93
- exports.assignCustomerGiftCard = (0, toolkit_1.createAsyncThunk)(CustomerGiftCardsActionType.AssignCustomerGiftCard, (requestData, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
93
+ exports.assignCustomerGiftCard = (0, toolkit_1.createAsyncThunk)(CustomerGiftCardsActionType.AssignCustomerGiftCard, ({ cardNumber, callback }, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
94
94
  try {
95
95
  const api = getState().config.api;
96
96
  const token = (0, account_1.selectToken)(getState());
97
97
  if (!token)
98
98
  throw new Error(types_2.MISSING_CUSTOMER);
99
- yield api.postCustomerGiftCardAssign(token, requestData.cardNumber);
99
+ yield api.postCustomerGiftCardAssign(token, cardNumber);
100
100
  const giftCards = yield api.getCustomerGiftCards(token);
101
101
  dispatch((0, notifications_1.showNotification)('Gift card added to your account!'));
102
- if (requestData.callback)
103
- requestData.callback();
102
+ if (callback)
103
+ callback();
104
104
  return giftCards;
105
105
  }
106
106
  catch (err) {
@@ -108,17 +108,17 @@ exports.assignCustomerGiftCard = (0, toolkit_1.createAsyncThunk)(CustomerGiftCar
108
108
  return (0, account_1.checkAuth)(error, dispatch, () => rejectWithValue(error));
109
109
  }
110
110
  }));
111
- exports.assignCustomerGiftCardOther = (0, toolkit_1.createAsyncThunk)(CustomerGiftCardsActionType.AssignCustomerGiftCardOther, (requestData, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
111
+ exports.assignCustomerGiftCardOther = (0, toolkit_1.createAsyncThunk)(CustomerGiftCardsActionType.AssignCustomerGiftCardOther, ({ giftCardId, email, callback }, { dispatch, getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
112
112
  try {
113
113
  const api = getState().config.api;
114
114
  const token = (0, account_1.selectToken)(getState());
115
115
  if (!token)
116
116
  throw new Error(types_2.MISSING_CUSTOMER);
117
- yield api.postCustomerGiftCardAssignOther(token, requestData.giftCardId, requestData.email);
117
+ yield api.postCustomerGiftCardAssignOther(token, giftCardId, email);
118
118
  const giftCards = yield api.getCustomerGiftCards(token);
119
- dispatch((0, notifications_1.showNotification)(`Gift card assigned to ${requestData.email}`));
120
- if (requestData.callback)
121
- requestData.callback();
119
+ dispatch((0, notifications_1.showNotification)(`Gift card assigned to ${email}`));
120
+ if (callback)
121
+ callback();
122
122
  return giftCards;
123
123
  }
124
124
  catch (err) {
@@ -1,16 +1,16 @@
1
1
  import { AppState } from '../app';
2
- import { CustomerGiftCard, CustomerGiftCards, RequestError, RequestStatus } from '@open-tender/types';
2
+ import { GiftCard, GiftCards, RequestError, RequestStatus } from '@open-tender/types';
3
3
  export interface GiftCardsState {
4
4
  loading: RequestStatus;
5
5
  error: RequestError;
6
6
  success: boolean;
7
- giftCards: CustomerGiftCards;
7
+ giftCards: GiftCards;
8
8
  }
9
9
  export declare enum GiftCardsActionType {
10
10
  PurchaseGiftCards = "giftCards/purchaseGiftCards"
11
11
  }
12
- export declare const purchaseGiftCards: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, {
13
- data: Partial<CustomerGiftCard>;
12
+ export declare const purchaseGiftCards: import("@reduxjs/toolkit").AsyncThunk<GiftCards, {
13
+ data: Partial<GiftCard>;
14
14
  callback?: (() => void) | undefined;
15
15
  }, {
16
16
  state: AppState;
@@ -27,6 +27,6 @@ export declare const selectGiftCards: (state: AppState) => {
27
27
  success: boolean;
28
28
  loading: RequestStatus;
29
29
  error: RequestError;
30
- giftCards: CustomerGiftCards;
30
+ giftCards: GiftCards;
31
31
  };
32
32
  export declare const giftCardsReducer: import("redux").Reducer<GiftCardsState, import("redux").AnyAction>;
@@ -5,8 +5,8 @@ const tslib_1 = require("tslib");
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const types_1 = require("./types");
7
7
  const types_2 = require("@open-tender/types");
8
- const order_1 = require("./order");
9
8
  const utils_1 = require("@open-tender/utils");
9
+ const order_1 = require("./order");
10
10
  const customer_1 = require("./customer");
11
11
  const initialState = {
12
12
  cart: [],
@@ -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<OrderRatingWithOrder, number, {
13
+ export declare const fetchOrderRating: import("@reduxjs/toolkit").AsyncThunk<OrderRatingWithOrder, string, {
14
14
  state: AppState;
15
15
  rejectValue: RequestError;
16
16
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
@@ -33,7 +33,7 @@ export declare const updateOrderRating: import("@reduxjs/toolkit").AsyncThunk<Or
33
33
  fulfilledMeta?: unknown;
34
34
  rejectedMeta?: unknown;
35
35
  }>;
36
- export declare const unsubscribeOrderRating: import("@reduxjs/toolkit").AsyncThunk<void, number, {
36
+ export declare const unsubscribeOrderRating: import("@reduxjs/toolkit").AsyncThunk<void, string, {
37
37
  state: AppState;
38
38
  rejectValue: RequestError;
39
39
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
@@ -15,12 +15,12 @@ var OrderRatingActionType;
15
15
  OrderRatingActionType["UpdateOrderRating"] = "orderRating/updateOrderRating";
16
16
  OrderRatingActionType["UnsubscribeOrderRating"] = "orderRating/unsubscribeOrderRating";
17
17
  })(OrderRatingActionType = exports.OrderRatingActionType || (exports.OrderRatingActionType = {}));
18
- exports.fetchOrderRating = (0, toolkit_1.createAsyncThunk)(OrderRatingActionType.FetchOrderRating, (ratingUuid, { getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
18
+ exports.fetchOrderRating = (0, toolkit_1.createAsyncThunk)(OrderRatingActionType.FetchOrderRating, (orderUuid, { getState, rejectWithValue }) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
19
19
  const { api } = getState().config;
20
20
  if (!api)
21
21
  return;
22
22
  try {
23
- return yield api.getOrderRating(ratingUuid);
23
+ return yield api.getOrderRating(orderUuid);
24
24
  }
25
25
  catch (err) {
26
26
  return rejectWithValue(err);
@@ -1,9 +1,9 @@
1
1
  import { AnyAction, ThunkDispatch } from '@reduxjs/toolkit';
2
2
  import { AppState } from '../../app';
3
- import { Auth, LoginData, Profile, RequestError, RequestStatus } from '@open-tender/types';
3
+ import { Auth, Customer, CustomerCreate, LoginData, RequestError, RequestStatus } from '@open-tender/types';
4
4
  export interface AccountState {
5
5
  auth: Auth | null;
6
- profile: Partial<Profile> | null;
6
+ profile: Customer | null;
7
7
  loading: RequestStatus;
8
8
  error: any;
9
9
  }
@@ -17,7 +17,7 @@ export declare enum AccountActionType {
17
17
  DeleteCustomer = "customer/deleteCustomer"
18
18
  }
19
19
  export declare const checkAuth: (err: RequestError, dispatch: ThunkDispatch<AppState, unknown, AnyAction>, rejectWithValue: () => any) => Promise<any>;
20
- export declare const fetchCustomer: import("@reduxjs/toolkit").AsyncThunk<Partial<Profile>, void, {
20
+ export declare const fetchCustomer: import("@reduxjs/toolkit").AsyncThunk<Customer, void, {
21
21
  state: AppState;
22
22
  rejectValue: RequestError;
23
23
  dispatch?: import("redux").Dispatch<AnyAction> | undefined;
@@ -57,9 +57,9 @@ export declare const linkPosToken: import("@reduxjs/toolkit").AsyncThunk<void, s
57
57
  fulfilledMeta?: unknown;
58
58
  rejectedMeta?: unknown;
59
59
  }>;
60
- export declare const updateCustomer: import("@reduxjs/toolkit").AsyncThunk<Partial<Profile>, {
61
- data: Partial<Profile>;
62
- callback?: ((data: Partial<Profile>) => void) | undefined;
60
+ export declare const updateCustomer: import("@reduxjs/toolkit").AsyncThunk<Customer, {
61
+ data: CustomerCreate;
62
+ callback?: ((data: CustomerCreate) => void) | undefined;
63
63
  }, {
64
64
  state: AppState;
65
65
  rejectValue: RequestError;
@@ -108,8 +108,8 @@ export declare const authCustomerThanx: import("@reduxjs/toolkit").AsyncThunk<Au
108
108
  rejectedMeta?: unknown;
109
109
  }>;
110
110
  export declare const deleteCustomer: import("@reduxjs/toolkit").AsyncThunk<void, {
111
- data?: Partial<Profile> | undefined;
112
- callback?: ((data?: Partial<Profile>) => void) | undefined;
111
+ data?: CustomerCreate | undefined;
112
+ callback?: ((data?: CustomerCreate) => void) | undefined;
113
113
  }, {
114
114
  state: AppState;
115
115
  rejectValue: RequestError;
@@ -2,6 +2,7 @@ import { __awaiter } from "tslib";
2
2
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
3
3
  import { ReducerType } from '../types';
4
4
  import { MISSING_CUSTOMER, MISSING_CUSTOMER_TOKEN } from '@open-tender/types';
5
+ import { makeCustomerProfile, makeFavoritesLookup, makeFormErrors } from '@open-tender/utils';
5
6
  import { showNotification } from '../notifications';
6
7
  import { resetCustomerAllergens, setCustomerAllergens } from './allergens';
7
8
  import { setSelectedAllergens } from '../allergens';
@@ -17,7 +18,6 @@ import { resetCustomerCommunicationPreferences } from './communicationPreference
17
18
  import { resetCustomerGiftCards, setCustomerGiftCards } from './giftCards';
18
19
  import { resetCustomerLevelUp, setCustomerLevelUp } from './levelup';
19
20
  import { addMessage, resetOrder, setAlert } from '../order';
20
- import { makeCustomerProfile, makeFavoritesLookup, makeFormErrors } from '@open-tender/utils';
21
21
  import { resetCheckout, updateCheckoutCustomer } from '../checkout';
22
22
  import { resetGroupOrder } from '../groupOrder';
23
23
  import { resetGuest } from '../guest';
@@ -133,17 +133,17 @@ export const linkPosToken = createAsyncThunk(AccountActionType.LinkPosToken, (po
133
133
  return rejectWithValue(error);
134
134
  }
135
135
  }));
136
- export const updateCustomer = createAsyncThunk(AccountActionType.UpdateCustomer, (data, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
136
+ export const updateCustomer = createAsyncThunk(AccountActionType.UpdateCustomer, ({ data, callback }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
137
137
  try {
138
138
  const token = selectToken(getState());
139
139
  const api = getState().config.api;
140
140
  if (!token)
141
141
  throw new Error(MISSING_CUSTOMER);
142
- const customer = yield api.putCustomer(token, data.data);
142
+ const customer = yield api.putCustomer(token, data);
143
143
  const profile = makeCustomerProfile(customer);
144
144
  dispatch(showNotification('Account updated!'));
145
- if (data.callback)
146
- data.callback(data.data);
145
+ if (callback)
146
+ callback(data);
147
147
  return profile;
148
148
  }
149
149
  catch (err) {
@@ -199,7 +199,7 @@ export const authCustomerThanx = createAsyncThunk(AccountActionType.LoginCustome
199
199
  return rejectWithValue(err);
200
200
  }
201
201
  }));
202
- export const deleteCustomer = createAsyncThunk(AccountActionType.DeleteCustomer, (requestData, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
202
+ export const deleteCustomer = createAsyncThunk(AccountActionType.DeleteCustomer, ({ data, callback }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
203
203
  try {
204
204
  const token = selectToken(getState());
205
205
  const api = getState().config.api;
@@ -223,8 +223,8 @@ export const deleteCustomer = createAsyncThunk(AccountActionType.DeleteCustomer,
223
223
  dispatch(resetCustomerCommunicationPreferences());
224
224
  dispatch(resetGuest());
225
225
  dispatch(showNotification('Account deleted!'));
226
- if (requestData.callback)
227
- requestData.callback(requestData.data);
226
+ if (callback)
227
+ callback(data);
228
228
  return;
229
229
  }
230
230
  catch (err) {
@@ -1,5 +1,5 @@
1
1
  import { AppState } from '../../app';
2
- import { CustomerNotificationPrefs, NotificationArea, NotificationChannel, RequestError, RequestStatus } from '@open-tender/types';
2
+ import { CustomerNotificationPrefs, CustomerNotificationPrefsCreate, NotificationArea, NotificationChannel, RequestError, RequestStatus } from '@open-tender/types';
3
3
  export interface CustomerCommunicationPrefsState {
4
4
  entities: CustomerNotificationPrefs;
5
5
  error: RequestError;
@@ -52,7 +52,7 @@ export declare const removeCustomerCommunicationPreference: import("@reduxjs/too
52
52
  rejectedMeta?: unknown;
53
53
  }>;
54
54
  export declare const setCustomerCommunicationDefaultPreferences: import("@reduxjs/toolkit").AsyncThunk<CustomerNotificationPrefs, {
55
- prefs: CustomerNotificationPrefs;
55
+ prefs: CustomerNotificationPrefsCreate;
56
56
  callback?: (() => void) | undefined;
57
57
  }, {
58
58
  state: AppState;
@@ -1,7 +1,7 @@
1
1
  import { AppState } from '../../app';
2
- import { CustomerGiftCard, CustomerGiftCards, RequestError, RequestStatus } from '@open-tender/types';
2
+ import { GiftCard, GiftCardPurchase, GiftCards, RequestError, RequestStatus } from '@open-tender/types';
3
3
  export interface CustomerGiftCardsState {
4
- entities: CustomerGiftCards;
4
+ entities: GiftCards;
5
5
  error: RequestError;
6
6
  loading: RequestStatus;
7
7
  lookup: {
@@ -16,7 +16,7 @@ export declare enum CustomerGiftCardsActionType {
16
16
  AssignCustomerGiftCardOther = "customer/assignCustomerGiftCardOther",
17
17
  UpdateCustomerGiftCard = "customer/updateCustomerGiftCard"
18
18
  }
19
- export declare const fetchCustomerGiftCards: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, void, {
19
+ export declare const fetchCustomerGiftCards: import("@reduxjs/toolkit").AsyncThunk<GiftCards, void, {
20
20
  state: AppState;
21
21
  rejectValue: RequestError;
22
22
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
@@ -26,9 +26,9 @@ export declare const fetchCustomerGiftCards: import("@reduxjs/toolkit").AsyncThu
26
26
  fulfilledMeta?: unknown;
27
27
  rejectedMeta?: unknown;
28
28
  }>;
29
- export declare const updateCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, {
29
+ export declare const updateCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<GiftCards, {
30
30
  giftCardId: number;
31
- data: CustomerGiftCard;
31
+ data: GiftCard;
32
32
  callback?: (() => void) | undefined;
33
33
  }, {
34
34
  state: AppState;
@@ -40,7 +40,7 @@ export declare const updateCustomerGiftCard: import("@reduxjs/toolkit").AsyncThu
40
40
  fulfilledMeta?: unknown;
41
41
  rejectedMeta?: unknown;
42
42
  }>;
43
- export declare const removeCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, {
43
+ export declare const removeCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<GiftCards, {
44
44
  giftCardId: number;
45
45
  callback?: (() => void) | undefined;
46
46
  }, {
@@ -53,8 +53,8 @@ export declare const removeCustomerGiftCard: import("@reduxjs/toolkit").AsyncThu
53
53
  fulfilledMeta?: unknown;
54
54
  rejectedMeta?: unknown;
55
55
  }>;
56
- export declare const addCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, {
57
- data: CustomerGiftCard;
56
+ export declare const addCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<GiftCards, {
57
+ data: GiftCardPurchase;
58
58
  callback?: (() => void) | undefined;
59
59
  }, {
60
60
  state: AppState;
@@ -66,7 +66,7 @@ export declare const addCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<
66
66
  fulfilledMeta?: unknown;
67
67
  rejectedMeta?: unknown;
68
68
  }>;
69
- export declare const assignCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, {
69
+ export declare const assignCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<GiftCards, {
70
70
  cardNumber: number;
71
71
  callback?: (() => void) | undefined;
72
72
  }, {
@@ -79,7 +79,7 @@ export declare const assignCustomerGiftCard: import("@reduxjs/toolkit").AsyncThu
79
79
  fulfilledMeta?: unknown;
80
80
  rejectedMeta?: unknown;
81
81
  }>;
82
- export declare const assignCustomerGiftCardOther: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, {
82
+ export declare const assignCustomerGiftCardOther: import("@reduxjs/toolkit").AsyncThunk<GiftCards, {
83
83
  giftCardId: number;
84
84
  email: string;
85
85
  callback?: (() => void) | undefined;
@@ -32,17 +32,17 @@ export const fetchCustomerGiftCards = createAsyncThunk(CustomerGiftCardsActionTy
32
32
  return checkAuth(error, dispatch, () => rejectWithValue(error));
33
33
  }
34
34
  }));
35
- export const updateCustomerGiftCard = createAsyncThunk(CustomerGiftCardsActionType.UpdateCustomerGiftCard, (requestData, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
35
+ export const updateCustomerGiftCard = createAsyncThunk(CustomerGiftCardsActionType.UpdateCustomerGiftCard, ({ giftCardId, data, callback }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
36
36
  try {
37
37
  const api = getState().config.api;
38
38
  const token = selectToken(getState());
39
39
  if (!token)
40
40
  throw new Error(MISSING_CUSTOMER);
41
- yield api.putCustomerGiftCard(token, requestData.giftCardId, requestData.data);
41
+ yield api.putCustomerGiftCard(token, giftCardId, data);
42
42
  const giftCards = yield api.getCustomerGiftCards(token);
43
43
  dispatch(showNotification('Gift card balance updated!'));
44
- if (requestData.callback)
45
- requestData.callback();
44
+ if (callback)
45
+ callback();
46
46
  return giftCards;
47
47
  }
48
48
  catch (err) {
@@ -50,17 +50,17 @@ export const updateCustomerGiftCard = createAsyncThunk(CustomerGiftCardsActionTy
50
50
  return checkAuth(error, dispatch, () => rejectWithValue(error));
51
51
  }
52
52
  }));
53
- export const removeCustomerGiftCard = createAsyncThunk(CustomerGiftCardsActionType.RemoveCustomerGiftCard, (requestData, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
53
+ export const removeCustomerGiftCard = createAsyncThunk(CustomerGiftCardsActionType.RemoveCustomerGiftCard, ({ giftCardId, callback }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
54
54
  try {
55
55
  const api = getState().config.api;
56
56
  const token = selectToken(getState());
57
57
  if (!token)
58
58
  throw new Error(MISSING_CUSTOMER);
59
- yield api.deleteCustomerGiftCard(token, requestData.giftCardId);
59
+ yield api.deleteCustomerGiftCard(token, giftCardId);
60
60
  const giftCards = yield api.getCustomerGiftCards(token);
61
61
  dispatch(showNotification('Gift card removed!'));
62
- if (requestData.callback)
63
- requestData.callback();
62
+ if (callback)
63
+ callback();
64
64
  return giftCards;
65
65
  }
66
66
  catch (err) {
@@ -68,17 +68,17 @@ export const removeCustomerGiftCard = createAsyncThunk(CustomerGiftCardsActionTy
68
68
  return checkAuth(error, dispatch, () => rejectWithValue(error));
69
69
  }
70
70
  }));
71
- export const addCustomerGiftCard = createAsyncThunk(CustomerGiftCardsActionType.AddCustomerGiftCard, (requestData, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
71
+ export const addCustomerGiftCard = createAsyncThunk(CustomerGiftCardsActionType.AddCustomerGiftCard, ({ data, callback }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
72
72
  try {
73
73
  const api = getState().config.api;
74
74
  const token = selectToken(getState());
75
75
  if (!token)
76
76
  throw new Error(MISSING_CUSTOMER);
77
- yield api.postCustomerGiftCard(token, requestData.data);
77
+ yield api.postCustomerGiftCard(token, data);
78
78
  const giftCards = yield api.getCustomerGiftCards(token);
79
79
  dispatch(showNotification('Gift card added!'));
80
- if (requestData.callback)
81
- requestData.callback();
80
+ if (callback)
81
+ callback();
82
82
  return giftCards;
83
83
  }
84
84
  catch (err) {
@@ -86,17 +86,17 @@ export const addCustomerGiftCard = createAsyncThunk(CustomerGiftCardsActionType.
86
86
  return checkAuth(error, dispatch, () => rejectWithValue(error));
87
87
  }
88
88
  }));
89
- export const assignCustomerGiftCard = createAsyncThunk(CustomerGiftCardsActionType.AssignCustomerGiftCard, (requestData, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
89
+ export const assignCustomerGiftCard = createAsyncThunk(CustomerGiftCardsActionType.AssignCustomerGiftCard, ({ cardNumber, callback }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
90
90
  try {
91
91
  const api = getState().config.api;
92
92
  const token = selectToken(getState());
93
93
  if (!token)
94
94
  throw new Error(MISSING_CUSTOMER);
95
- yield api.postCustomerGiftCardAssign(token, requestData.cardNumber);
95
+ yield api.postCustomerGiftCardAssign(token, cardNumber);
96
96
  const giftCards = yield api.getCustomerGiftCards(token);
97
97
  dispatch(showNotification('Gift card added to your account!'));
98
- if (requestData.callback)
99
- requestData.callback();
98
+ if (callback)
99
+ callback();
100
100
  return giftCards;
101
101
  }
102
102
  catch (err) {
@@ -104,17 +104,17 @@ export const assignCustomerGiftCard = createAsyncThunk(CustomerGiftCardsActionTy
104
104
  return checkAuth(error, dispatch, () => rejectWithValue(error));
105
105
  }
106
106
  }));
107
- export const assignCustomerGiftCardOther = createAsyncThunk(CustomerGiftCardsActionType.AssignCustomerGiftCardOther, (requestData, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
107
+ export const assignCustomerGiftCardOther = createAsyncThunk(CustomerGiftCardsActionType.AssignCustomerGiftCardOther, ({ giftCardId, email, callback }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
108
108
  try {
109
109
  const api = getState().config.api;
110
110
  const token = selectToken(getState());
111
111
  if (!token)
112
112
  throw new Error(MISSING_CUSTOMER);
113
- yield api.postCustomerGiftCardAssignOther(token, requestData.giftCardId, requestData.email);
113
+ yield api.postCustomerGiftCardAssignOther(token, giftCardId, email);
114
114
  const giftCards = yield api.getCustomerGiftCards(token);
115
- dispatch(showNotification(`Gift card assigned to ${requestData.email}`));
116
- if (requestData.callback)
117
- requestData.callback();
115
+ dispatch(showNotification(`Gift card assigned to ${email}`));
116
+ if (callback)
117
+ callback();
118
118
  return giftCards;
119
119
  }
120
120
  catch (err) {
@@ -1,16 +1,16 @@
1
1
  import { AppState } from '../app';
2
- import { CustomerGiftCard, CustomerGiftCards, RequestError, RequestStatus } from '@open-tender/types';
2
+ import { GiftCard, GiftCards, RequestError, RequestStatus } from '@open-tender/types';
3
3
  export interface GiftCardsState {
4
4
  loading: RequestStatus;
5
5
  error: RequestError;
6
6
  success: boolean;
7
- giftCards: CustomerGiftCards;
7
+ giftCards: GiftCards;
8
8
  }
9
9
  export declare enum GiftCardsActionType {
10
10
  PurchaseGiftCards = "giftCards/purchaseGiftCards"
11
11
  }
12
- export declare const purchaseGiftCards: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, {
13
- data: Partial<CustomerGiftCard>;
12
+ export declare const purchaseGiftCards: import("@reduxjs/toolkit").AsyncThunk<GiftCards, {
13
+ data: Partial<GiftCard>;
14
14
  callback?: (() => void) | undefined;
15
15
  }, {
16
16
  state: AppState;
@@ -27,6 +27,6 @@ export declare const selectGiftCards: (state: AppState) => {
27
27
  success: boolean;
28
28
  loading: RequestStatus;
29
29
  error: RequestError;
30
- giftCards: CustomerGiftCards;
30
+ giftCards: GiftCards;
31
31
  };
32
32
  export declare const giftCardsReducer: import("redux").Reducer<GiftCardsState, import("redux").AnyAction>;
@@ -2,8 +2,8 @@ import { __awaiter } from "tslib";
2
2
  import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
3
3
  import { ReducerType } from './types';
4
4
  import { MISSING_CUSTOMER } from '@open-tender/types';
5
- import { resetOrder, selectTimezone, setCart, setMenuVars } from './order';
6
5
  import { isoToDate, makeSimpleCart, rehydrateCart } from '@open-tender/utils';
6
+ import { resetOrder, selectTimezone, setCart, setMenuVars } from './order';
7
7
  import { checkAuth, makeCartData, selectToken } from './customer';
8
8
  const initialState = {
9
9
  cart: [],
@@ -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<OrderRatingWithOrder, number, {
13
+ export declare const fetchOrderRating: import("@reduxjs/toolkit").AsyncThunk<OrderRatingWithOrder, string, {
14
14
  state: AppState;
15
15
  rejectValue: RequestError;
16
16
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
@@ -33,7 +33,7 @@ export declare const updateOrderRating: import("@reduxjs/toolkit").AsyncThunk<Or
33
33
  fulfilledMeta?: unknown;
34
34
  rejectedMeta?: unknown;
35
35
  }>;
36
- export declare const unsubscribeOrderRating: import("@reduxjs/toolkit").AsyncThunk<void, number, {
36
+ export declare const unsubscribeOrderRating: import("@reduxjs/toolkit").AsyncThunk<void, string, {
37
37
  state: AppState;
38
38
  rejectValue: RequestError;
39
39
  dispatch?: import("redux").Dispatch<import("redux").AnyAction> | undefined;
@@ -12,12 +12,12 @@ export var OrderRatingActionType;
12
12
  OrderRatingActionType["UpdateOrderRating"] = "orderRating/updateOrderRating";
13
13
  OrderRatingActionType["UnsubscribeOrderRating"] = "orderRating/unsubscribeOrderRating";
14
14
  })(OrderRatingActionType || (OrderRatingActionType = {}));
15
- export const fetchOrderRating = createAsyncThunk(OrderRatingActionType.FetchOrderRating, (ratingUuid, { getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
15
+ export const fetchOrderRating = createAsyncThunk(OrderRatingActionType.FetchOrderRating, (orderUuid, { getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
16
16
  const { api } = getState().config;
17
17
  if (!api)
18
18
  return;
19
19
  try {
20
- return yield api.getOrderRating(ratingUuid);
20
+ return yield api.getOrderRating(orderUuid);
21
21
  }
22
22
  catch (err) {
23
23
  return rejectWithValue(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-tender/cloud",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
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.2.4",
53
- "@open-tender/utils": "^0.1.25",
52
+ "@open-tender/types": "^0.2.6",
53
+ "@open-tender/utils": "^0.1.27",
54
54
  "@reduxjs/toolkit": "^1.8.5",
55
55
  "react": "^18.2.0"
56
56
  },