@open-tender/cloud 0.0.1

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.
Files changed (215) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +3 -0
  3. package/dist/cjs/app/hooks.d.ts +50 -0
  4. package/dist/cjs/app/hooks.js +8 -0
  5. package/dist/cjs/app/index.d.ts +1 -0
  6. package/dist/cjs/app/index.js +4 -0
  7. package/dist/cjs/app/store.d.ts +146 -0
  8. package/dist/cjs/app/store.js +51 -0
  9. package/dist/cjs/index.d.ts +3 -0
  10. package/dist/cjs/index.js +7 -0
  11. package/dist/cjs/services/api.d.ts +162 -0
  12. package/dist/cjs/services/api.js +691 -0
  13. package/dist/cjs/services/errors.d.ts +50 -0
  14. package/dist/cjs/services/errors.js +53 -0
  15. package/dist/cjs/services/index.d.ts +2 -0
  16. package/dist/cjs/services/index.js +6 -0
  17. package/dist/cjs/slices/alerts.d.ts +5 -0
  18. package/dist/cjs/slices/alerts.js +28 -0
  19. package/dist/cjs/slices/allergens.d.ts +19 -0
  20. package/dist/cjs/slices/allergens.js +66 -0
  21. package/dist/cjs/slices/announcements.d.ts +28 -0
  22. package/dist/cjs/slices/announcements.js +77 -0
  23. package/dist/cjs/slices/checkout.d.ts +38 -0
  24. package/dist/cjs/slices/checkout.js +276 -0
  25. package/dist/cjs/slices/completedOrders.d.ts +25 -0
  26. package/dist/cjs/slices/completedOrders.js +61 -0
  27. package/dist/cjs/slices/config.d.ts +87 -0
  28. package/dist/cjs/slices/config.js +121 -0
  29. package/dist/cjs/slices/confirmation.d.ts +8 -0
  30. package/dist/cjs/slices/confirmation.js +22 -0
  31. package/dist/cjs/slices/customer/account.d.ts +59 -0
  32. package/dist/cjs/slices/customer/account.js +288 -0
  33. package/dist/cjs/slices/customer/addresses.d.ts +37 -0
  34. package/dist/cjs/slices/customer/addresses.js +134 -0
  35. package/dist/cjs/slices/customer/allergens.d.ts +25 -0
  36. package/dist/cjs/slices/customer/allergens.js +94 -0
  37. package/dist/cjs/slices/customer/communicationPreferences.d.ts +44 -0
  38. package/dist/cjs/slices/customer/communicationPreferences.js +165 -0
  39. package/dist/cjs/slices/customer/creditCards.d.ts +46 -0
  40. package/dist/cjs/slices/customer/creditCards.js +172 -0
  41. package/dist/cjs/slices/customer/favorites.d.ts +45 -0
  42. package/dist/cjs/slices/customer/favorites.js +176 -0
  43. package/dist/cjs/slices/customer/fcmToken.d.ts +31 -0
  44. package/dist/cjs/slices/customer/fcmToken.js +110 -0
  45. package/dist/cjs/slices/customer/giftCards.d.ts +62 -0
  46. package/dist/cjs/slices/customer/giftCards.js +196 -0
  47. package/dist/cjs/slices/customer/groupOrders.d.ts +33 -0
  48. package/dist/cjs/slices/customer/groupOrders.js +148 -0
  49. package/dist/cjs/slices/customer/houseAccounts.d.ts +20 -0
  50. package/dist/cjs/slices/customer/houseAccounts.js +67 -0
  51. package/dist/cjs/slices/customer/index.d.ts +29 -0
  52. package/dist/cjs/slices/customer/index.js +52 -0
  53. package/dist/cjs/slices/customer/levelup.d.ts +36 -0
  54. package/dist/cjs/slices/customer/levelup.js +128 -0
  55. package/dist/cjs/slices/customer/loyalty.d.ts +27 -0
  56. package/dist/cjs/slices/customer/loyalty.js +87 -0
  57. package/dist/cjs/slices/customer/order.d.ts +25 -0
  58. package/dist/cjs/slices/customer/order.js +84 -0
  59. package/dist/cjs/slices/customer/orders.d.ts +20 -0
  60. package/dist/cjs/slices/customer/orders.js +67 -0
  61. package/dist/cjs/slices/customer/qrCode.d.ts +17 -0
  62. package/dist/cjs/slices/customer/qrCode.js +57 -0
  63. package/dist/cjs/slices/customer/rewards.d.ts +20 -0
  64. package/dist/cjs/slices/customer/rewards.js +67 -0
  65. package/dist/cjs/slices/customer/thanx.d.ts +17 -0
  66. package/dist/cjs/slices/customer/thanx.js +57 -0
  67. package/dist/cjs/slices/deals.d.ts +19 -0
  68. package/dist/cjs/slices/deals.js +97 -0
  69. package/dist/cjs/slices/donations.d.ts +26 -0
  70. package/dist/cjs/slices/donations.js +62 -0
  71. package/dist/cjs/slices/giftCards.d.ts +26 -0
  72. package/dist/cjs/slices/giftCards.js +63 -0
  73. package/dist/cjs/slices/groupOrder.d.ts +80 -0
  74. package/dist/cjs/slices/groupOrder.js +226 -0
  75. package/dist/cjs/slices/guest.d.ts +38 -0
  76. package/dist/cjs/slices/guest.js +101 -0
  77. package/dist/cjs/slices/index.d.ts +27 -0
  78. package/dist/cjs/slices/index.js +30 -0
  79. package/dist/cjs/slices/levelup.d.ts +18 -0
  80. package/dist/cjs/slices/levelup.js +51 -0
  81. package/dist/cjs/slices/menu.d.ts +22 -0
  82. package/dist/cjs/slices/menu.js +86 -0
  83. package/dist/cjs/slices/menuDisplay.d.ts +26 -0
  84. package/dist/cjs/slices/menuDisplay.js +59 -0
  85. package/dist/cjs/slices/menuItems.d.ts +20 -0
  86. package/dist/cjs/slices/menuItems.js +57 -0
  87. package/dist/cjs/slices/notifications.d.ts +5 -0
  88. package/dist/cjs/slices/notifications.js +27 -0
  89. package/dist/cjs/slices/order.d.ts +77 -0
  90. package/dist/cjs/slices/order.js +426 -0
  91. package/dist/cjs/slices/orderFulfillment.d.ts +29 -0
  92. package/dist/cjs/slices/orderFulfillment.js +83 -0
  93. package/dist/cjs/slices/orderRating.d.ts +34 -0
  94. package/dist/cjs/slices/orderRating.js +108 -0
  95. package/dist/cjs/slices/orders.d.ts +86 -0
  96. package/dist/cjs/slices/orders.js +311 -0
  97. package/dist/cjs/slices/resetPassword.d.ts +29 -0
  98. package/dist/cjs/slices/resetPassword.js +83 -0
  99. package/dist/cjs/slices/revenueCenters.d.ts +35 -0
  100. package/dist/cjs/slices/revenueCenters.js +95 -0
  101. package/dist/cjs/slices/signUp.d.ts +19 -0
  102. package/dist/cjs/slices/signUp.js +52 -0
  103. package/dist/cjs/slices/types.d.ts +43 -0
  104. package/dist/cjs/slices/types.js +47 -0
  105. package/dist/cjs/slices/validTimes.d.ts +17 -0
  106. package/dist/cjs/slices/validTimes.js +57 -0
  107. package/dist/cjs/slices/verifyAccount.d.ts +17 -0
  108. package/dist/cjs/slices/verifyAccount.js +54 -0
  109. package/dist/esm/app/hooks.d.ts +50 -0
  110. package/dist/esm/app/hooks.js +4 -0
  111. package/dist/esm/app/index.d.ts +1 -0
  112. package/dist/esm/app/index.js +1 -0
  113. package/dist/esm/app/store.d.ts +146 -0
  114. package/dist/esm/app/store.js +48 -0
  115. package/dist/esm/index.d.ts +3 -0
  116. package/dist/esm/index.js +3 -0
  117. package/dist/esm/services/api.d.ts +162 -0
  118. package/dist/esm/services/api.js +689 -0
  119. package/dist/esm/services/errors.d.ts +50 -0
  120. package/dist/esm/services/errors.js +50 -0
  121. package/dist/esm/services/index.d.ts +2 -0
  122. package/dist/esm/services/index.js +2 -0
  123. package/dist/esm/slices/alerts.d.ts +5 -0
  124. package/dist/esm/slices/alerts.js +23 -0
  125. package/dist/esm/slices/allergens.d.ts +19 -0
  126. package/dist/esm/slices/allergens.js +60 -0
  127. package/dist/esm/slices/announcements.d.ts +28 -0
  128. package/dist/esm/slices/announcements.js +71 -0
  129. package/dist/esm/slices/checkout.d.ts +38 -0
  130. package/dist/esm/slices/checkout.js +268 -0
  131. package/dist/esm/slices/completedOrders.d.ts +25 -0
  132. package/dist/esm/slices/completedOrders.js +57 -0
  133. package/dist/esm/slices/config.d.ts +87 -0
  134. package/dist/esm/slices/config.js +102 -0
  135. package/dist/esm/slices/confirmation.d.ts +8 -0
  136. package/dist/esm/slices/confirmation.js +18 -0
  137. package/dist/esm/slices/customer/account.d.ts +59 -0
  138. package/dist/esm/slices/customer/account.js +282 -0
  139. package/dist/esm/slices/customer/addresses.d.ts +37 -0
  140. package/dist/esm/slices/customer/addresses.js +129 -0
  141. package/dist/esm/slices/customer/allergens.d.ts +25 -0
  142. package/dist/esm/slices/customer/allergens.js +89 -0
  143. package/dist/esm/slices/customer/communicationPreferences.d.ts +44 -0
  144. package/dist/esm/slices/customer/communicationPreferences.js +161 -0
  145. package/dist/esm/slices/customer/creditCards.d.ts +46 -0
  146. package/dist/esm/slices/customer/creditCards.js +166 -0
  147. package/dist/esm/slices/customer/favorites.d.ts +45 -0
  148. package/dist/esm/slices/customer/favorites.js +171 -0
  149. package/dist/esm/slices/customer/fcmToken.d.ts +31 -0
  150. package/dist/esm/slices/customer/fcmToken.js +106 -0
  151. package/dist/esm/slices/customer/giftCards.d.ts +62 -0
  152. package/dist/esm/slices/customer/giftCards.js +191 -0
  153. package/dist/esm/slices/customer/groupOrders.d.ts +33 -0
  154. package/dist/esm/slices/customer/groupOrders.js +143 -0
  155. package/dist/esm/slices/customer/houseAccounts.d.ts +20 -0
  156. package/dist/esm/slices/customer/houseAccounts.js +62 -0
  157. package/dist/esm/slices/customer/index.d.ts +29 -0
  158. package/dist/esm/slices/customer/index.js +48 -0
  159. package/dist/esm/slices/customer/levelup.d.ts +36 -0
  160. package/dist/esm/slices/customer/levelup.js +123 -0
  161. package/dist/esm/slices/customer/loyalty.d.ts +27 -0
  162. package/dist/esm/slices/customer/loyalty.js +79 -0
  163. package/dist/esm/slices/customer/order.d.ts +25 -0
  164. package/dist/esm/slices/customer/order.js +79 -0
  165. package/dist/esm/slices/customer/orders.d.ts +20 -0
  166. package/dist/esm/slices/customer/orders.js +62 -0
  167. package/dist/esm/slices/customer/qrCode.d.ts +17 -0
  168. package/dist/esm/slices/customer/qrCode.js +53 -0
  169. package/dist/esm/slices/customer/rewards.d.ts +20 -0
  170. package/dist/esm/slices/customer/rewards.js +62 -0
  171. package/dist/esm/slices/customer/thanx.d.ts +17 -0
  172. package/dist/esm/slices/customer/thanx.js +53 -0
  173. package/dist/esm/slices/deals.d.ts +19 -0
  174. package/dist/esm/slices/deals.js +91 -0
  175. package/dist/esm/slices/donations.d.ts +26 -0
  176. package/dist/esm/slices/donations.js +58 -0
  177. package/dist/esm/slices/giftCards.d.ts +26 -0
  178. package/dist/esm/slices/giftCards.js +59 -0
  179. package/dist/esm/slices/groupOrder.d.ts +80 -0
  180. package/dist/esm/slices/groupOrder.js +216 -0
  181. package/dist/esm/slices/guest.d.ts +38 -0
  182. package/dist/esm/slices/guest.js +97 -0
  183. package/dist/esm/slices/index.d.ts +27 -0
  184. package/dist/esm/slices/index.js +27 -0
  185. package/dist/esm/slices/levelup.d.ts +18 -0
  186. package/dist/esm/slices/levelup.js +48 -0
  187. package/dist/esm/slices/menu.d.ts +22 -0
  188. package/dist/esm/slices/menu.js +81 -0
  189. package/dist/esm/slices/menuDisplay.d.ts +26 -0
  190. package/dist/esm/slices/menuDisplay.js +55 -0
  191. package/dist/esm/slices/menuItems.d.ts +20 -0
  192. package/dist/esm/slices/menuItems.js +52 -0
  193. package/dist/esm/slices/notifications.d.ts +5 -0
  194. package/dist/esm/slices/notifications.js +22 -0
  195. package/dist/esm/slices/order.d.ts +77 -0
  196. package/dist/esm/slices/order.js +423 -0
  197. package/dist/esm/slices/orderFulfillment.d.ts +29 -0
  198. package/dist/esm/slices/orderFulfillment.js +79 -0
  199. package/dist/esm/slices/orderRating.d.ts +34 -0
  200. package/dist/esm/slices/orderRating.js +104 -0
  201. package/dist/esm/slices/orders.d.ts +86 -0
  202. package/dist/esm/slices/orders.js +302 -0
  203. package/dist/esm/slices/resetPassword.d.ts +29 -0
  204. package/dist/esm/slices/resetPassword.js +79 -0
  205. package/dist/esm/slices/revenueCenters.d.ts +35 -0
  206. package/dist/esm/slices/revenueCenters.js +89 -0
  207. package/dist/esm/slices/signUp.d.ts +19 -0
  208. package/dist/esm/slices/signUp.js +48 -0
  209. package/dist/esm/slices/types.d.ts +43 -0
  210. package/dist/esm/slices/types.js +44 -0
  211. package/dist/esm/slices/validTimes.d.ts +17 -0
  212. package/dist/esm/slices/validTimes.js +52 -0
  213. package/dist/esm/slices/verifyAccount.d.ts +17 -0
  214. package/dist/esm/slices/verifyAccount.js +50 -0
  215. package/package.json +61 -0
@@ -0,0 +1,45 @@
1
+ import { AppState } from '../../app';
2
+ import { Favorite, Favorites, RequestError, RequestStatus } from '@open-tender/types';
3
+ export interface CustomerFavoritesState {
4
+ entities: Favorites;
5
+ error: RequestError;
6
+ loading: RequestStatus;
7
+ lookup: {
8
+ [key: number]: number;
9
+ };
10
+ }
11
+ export declare enum CustomerFavoritesActionType {
12
+ FetchCustomerFavorites = "customer/fetchCustomerFavorites",
13
+ UpdateCustomerFavorite = "customer/updateCustomerFavorite",
14
+ RemoveCustomerFavorite = "customer/removeCustomerFavorite",
15
+ AddCustomerFavorite = "customer/addCustomerFavorite"
16
+ }
17
+ export declare const fetchCustomerFavorites: import("@reduxjs/toolkit").AsyncThunk<Favorites, void, {
18
+ state: AppState;
19
+ rejectValue: RequestError;
20
+ }>;
21
+ export declare const updateCustomerFavorite: import("@reduxjs/toolkit").AsyncThunk<Favorites, {
22
+ favoriteId: number;
23
+ data: Favorite;
24
+ callback?: (() => void) | undefined;
25
+ }, {
26
+ state: AppState;
27
+ rejectValue: RequestError;
28
+ }>;
29
+ export declare const removeCustomerFavorite: import("@reduxjs/toolkit").AsyncThunk<Favorites, {
30
+ favoriteId: number;
31
+ callback?: (() => void) | undefined;
32
+ }, {
33
+ state: AppState;
34
+ rejectValue: RequestError;
35
+ }>;
36
+ export declare const addCustomerFavorite: import("@reduxjs/toolkit").AsyncThunk<Favorites, {
37
+ data: Favorite;
38
+ callback?: (() => void) | undefined;
39
+ }, {
40
+ state: AppState;
41
+ rejectValue: RequestError;
42
+ }>;
43
+ export declare const resetCustomerFavorites: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetCustomerFavoritesError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setCustomerFavorites: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>, setCustomerFavoritesLookup: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>;
44
+ export declare const selectCustomerFavorites: (state: AppState) => CustomerFavoritesState;
45
+ export declare const customerFavoritesReducer: import("redux").Reducer<CustomerFavoritesState, import("redux").AnyAction>;
@@ -0,0 +1,171 @@
1
+ import { __awaiter } from "tslib";
2
+ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
3
+ import { ReducerType } from '../types';
4
+ import { MISSING_CUSTOMER } from '@open-tender/types';
5
+ import { checkAuth, selectToken } from './account';
6
+ import { showNotification } from '../notifications';
7
+ import { makeFavoritesLookup, makeFormErrors } from '@open-tender/utils';
8
+ const initialState = {
9
+ entities: [],
10
+ error: null,
11
+ loading: 'idle',
12
+ lookup: {}
13
+ };
14
+ export var CustomerFavoritesActionType;
15
+ (function (CustomerFavoritesActionType) {
16
+ CustomerFavoritesActionType["FetchCustomerFavorites"] = "customer/fetchCustomerFavorites";
17
+ CustomerFavoritesActionType["UpdateCustomerFavorite"] = "customer/updateCustomerFavorite";
18
+ CustomerFavoritesActionType["RemoveCustomerFavorite"] = "customer/removeCustomerFavorite";
19
+ CustomerFavoritesActionType["AddCustomerFavorite"] = "customer/addCustomerFavorite";
20
+ })(CustomerFavoritesActionType || (CustomerFavoritesActionType = {}));
21
+ export const fetchCustomerFavorites = createAsyncThunk(CustomerFavoritesActionType.FetchCustomerFavorites, (_, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
22
+ try {
23
+ const api = getState().config.api;
24
+ const token = selectToken(getState());
25
+ if (!token)
26
+ throw new Error(MISSING_CUSTOMER);
27
+ const { data: favorites } = yield api.getCustomerFavorites(token);
28
+ const lookup = makeFavoritesLookup(favorites);
29
+ dispatch(setCustomerFavoritesLookup(lookup));
30
+ return favorites;
31
+ }
32
+ catch (err) {
33
+ const error = err;
34
+ return checkAuth(error, dispatch, () => rejectWithValue(error));
35
+ }
36
+ }));
37
+ export const updateCustomerFavorite = createAsyncThunk(CustomerFavoritesActionType.UpdateCustomerFavorite, (requestData, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
38
+ try {
39
+ const api = getState().config.api;
40
+ const token = selectToken(getState());
41
+ if (!token)
42
+ throw new Error(MISSING_CUSTOMER);
43
+ yield api.putCustomerFavorite(token, requestData.favoriteId, requestData.data);
44
+ const { data: favorites } = yield api.getCustomerFavorites(token);
45
+ const lookup = makeFavoritesLookup(favorites);
46
+ dispatch(setCustomerFavoritesLookup(lookup));
47
+ dispatch(showNotification('Favorite updated!'));
48
+ if (requestData.callback)
49
+ requestData.callback();
50
+ return favorites;
51
+ }
52
+ catch (err) {
53
+ const error = err;
54
+ const errors = makeFormErrors(error);
55
+ return checkAuth(error, dispatch, () => rejectWithValue(errors));
56
+ }
57
+ }));
58
+ export const removeCustomerFavorite = createAsyncThunk(CustomerFavoritesActionType.RemoveCustomerFavorite, (requestData, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
59
+ try {
60
+ const api = getState().config.api;
61
+ const token = selectToken(getState());
62
+ if (!token)
63
+ throw new Error(MISSING_CUSTOMER);
64
+ yield api.deleteCustomerFavorite(token, requestData.favoriteId);
65
+ const { data: favorites } = yield api.getCustomerFavorites(token);
66
+ const lookup = makeFavoritesLookup(favorites);
67
+ dispatch(setCustomerFavoritesLookup(lookup));
68
+ if (requestData.callback)
69
+ requestData.callback();
70
+ return favorites;
71
+ }
72
+ catch (err) {
73
+ const error = err;
74
+ return checkAuth(error, dispatch, () => rejectWithValue(error));
75
+ }
76
+ }));
77
+ export const addCustomerFavorite = createAsyncThunk(CustomerFavoritesActionType.AddCustomerFavorite, (requestData, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
78
+ try {
79
+ const api = getState().config.api;
80
+ const token = selectToken(getState());
81
+ if (!token)
82
+ throw new Error(MISSING_CUSTOMER);
83
+ if (!requestData.data.name)
84
+ requestData.data.name = '';
85
+ yield api.postCustomerFavorite(token, requestData.data);
86
+ const { data: favorites } = yield api.getCustomerFavorites(token);
87
+ const lookup = makeFavoritesLookup(favorites);
88
+ dispatch(setCustomerFavoritesLookup(lookup));
89
+ if (requestData.callback)
90
+ requestData.callback();
91
+ return favorites;
92
+ }
93
+ catch (err) {
94
+ const error = err;
95
+ const errors = makeFormErrors(error);
96
+ return checkAuth(error, dispatch, () => rejectWithValue(errors));
97
+ }
98
+ }));
99
+ const customerFavoritesSlice = createSlice({
100
+ name: ReducerType.Favorites,
101
+ initialState,
102
+ reducers: {
103
+ resetCustomerFavorites: () => initialState,
104
+ resetCustomerFavoritesError: state => {
105
+ state.error = null;
106
+ state.loading = 'idle';
107
+ },
108
+ setCustomerFavorites: (state, action) => {
109
+ state.entities = action.payload;
110
+ state.error = null;
111
+ },
112
+ setCustomerFavoritesLookup: (state, action) => {
113
+ state.lookup = action.payload;
114
+ state.error = null;
115
+ }
116
+ },
117
+ extraReducers: builder => {
118
+ builder
119
+ .addCase(fetchCustomerFavorites.fulfilled, (state, action) => {
120
+ state.entities = action.payload;
121
+ state.loading = 'idle';
122
+ state.error = null;
123
+ })
124
+ .addCase(fetchCustomerFavorites.pending, state => {
125
+ state.loading = 'pending';
126
+ })
127
+ .addCase(fetchCustomerFavorites.rejected, (state, action) => {
128
+ state.error = action.payload;
129
+ state.loading = 'idle';
130
+ })
131
+ .addCase(updateCustomerFavorite.fulfilled, (state, action) => {
132
+ state.entities = action.payload;
133
+ state.loading = 'idle';
134
+ state.error = null;
135
+ })
136
+ .addCase(updateCustomerFavorite.pending, state => {
137
+ state.loading = 'pending';
138
+ })
139
+ .addCase(updateCustomerFavorite.rejected, (state, action) => {
140
+ state.error = action.payload;
141
+ state.loading = 'idle';
142
+ })
143
+ .addCase(removeCustomerFavorite.fulfilled, (state, action) => {
144
+ state.entities = action.payload;
145
+ state.loading = 'idle';
146
+ state.error = null;
147
+ })
148
+ .addCase(removeCustomerFavorite.pending, state => {
149
+ state.loading = 'pending';
150
+ })
151
+ .addCase(removeCustomerFavorite.rejected, (state, action) => {
152
+ state.error = action.payload;
153
+ state.loading = 'idle';
154
+ })
155
+ .addCase(addCustomerFavorite.fulfilled, (state, action) => {
156
+ state.entities = action.payload;
157
+ state.loading = 'idle';
158
+ state.error = null;
159
+ })
160
+ .addCase(addCustomerFavorite.pending, state => {
161
+ state.loading = 'pending';
162
+ })
163
+ .addCase(addCustomerFavorite.rejected, (state, action) => {
164
+ state.error = action.payload;
165
+ state.loading = 'idle';
166
+ });
167
+ }
168
+ });
169
+ export const { resetCustomerFavorites, resetCustomerFavoritesError, setCustomerFavorites, setCustomerFavoritesLookup } = customerFavoritesSlice.actions;
170
+ export const selectCustomerFavorites = (state) => state.customer.favorites;
171
+ export const customerFavoritesReducer = customerFavoritesSlice.reducer;
@@ -0,0 +1,31 @@
1
+ import { AppState } from '../../app';
2
+ import { RequestError, RequestStatus } from '@open-tender/types';
3
+ export interface CustomerFcmTokenState {
4
+ error: RequestError;
5
+ loading: RequestStatus;
6
+ }
7
+ export declare enum CustomerFcmTokenActionType {
8
+ FetchCustomerFcmTokens = "customer/fetchCustomerFcmTokens",
9
+ RemoveCustomerFcmTokens = "customer/removeCustomerFcmTokens",
10
+ AddCustomerFcmToken = "customer/addCustomerFcmToken"
11
+ }
12
+ export declare const fetchCustomerFcmTokens: import("@reduxjs/toolkit").AsyncThunk<void, void, {
13
+ state: AppState;
14
+ rejectValue: RequestError;
15
+ }>;
16
+ export declare const removeCustomerFcmTokens: import("@reduxjs/toolkit").AsyncThunk<void, {
17
+ callback?: (() => void) | undefined;
18
+ }, {
19
+ state: AppState;
20
+ rejectValue: RequestError;
21
+ }>;
22
+ export declare const addCustomerFcmToken: import("@reduxjs/toolkit").AsyncThunk<void, {
23
+ fcmToken: string;
24
+ callback?: (() => void) | undefined;
25
+ }, {
26
+ state: AppState;
27
+ rejectValue: RequestError;
28
+ }>;
29
+ export declare const resetCustomerFcmToken: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
30
+ export declare const selectCustomerFcmToken: (state: AppState) => CustomerFcmTokenState;
31
+ export declare const customerFcmTokenReducer: import("redux").Reducer<CustomerFcmTokenState, import("redux").AnyAction>;
@@ -0,0 +1,106 @@
1
+ import { __awaiter } from "tslib";
2
+ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
3
+ import { ReducerType } from '../types';
4
+ import { MISSING_CUSTOMER } from '@open-tender/types';
5
+ import { checkAuth, selectToken } from './account';
6
+ const initialState = {
7
+ error: null,
8
+ loading: 'idle'
9
+ };
10
+ export var CustomerFcmTokenActionType;
11
+ (function (CustomerFcmTokenActionType) {
12
+ CustomerFcmTokenActionType["FetchCustomerFcmTokens"] = "customer/fetchCustomerFcmTokens";
13
+ CustomerFcmTokenActionType["RemoveCustomerFcmTokens"] = "customer/removeCustomerFcmTokens";
14
+ CustomerFcmTokenActionType["AddCustomerFcmToken"] = "customer/addCustomerFcmToken";
15
+ })(CustomerFcmTokenActionType || (CustomerFcmTokenActionType = {}));
16
+ export const fetchCustomerFcmTokens = createAsyncThunk(CustomerFcmTokenActionType.FetchCustomerFcmTokens, (_, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
17
+ try {
18
+ const api = getState().config.api;
19
+ const token = selectToken(getState());
20
+ if (!token)
21
+ throw new Error(MISSING_CUSTOMER);
22
+ return yield api.getCustomerFcmToken(token);
23
+ }
24
+ catch (err) {
25
+ const error = err;
26
+ return checkAuth(error, dispatch, () => rejectWithValue(error));
27
+ }
28
+ }));
29
+ export const removeCustomerFcmTokens = createAsyncThunk(CustomerFcmTokenActionType.RemoveCustomerFcmTokens, (requestData, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
30
+ try {
31
+ const api = getState().config.api;
32
+ const token = selectToken(getState());
33
+ if (!token)
34
+ throw new Error(MISSING_CUSTOMER);
35
+ const response = yield api.deleteCustomerFcmToken(token);
36
+ if (requestData.callback)
37
+ requestData.callback();
38
+ return response;
39
+ }
40
+ catch (err) {
41
+ const error = err;
42
+ return checkAuth(error, dispatch, () => rejectWithValue(error));
43
+ }
44
+ }));
45
+ export const addCustomerFcmToken = createAsyncThunk(CustomerFcmTokenActionType.AddCustomerFcmToken, (requestData, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
46
+ try {
47
+ const api = getState().config.api;
48
+ const token = selectToken(getState());
49
+ if (!token)
50
+ throw new Error(MISSING_CUSTOMER);
51
+ const response = yield api.postCustomerFcmToken(token, requestData.fcmToken);
52
+ if (requestData.callback)
53
+ requestData.callback();
54
+ return response;
55
+ }
56
+ catch (err) {
57
+ const error = err;
58
+ return checkAuth(error, dispatch, () => rejectWithValue(error));
59
+ }
60
+ }));
61
+ const customerFcmTokenSlice = createSlice({
62
+ name: ReducerType.FcmToken,
63
+ initialState,
64
+ reducers: {
65
+ resetCustomerFcmToken: () => initialState
66
+ },
67
+ extraReducers: builder => {
68
+ builder
69
+ .addCase(fetchCustomerFcmTokens.fulfilled, state => {
70
+ state.loading = 'idle';
71
+ state.error = null;
72
+ })
73
+ .addCase(fetchCustomerFcmTokens.pending, state => {
74
+ state.loading = 'pending';
75
+ })
76
+ .addCase(fetchCustomerFcmTokens.rejected, (state, action) => {
77
+ state.error = action.payload;
78
+ state.loading = 'idle';
79
+ })
80
+ .addCase(removeCustomerFcmTokens.fulfilled, state => {
81
+ state.loading = 'idle';
82
+ state.error = null;
83
+ })
84
+ .addCase(removeCustomerFcmTokens.pending, state => {
85
+ state.loading = 'pending';
86
+ })
87
+ .addCase(removeCustomerFcmTokens.rejected, (state, action) => {
88
+ state.error = action.payload;
89
+ state.loading = 'idle';
90
+ })
91
+ .addCase(addCustomerFcmToken.fulfilled, state => {
92
+ state.loading = 'idle';
93
+ state.error = null;
94
+ })
95
+ .addCase(addCustomerFcmToken.pending, state => {
96
+ state.loading = 'pending';
97
+ })
98
+ .addCase(addCustomerFcmToken.rejected, (state, action) => {
99
+ state.error = action.payload;
100
+ state.loading = 'idle';
101
+ });
102
+ }
103
+ });
104
+ export const { resetCustomerFcmToken } = customerFcmTokenSlice.actions;
105
+ export const selectCustomerFcmToken = (state) => state.customer.fcmToken;
106
+ export const customerFcmTokenReducer = customerFcmTokenSlice.reducer;
@@ -0,0 +1,62 @@
1
+ import { AppState } from '../../app';
2
+ import { CustomerGiftCard, CustomerGiftCards, RequestError, RequestStatus } from '@open-tender/types';
3
+ export interface CustomerGiftCardsState {
4
+ entities: CustomerGiftCards;
5
+ error: RequestError;
6
+ loading: RequestStatus;
7
+ lookup: {
8
+ [key: number]: number;
9
+ };
10
+ }
11
+ export declare enum CustomerGiftCardsActionType {
12
+ FetchCustomerGiftCards = "customer/fetchCustomerGiftCards",
13
+ RemoveCustomerGiftCard = "customer/removeCustomerGiftCard",
14
+ AddCustomerGiftCard = "customer/addCustomerGiftCard",
15
+ AssignCustomerGiftCard = "customer/assignCustomerGiftCard",
16
+ AssignCustomerGiftCardOther = "customer/assignCustomerGiftCardOther",
17
+ UpdateCustomerGiftCard = "customer/updateCustomerGiftCard"
18
+ }
19
+ export declare const fetchCustomerGiftCards: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, void, {
20
+ state: AppState;
21
+ rejectValue: RequestError;
22
+ }>;
23
+ export declare const updateCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, {
24
+ giftCardId: number;
25
+ data: CustomerGiftCard;
26
+ callback?: (() => void) | undefined;
27
+ }, {
28
+ state: AppState;
29
+ rejectValue: RequestError;
30
+ }>;
31
+ export declare const removeCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, {
32
+ giftCardId: number;
33
+ callback?: (() => void) | undefined;
34
+ }, {
35
+ state: AppState;
36
+ rejectValue: RequestError;
37
+ }>;
38
+ export declare const addCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, {
39
+ data: CustomerGiftCard;
40
+ callback?: (() => void) | undefined;
41
+ }, {
42
+ state: AppState;
43
+ rejectValue: RequestError;
44
+ }>;
45
+ export declare const assignCustomerGiftCard: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, {
46
+ cardNumber: string;
47
+ callback?: (() => void) | undefined;
48
+ }, {
49
+ state: AppState;
50
+ rejectValue: RequestError;
51
+ }>;
52
+ export declare const assignCustomerGiftCardOther: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, {
53
+ giftCardId: number;
54
+ email: string;
55
+ callback?: (() => void) | undefined;
56
+ }, {
57
+ state: AppState;
58
+ rejectValue: RequestError;
59
+ }>;
60
+ export declare const resetCustomerGiftCards: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetCustomerGiftCardsError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setCustomerGiftCards: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>;
61
+ export declare const selectCustomerGiftCards: (state: AppState) => CustomerGiftCardsState;
62
+ export declare const customerGiftCardsReducer: import("redux").Reducer<CustomerGiftCardsState, import("redux").AnyAction>;
@@ -0,0 +1,191 @@
1
+ import { __awaiter } from "tslib";
2
+ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
3
+ import { ReducerType } from '../types';
4
+ import { MISSING_CUSTOMER } from '@open-tender/types';
5
+ import { checkAuth, selectToken } from './account';
6
+ import { showNotification } from '../notifications';
7
+ const initialState = {
8
+ entities: [],
9
+ error: null,
10
+ loading: 'idle',
11
+ lookup: {}
12
+ };
13
+ export var CustomerGiftCardsActionType;
14
+ (function (CustomerGiftCardsActionType) {
15
+ CustomerGiftCardsActionType["FetchCustomerGiftCards"] = "customer/fetchCustomerGiftCards";
16
+ CustomerGiftCardsActionType["RemoveCustomerGiftCard"] = "customer/removeCustomerGiftCard";
17
+ CustomerGiftCardsActionType["AddCustomerGiftCard"] = "customer/addCustomerGiftCard";
18
+ CustomerGiftCardsActionType["AssignCustomerGiftCard"] = "customer/assignCustomerGiftCard";
19
+ CustomerGiftCardsActionType["AssignCustomerGiftCardOther"] = "customer/assignCustomerGiftCardOther";
20
+ CustomerGiftCardsActionType["UpdateCustomerGiftCard"] = "customer/updateCustomerGiftCard";
21
+ })(CustomerGiftCardsActionType || (CustomerGiftCardsActionType = {}));
22
+ export const fetchCustomerGiftCards = createAsyncThunk(CustomerGiftCardsActionType.FetchCustomerGiftCards, (_, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
23
+ try {
24
+ const api = getState().config.api;
25
+ const token = selectToken(getState());
26
+ if (!token)
27
+ throw new Error(MISSING_CUSTOMER);
28
+ return yield api.getCustomerGiftCards(token);
29
+ }
30
+ catch (err) {
31
+ const error = err;
32
+ return checkAuth(error, dispatch, () => rejectWithValue(error));
33
+ }
34
+ }));
35
+ export const updateCustomerGiftCard = createAsyncThunk(CustomerGiftCardsActionType.UpdateCustomerGiftCard, (requestData, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
36
+ try {
37
+ const api = getState().config.api;
38
+ const token = selectToken(getState());
39
+ if (!token)
40
+ throw new Error(MISSING_CUSTOMER);
41
+ yield api.putCustomerGiftCard(token, requestData.giftCardId, requestData.data);
42
+ const giftCards = yield api.getCustomerGiftCards(token);
43
+ dispatch(showNotification('Gift card balance updated!'));
44
+ if (requestData.callback)
45
+ requestData.callback();
46
+ return giftCards;
47
+ }
48
+ catch (err) {
49
+ const error = err;
50
+ return checkAuth(error, dispatch, () => rejectWithValue(error));
51
+ }
52
+ }));
53
+ export const removeCustomerGiftCard = createAsyncThunk(CustomerGiftCardsActionType.RemoveCustomerGiftCard, (requestData, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
54
+ try {
55
+ const api = getState().config.api;
56
+ const token = selectToken(getState());
57
+ if (!token)
58
+ throw new Error(MISSING_CUSTOMER);
59
+ yield api.deleteCustomerGiftCard(token, requestData.giftCardId);
60
+ const giftCards = yield api.getCustomerGiftCards(token);
61
+ dispatch(showNotification('Gift card removed!'));
62
+ if (requestData.callback)
63
+ requestData.callback();
64
+ return giftCards;
65
+ }
66
+ catch (err) {
67
+ const error = err;
68
+ return checkAuth(error, dispatch, () => rejectWithValue(error));
69
+ }
70
+ }));
71
+ export const addCustomerGiftCard = createAsyncThunk(CustomerGiftCardsActionType.AddCustomerGiftCard, (requestData, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
72
+ try {
73
+ const api = getState().config.api;
74
+ const token = selectToken(getState());
75
+ if (!token)
76
+ throw new Error(MISSING_CUSTOMER);
77
+ yield api.postCustomerGiftCard(token, requestData.data);
78
+ const giftCards = yield api.getCustomerGiftCards(token);
79
+ dispatch(showNotification('Gift card added!'));
80
+ if (requestData.callback)
81
+ requestData.callback();
82
+ return giftCards;
83
+ }
84
+ catch (err) {
85
+ const error = err;
86
+ return checkAuth(error, dispatch, () => rejectWithValue(error));
87
+ }
88
+ }));
89
+ export const assignCustomerGiftCard = createAsyncThunk(CustomerGiftCardsActionType.AssignCustomerGiftCard, (requestData, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
90
+ try {
91
+ const api = getState().config.api;
92
+ const token = selectToken(getState());
93
+ if (!token)
94
+ throw new Error(MISSING_CUSTOMER);
95
+ yield api.postCustomerGiftCardAssign(token, requestData.cardNumber);
96
+ const giftCards = yield api.getCustomerGiftCards(token);
97
+ dispatch(showNotification('Gift card added to your account!'));
98
+ if (requestData.callback)
99
+ requestData.callback();
100
+ return giftCards;
101
+ }
102
+ catch (err) {
103
+ const error = err;
104
+ return checkAuth(error, dispatch, () => rejectWithValue(error));
105
+ }
106
+ }));
107
+ export const assignCustomerGiftCardOther = createAsyncThunk(CustomerGiftCardsActionType.AssignCustomerGiftCardOther, (requestData, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
108
+ try {
109
+ const api = getState().config.api;
110
+ const token = selectToken(getState());
111
+ if (!token)
112
+ throw new Error(MISSING_CUSTOMER);
113
+ yield api.postCustomerGiftCardAssignOther(token, requestData.giftCardId, requestData.email);
114
+ const giftCards = yield api.getCustomerGiftCards(token);
115
+ dispatch(showNotification(`Gift card assigned to ${requestData.email}`));
116
+ if (requestData.callback)
117
+ requestData.callback();
118
+ return giftCards;
119
+ }
120
+ catch (err) {
121
+ const error = err;
122
+ return checkAuth(error, dispatch, () => rejectWithValue(error));
123
+ }
124
+ }));
125
+ const customerGiftCardsSlice = createSlice({
126
+ name: ReducerType.GiftCards,
127
+ initialState,
128
+ reducers: {
129
+ resetCustomerGiftCards: () => initialState,
130
+ resetCustomerGiftCardsError: state => {
131
+ state.error = null;
132
+ state.loading = 'idle';
133
+ },
134
+ setCustomerGiftCards: (state, action) => {
135
+ state.entities = action.payload;
136
+ state.error = null;
137
+ }
138
+ },
139
+ extraReducers: builder => {
140
+ builder
141
+ .addCase(fetchCustomerGiftCards.fulfilled, (state, action) => {
142
+ state.entities = action.payload;
143
+ state.loading = 'idle';
144
+ state.error = null;
145
+ })
146
+ .addCase(fetchCustomerGiftCards.pending, state => {
147
+ state.loading = 'pending';
148
+ })
149
+ .addCase(fetchCustomerGiftCards.rejected, (state, action) => {
150
+ state.error = action.payload;
151
+ state.loading = 'idle';
152
+ })
153
+ .addCase(removeCustomerGiftCard.fulfilled, state => {
154
+ state.loading = 'idle';
155
+ state.error = null;
156
+ })
157
+ .addCase(removeCustomerGiftCard.pending, state => {
158
+ state.loading = 'pending';
159
+ })
160
+ .addCase(removeCustomerGiftCard.rejected, (state, action) => {
161
+ state.error = action.payload;
162
+ state.loading = 'idle';
163
+ })
164
+ .addCase(addCustomerGiftCard.fulfilled, state => {
165
+ state.loading = 'idle';
166
+ state.error = null;
167
+ })
168
+ .addCase(addCustomerGiftCard.pending, state => {
169
+ state.loading = 'pending';
170
+ })
171
+ .addCase(addCustomerGiftCard.rejected, (state, action) => {
172
+ state.error = action.payload;
173
+ state.loading = 'idle';
174
+ })
175
+ .addCase(updateCustomerGiftCard.fulfilled, (state, action) => {
176
+ state.entities = action.payload;
177
+ state.loading = 'idle';
178
+ state.error = null;
179
+ })
180
+ .addCase(updateCustomerGiftCard.pending, state => {
181
+ state.loading = 'pending';
182
+ })
183
+ .addCase(updateCustomerGiftCard.rejected, (state, action) => {
184
+ state.error = action.payload;
185
+ state.loading = 'idle';
186
+ });
187
+ }
188
+ });
189
+ export const { resetCustomerGiftCards, resetCustomerGiftCardsError, setCustomerGiftCards } = customerGiftCardsSlice.actions;
190
+ export const selectCustomerGiftCards = (state) => state.customer.giftCards;
191
+ export const customerGiftCardsReducer = customerGiftCardsSlice.reducer;
@@ -0,0 +1,33 @@
1
+ import { AppState } from '../../app';
2
+ import { GroupOrder, GroupOrders, RequestError, RequestStatus } from '@open-tender/types';
3
+ export interface CustomerGroupOrdersState {
4
+ entities: GroupOrders;
5
+ error: RequestError;
6
+ loading: RequestStatus;
7
+ lookup: {
8
+ [key: number]: number;
9
+ };
10
+ }
11
+ export declare enum CustomerGroupOrdersActionType {
12
+ FetchCustomerGroupOrders = "customer/fetchCustomerGroupOrders",
13
+ FetchCustomerGroupOrder = "customer/fetchCustomerGroupOrder",
14
+ AddCustomerGroupOrder = "customer/addCustomerGroupOrder"
15
+ }
16
+ export declare const fetchCustomerGroupOrders: import("@reduxjs/toolkit").AsyncThunk<GroupOrders, void, {
17
+ state: AppState;
18
+ rejectValue: RequestError;
19
+ }>;
20
+ export declare const fetchCustomerGroupOrder: import("@reduxjs/toolkit").AsyncThunk<GroupOrders, number, {
21
+ state: AppState;
22
+ rejectValue: RequestError;
23
+ }>;
24
+ export declare const addCustomerGroupOrder: import("@reduxjs/toolkit").AsyncThunk<GroupOrders, {
25
+ data: Partial<GroupOrder>;
26
+ callback?: (() => void) | undefined;
27
+ }, {
28
+ state: AppState;
29
+ rejectValue: RequestError;
30
+ }>;
31
+ export declare const resetCustomerGroupOrders: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetCustomerGroupOrdersError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setCustomerGroupOrders: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>;
32
+ export declare const selectCustomerGroupOrders: (state: AppState) => CustomerGroupOrdersState;
33
+ export declare const customerGroupOrdersReducer: import("redux").Reducer<CustomerGroupOrdersState, import("redux").AnyAction>;