@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,79 @@
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
+ entity: {},
9
+ error: null,
10
+ loading: 'idle'
11
+ };
12
+ export var CustomerOrderActionType;
13
+ (function (CustomerOrderActionType) {
14
+ CustomerOrderActionType["FetchCustomerOrder"] = "customer/fetchCustomerOrder";
15
+ CustomerOrderActionType["UpdateCustomerFavorite"] = "customer/updateCustomerFavorite";
16
+ })(CustomerOrderActionType || (CustomerOrderActionType = {}));
17
+ export const fetchCustomerOrder = createAsyncThunk(CustomerOrderActionType.FetchCustomerOrder, (orderId, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
18
+ try {
19
+ const api = getState().config.api;
20
+ const token = selectToken(getState());
21
+ if (!token)
22
+ throw new Error(MISSING_CUSTOMER);
23
+ const order = yield api.getCustomerOrder(token, orderId);
24
+ return order;
25
+ }
26
+ catch (err) {
27
+ const error = err;
28
+ return checkAuth(error, dispatch, () => rejectWithValue(error));
29
+ }
30
+ }));
31
+ export const updateCustomerOrderRating = createAsyncThunk(CustomerOrderActionType.FetchCustomerOrder, (requestData, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
32
+ try {
33
+ const api = getState().config.api;
34
+ const token = selectToken(getState());
35
+ if (!token)
36
+ throw new Error(MISSING_CUSTOMER);
37
+ const response = yield api.putCustomerOrderRating(token, requestData.orderId, requestData.data);
38
+ dispatch(fetchCustomerOrder(requestData.orderId));
39
+ dispatch(showNotification('Rating updated!'));
40
+ return response;
41
+ }
42
+ catch (err) {
43
+ const error = err;
44
+ return checkAuth(error, dispatch, () => rejectWithValue(error));
45
+ }
46
+ }));
47
+ const customerOrderSlice = createSlice({
48
+ name: ReducerType.Order,
49
+ initialState,
50
+ reducers: {
51
+ resetCustomerOrder: () => initialState,
52
+ resetCustomerOrderError: state => {
53
+ state.error = null;
54
+ state.loading = 'idle';
55
+ },
56
+ setCustomerOrder: (state, action) => {
57
+ state.entity = action.payload;
58
+ state.error = null;
59
+ }
60
+ },
61
+ extraReducers: builder => {
62
+ builder
63
+ .addCase(fetchCustomerOrder.fulfilled, (state, action) => {
64
+ state.entity = action.payload;
65
+ state.loading = 'idle';
66
+ state.error = null;
67
+ })
68
+ .addCase(fetchCustomerOrder.pending, state => {
69
+ state.loading = 'pending';
70
+ })
71
+ .addCase(fetchCustomerOrder.rejected, (state, action) => {
72
+ state.error = action.payload;
73
+ state.loading = 'idle';
74
+ });
75
+ }
76
+ });
77
+ export const { resetCustomerOrder, resetCustomerOrderError, setCustomerOrder } = customerOrderSlice.actions;
78
+ export const selectCustomerOrder = (state) => state.customer.order;
79
+ export const customerOrderReducer = customerOrderSlice.reducer;
@@ -0,0 +1,20 @@
1
+ import { AppState } from '../../app';
2
+ import { Orders, RequestError, RequestStatus } from '@open-tender/types';
3
+ export interface CustomerOrdersState {
4
+ entities: Orders;
5
+ error: RequestError;
6
+ loading: RequestStatus;
7
+ lookup: {
8
+ [key: number]: number;
9
+ };
10
+ }
11
+ export declare enum CustomerOrdersActionType {
12
+ FetchCustomerOrders = "customer/fetchCustomerOrders"
13
+ }
14
+ export declare const fetchCustomerOrders: import("@reduxjs/toolkit").AsyncThunk<Orders, number, {
15
+ state: AppState;
16
+ rejectValue: RequestError;
17
+ }>;
18
+ export declare const resetCustomerOrders: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetCustomerOrdersError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setCustomerOrders: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>;
19
+ export declare const selectCustomerOrders: (state: AppState) => CustomerOrdersState;
20
+ export declare const customerOrdersReducer: import("redux").Reducer<CustomerOrdersState, import("redux").AnyAction>;
@@ -0,0 +1,62 @@
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
+ entities: [],
8
+ error: null,
9
+ loading: 'idle',
10
+ lookup: {}
11
+ };
12
+ export var CustomerOrdersActionType;
13
+ (function (CustomerOrdersActionType) {
14
+ CustomerOrdersActionType["FetchCustomerOrders"] = "customer/fetchCustomerOrders";
15
+ })(CustomerOrdersActionType || (CustomerOrdersActionType = {}));
16
+ export const fetchCustomerOrders = createAsyncThunk(CustomerOrdersActionType.FetchCustomerOrders, (limit, { 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
+ const { data: orders } = yield api.getCustomerOrders(token, limit);
23
+ return orders;
24
+ }
25
+ catch (err) {
26
+ const error = err;
27
+ return checkAuth(error, dispatch, () => rejectWithValue(error));
28
+ }
29
+ }));
30
+ const customerOrdersSlice = createSlice({
31
+ name: ReducerType.Orders,
32
+ initialState,
33
+ reducers: {
34
+ resetCustomerOrders: () => initialState,
35
+ resetCustomerOrdersError: state => {
36
+ state.error = null;
37
+ state.loading = 'idle';
38
+ },
39
+ setCustomerOrders: (state, action) => {
40
+ state.entities = action.payload;
41
+ state.error = null;
42
+ }
43
+ },
44
+ extraReducers: builder => {
45
+ builder
46
+ .addCase(fetchCustomerOrders.fulfilled, (state, action) => {
47
+ state.entities = action.payload;
48
+ state.loading = 'idle';
49
+ state.error = null;
50
+ })
51
+ .addCase(fetchCustomerOrders.pending, state => {
52
+ state.loading = 'pending';
53
+ })
54
+ .addCase(fetchCustomerOrders.rejected, (state, action) => {
55
+ state.error = action.payload;
56
+ state.loading = 'idle';
57
+ });
58
+ }
59
+ });
60
+ export const { resetCustomerOrders, resetCustomerOrdersError, setCustomerOrders } = customerOrdersSlice.actions;
61
+ export const selectCustomerOrders = (state) => state.customer.orders;
62
+ export const customerOrdersReducer = customerOrdersSlice.reducer;
@@ -0,0 +1,17 @@
1
+ import { AppState } from '../../app';
2
+ import { RequestError, RequestStatus } from '@open-tender/types';
3
+ export interface CustomerQRCodeState {
4
+ qrcode: string | null;
5
+ error: RequestError;
6
+ loading: RequestStatus;
7
+ }
8
+ export declare enum CustomerQRCodeActionType {
9
+ FetchCustomerQRCode = "customer/fetchCustomerQRCode"
10
+ }
11
+ export declare const fetchCustomerQRCode: import("@reduxjs/toolkit").AsyncThunk<string, void, {
12
+ state: AppState;
13
+ rejectValue: RequestError;
14
+ }>;
15
+ export declare const resetCustomerQRCode: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
16
+ export declare const selectCustomerQRCode: (state: AppState) => CustomerQRCodeState;
17
+ export declare const customerQRCodeReducer: import("redux").Reducer<CustomerQRCodeState, import("redux").AnyAction>;
@@ -0,0 +1,53 @@
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
+ qrcode: null,
8
+ error: null,
9
+ loading: 'idle'
10
+ };
11
+ export var CustomerQRCodeActionType;
12
+ (function (CustomerQRCodeActionType) {
13
+ CustomerQRCodeActionType["FetchCustomerQRCode"] = "customer/fetchCustomerQRCode";
14
+ })(CustomerQRCodeActionType || (CustomerQRCodeActionType = {}));
15
+ export const fetchCustomerQRCode = createAsyncThunk(CustomerQRCodeActionType.FetchCustomerQRCode, (_, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
16
+ try {
17
+ const api = getState().config.api;
18
+ const token = selectToken(getState());
19
+ if (!token)
20
+ throw new Error(MISSING_CUSTOMER);
21
+ const { qr_code_url } = yield api.getCustomerQRCode(token);
22
+ return qr_code_url;
23
+ }
24
+ catch (err) {
25
+ const error = err;
26
+ return checkAuth(error, dispatch, () => rejectWithValue(error));
27
+ }
28
+ }));
29
+ const customerQRCodeSlice = createSlice({
30
+ name: ReducerType.QRCode,
31
+ initialState,
32
+ reducers: {
33
+ resetCustomerQRCode: () => initialState
34
+ },
35
+ extraReducers: builder => {
36
+ builder
37
+ .addCase(fetchCustomerQRCode.fulfilled, (state, action) => {
38
+ state.qrcode = action.payload;
39
+ state.loading = 'idle';
40
+ state.error = null;
41
+ })
42
+ .addCase(fetchCustomerQRCode.pending, state => {
43
+ state.loading = 'pending';
44
+ })
45
+ .addCase(fetchCustomerQRCode.rejected, (state, action) => {
46
+ state.error = action.payload;
47
+ state.loading = 'idle';
48
+ });
49
+ }
50
+ });
51
+ export const { resetCustomerQRCode } = customerQRCodeSlice.actions;
52
+ export const selectCustomerQRCode = (state) => state.customer.qrcode;
53
+ export const customerQRCodeReducer = customerQRCodeSlice.reducer;
@@ -0,0 +1,20 @@
1
+ import { AppState } from '../../app';
2
+ import { Rewards, RequestError, RequestStatus } from '@open-tender/types';
3
+ export interface CustomerRewardsState {
4
+ entities: Rewards;
5
+ error: RequestError;
6
+ loading: RequestStatus;
7
+ lookup: {
8
+ [key: number]: number;
9
+ };
10
+ }
11
+ export declare enum CustomerRewardsActionType {
12
+ FetchCustomerRewards = "customer/fetchCustomerRewards"
13
+ }
14
+ export declare const fetchCustomerRewards: import("@reduxjs/toolkit").AsyncThunk<Rewards, void, {
15
+ state: AppState;
16
+ rejectValue: RequestError;
17
+ }>;
18
+ export declare const resetCustomerRewards: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, resetCustomerRewardsError: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setCustomerRewards: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>;
19
+ export declare const selectCustomerRewards: (state: AppState) => CustomerRewardsState;
20
+ export declare const customerRewardsReducer: import("redux").Reducer<CustomerRewardsState, import("redux").AnyAction>;
@@ -0,0 +1,62 @@
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
+ entities: [],
8
+ error: null,
9
+ loading: 'idle',
10
+ lookup: {}
11
+ };
12
+ export var CustomerRewardsActionType;
13
+ (function (CustomerRewardsActionType) {
14
+ CustomerRewardsActionType["FetchCustomerRewards"] = "customer/fetchCustomerRewards";
15
+ })(CustomerRewardsActionType || (CustomerRewardsActionType = {}));
16
+ export const fetchCustomerRewards = createAsyncThunk(CustomerRewardsActionType.FetchCustomerRewards, (_, { 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
+ const rewards = yield api.getCustomerRewards(token);
23
+ return rewards;
24
+ }
25
+ catch (err) {
26
+ const error = err;
27
+ return checkAuth(error, dispatch, () => rejectWithValue(error));
28
+ }
29
+ }));
30
+ const customerRewardsSlice = createSlice({
31
+ name: ReducerType.Rewards,
32
+ initialState,
33
+ reducers: {
34
+ resetCustomerRewards: () => initialState,
35
+ resetCustomerRewardsError: state => {
36
+ state.error = null;
37
+ state.loading = 'idle';
38
+ },
39
+ setCustomerRewards: (state, action) => {
40
+ state.entities = action.payload;
41
+ state.error = null;
42
+ }
43
+ },
44
+ extraReducers: builder => {
45
+ builder
46
+ .addCase(fetchCustomerRewards.fulfilled, (state, action) => {
47
+ state.entities = action.payload;
48
+ state.loading = 'idle';
49
+ state.error = null;
50
+ })
51
+ .addCase(fetchCustomerRewards.pending, state => {
52
+ state.loading = 'pending';
53
+ })
54
+ .addCase(fetchCustomerRewards.rejected, (state, action) => {
55
+ state.error = action.payload;
56
+ state.loading = 'idle';
57
+ });
58
+ }
59
+ });
60
+ export const { resetCustomerRewards, resetCustomerRewardsError, setCustomerRewards } = customerRewardsSlice.actions;
61
+ export const selectCustomerRewards = (state) => state.customer.rewards;
62
+ export const customerRewardsReducer = customerRewardsSlice.reducer;
@@ -0,0 +1,17 @@
1
+ import { AppState } from '../../app';
2
+ import { Thanx, RequestError, RequestStatus } from '@open-tender/types';
3
+ export interface CustomerThanxState {
4
+ thanx: Thanx | null;
5
+ error: RequestError;
6
+ loading: RequestStatus;
7
+ }
8
+ export declare enum CustomerThanxActionType {
9
+ FetchCustomerThanx = "customer/fetchCustomerThanx"
10
+ }
11
+ export declare const fetchCustomerThanx: import("@reduxjs/toolkit").AsyncThunk<Thanx, void, {
12
+ state: AppState;
13
+ rejectValue: RequestError;
14
+ }>;
15
+ export declare const resetCustomerThanx: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
16
+ export declare const selectCustomerThanx: (state: AppState) => CustomerThanxState;
17
+ export declare const customerThanxReducer: import("redux").Reducer<CustomerThanxState, import("redux").AnyAction>;
@@ -0,0 +1,53 @@
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
+ thanx: null,
8
+ error: null,
9
+ loading: 'idle'
10
+ };
11
+ export var CustomerThanxActionType;
12
+ (function (CustomerThanxActionType) {
13
+ CustomerThanxActionType["FetchCustomerThanx"] = "customer/fetchCustomerThanx";
14
+ })(CustomerThanxActionType || (CustomerThanxActionType = {}));
15
+ export const fetchCustomerThanx = createAsyncThunk(CustomerThanxActionType.FetchCustomerThanx, (_, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
16
+ try {
17
+ const api = getState().config.api;
18
+ const token = selectToken(getState());
19
+ if (!token)
20
+ throw new Error(MISSING_CUSTOMER);
21
+ const resp = yield api.getCustomerThanx(token);
22
+ return resp;
23
+ }
24
+ catch (err) {
25
+ const error = err;
26
+ return checkAuth(error, dispatch, () => rejectWithValue(error));
27
+ }
28
+ }));
29
+ const customerThanxSlice = createSlice({
30
+ name: ReducerType.Thanx,
31
+ initialState,
32
+ reducers: {
33
+ resetCustomerThanx: () => initialState
34
+ },
35
+ extraReducers: builder => {
36
+ builder
37
+ .addCase(fetchCustomerThanx.fulfilled, (state, action) => {
38
+ state.thanx = action.payload;
39
+ state.loading = 'idle';
40
+ state.error = null;
41
+ })
42
+ .addCase(fetchCustomerThanx.pending, state => {
43
+ state.loading = 'pending';
44
+ })
45
+ .addCase(fetchCustomerThanx.rejected, (state, action) => {
46
+ state.error = action.payload;
47
+ state.loading = 'idle';
48
+ });
49
+ }
50
+ });
51
+ export const { resetCustomerThanx } = customerThanxSlice.actions;
52
+ export const selectCustomerThanx = (state) => state.customer.thanx;
53
+ export const customerThanxReducer = customerThanxSlice.reducer;
@@ -0,0 +1,19 @@
1
+ import { AppState } from '../app';
2
+ import { Deals, Deal, RequestError, RequestStatus } from '@open-tender/types';
3
+ export interface DealState {
4
+ entities: Deals;
5
+ error: RequestError;
6
+ loading: RequestStatus;
7
+ selected: Deal | null;
8
+ }
9
+ export declare enum DealActionType {
10
+ FetchDeals = "deals/fetchDeals"
11
+ }
12
+ export declare const fetchDeals: import("@reduxjs/toolkit").AsyncThunk<Deals, void, {
13
+ state: AppState;
14
+ rejectValue: RequestError;
15
+ }>;
16
+ export declare const resetDeals: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setSelectedDeals: import("@reduxjs/toolkit").ActionCreatorWithPayload<any, string>;
17
+ export declare const selectDeals: (state: AppState) => DealState;
18
+ export declare const selectEligibleDeals: (state: AppState) => Deals;
19
+ export declare const dealsReducer: import("redux").Reducer<DealState, import("redux").AnyAction>;
@@ -0,0 +1,91 @@
1
+ import { __awaiter } from "tslib";
2
+ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
3
+ import { ReducerType } from './types';
4
+ import { getMinutesfromDate, time24ToMinutes } from '@open-tender/utils';
5
+ const initialState = {
6
+ entities: [],
7
+ selected: null,
8
+ error: null,
9
+ loading: 'idle'
10
+ };
11
+ export var DealActionType;
12
+ (function (DealActionType) {
13
+ DealActionType["FetchDeals"] = "deals/fetchDeals";
14
+ })(DealActionType || (DealActionType = {}));
15
+ export const fetchDeals = createAsyncThunk(DealActionType.FetchDeals, (_, { getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
16
+ const { api } = getState().config;
17
+ if (!api)
18
+ return;
19
+ try {
20
+ const { profile } = getState().customer.account;
21
+ const { customer_id = null } = profile || {};
22
+ const deals = yield api.getDeals(customer_id);
23
+ return deals;
24
+ }
25
+ catch (err) {
26
+ return rejectWithValue(err);
27
+ }
28
+ }));
29
+ const dealsSlice = createSlice({
30
+ name: ReducerType.Deals,
31
+ initialState,
32
+ reducers: {
33
+ resetDeals: () => initialState,
34
+ setSelectedDeals: (state, action) => {
35
+ state.selected = action.payload;
36
+ }
37
+ },
38
+ extraReducers: builder => {
39
+ builder
40
+ .addCase(fetchDeals.fulfilled, (state, action) => {
41
+ state.entities = action.payload;
42
+ state.loading = 'idle';
43
+ state.error = null;
44
+ })
45
+ .addCase(fetchDeals.pending, state => {
46
+ state.loading = 'pending';
47
+ })
48
+ .addCase(fetchDeals.rejected, (state, action) => {
49
+ state.error = action.payload;
50
+ state.loading = 'idle';
51
+ });
52
+ }
53
+ });
54
+ export const { resetDeals, setSelectedDeals } = dealsSlice.actions;
55
+ export const selectDeals = (state) => state.deals;
56
+ export const selectEligibleDeals = (state) => {
57
+ const { brand } = state.config || {};
58
+ if (!brand || !brand.has_deals)
59
+ return [];
60
+ let { entities: deals } = state.deals;
61
+ const { orderType, serviceType, revenueCenter } = state.order;
62
+ if (orderType) {
63
+ deals = deals.filter(i => !i.order_type || i.order_type === orderType);
64
+ }
65
+ if (serviceType) {
66
+ deals = deals.filter(i => !i.service_type || i.service_type === serviceType);
67
+ }
68
+ if (revenueCenter) {
69
+ const { revenue_center_id } = revenueCenter;
70
+ deals = deals.filter(i => {
71
+ var _a;
72
+ return !((_a = i.revenue_centers) === null || _a === void 0 ? void 0 : _a.length) ||
73
+ i.revenue_centers
74
+ .map(r => r.revenue_center_id)
75
+ .includes(revenue_center_id);
76
+ });
77
+ }
78
+ const minutes = getMinutesfromDate(new Date());
79
+ deals = deals.filter(i => {
80
+ if (!i.dayparts.length)
81
+ return true;
82
+ const validDayparts = i.dayparts.filter(d => {
83
+ const start = time24ToMinutes(d.start_time);
84
+ const end = time24ToMinutes(d.end_time);
85
+ return start <= minutes && minutes <= end;
86
+ });
87
+ return validDayparts.length > 0;
88
+ });
89
+ return deals;
90
+ };
91
+ export const dealsReducer = dealsSlice.reducer;
@@ -0,0 +1,26 @@
1
+ import { AppState } from '../app';
2
+ import { Donation, RequestError, RequestStatus, PurchaseDonationRequest } from '@open-tender/types';
3
+ export interface DonationState {
4
+ donation: Donation | null;
5
+ error: RequestError | Record<string, any>;
6
+ loading: RequestStatus;
7
+ success: boolean;
8
+ }
9
+ export declare enum DonationActionType {
10
+ PurchaseDonation = "donations/purchaseDonation"
11
+ }
12
+ export declare const purchaseDonation: import("@reduxjs/toolkit").AsyncThunk<Donation, {
13
+ data: PurchaseDonationRequest;
14
+ callback?: (() => void) | undefined;
15
+ }, {
16
+ state: AppState;
17
+ rejectValue: RequestError | Record<string, any>;
18
+ }>;
19
+ export declare const resetDonation: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
20
+ export declare const selectDonation: (state: AppState) => {
21
+ success: boolean;
22
+ loading: RequestStatus;
23
+ error: RequestError | Record<string, any>;
24
+ donation: Donation | null;
25
+ };
26
+ export declare const donationsReducer: import("redux").Reducer<DonationState, import("redux").AnyAction>;
@@ -0,0 +1,58 @@
1
+ import { __awaiter } from "tslib";
2
+ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
3
+ import { ReducerType } from './types';
4
+ import { makeFormErrors } from '@open-tender/utils';
5
+ const initialState = {
6
+ donation: null,
7
+ success: false,
8
+ error: null,
9
+ loading: 'idle'
10
+ };
11
+ export var DonationActionType;
12
+ (function (DonationActionType) {
13
+ DonationActionType["PurchaseDonation"] = "donations/purchaseDonation";
14
+ })(DonationActionType || (DonationActionType = {}));
15
+ export const purchaseDonation = createAsyncThunk(DonationActionType.PurchaseDonation, (requestData, { getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
16
+ const { api } = getState().config;
17
+ if (!api)
18
+ return;
19
+ try {
20
+ const donation = yield api.postPurchaseDonation(requestData.data);
21
+ if (requestData.callback)
22
+ requestData.callback();
23
+ return donation;
24
+ }
25
+ catch (err) {
26
+ const errors = makeFormErrors(err);
27
+ return rejectWithValue(errors);
28
+ }
29
+ }));
30
+ const donationsSlice = createSlice({
31
+ name: ReducerType.Donations,
32
+ initialState,
33
+ reducers: {
34
+ resetDonation: () => initialState
35
+ },
36
+ extraReducers: builder => {
37
+ builder
38
+ .addCase(purchaseDonation.fulfilled, (state, action) => {
39
+ state.donation = action.payload;
40
+ state.success = true;
41
+ state.loading = 'idle';
42
+ state.error = null;
43
+ })
44
+ .addCase(purchaseDonation.pending, state => {
45
+ state.loading = 'pending';
46
+ })
47
+ .addCase(purchaseDonation.rejected, (state, action) => {
48
+ state.error = action.payload;
49
+ state.loading = 'idle';
50
+ });
51
+ }
52
+ });
53
+ export const { resetDonation } = donationsSlice.actions;
54
+ export const selectDonation = (state) => {
55
+ const { success, loading, error, donation } = state.donations;
56
+ return { success, loading, error, donation };
57
+ };
58
+ export const donationsReducer = donationsSlice.reducer;
@@ -0,0 +1,26 @@
1
+ import { AppState } from '../app';
2
+ import { CustomerGiftCard, CustomerGiftCards, RequestError, RequestStatus } from '@open-tender/types';
3
+ export interface GiftCardsState {
4
+ loading: RequestStatus;
5
+ error: RequestError;
6
+ success: boolean;
7
+ giftCards: CustomerGiftCards;
8
+ }
9
+ export declare enum GiftCardsActionType {
10
+ PurchaseGiftCards = "giftCards/purchaseGiftCards"
11
+ }
12
+ export declare const purchaseGiftCards: import("@reduxjs/toolkit").AsyncThunk<CustomerGiftCards, {
13
+ data: Partial<CustomerGiftCard>;
14
+ callback?: (() => void) | undefined;
15
+ }, {
16
+ state: AppState;
17
+ rejectValue: any;
18
+ }>;
19
+ export declare const resetGiftCards: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
20
+ export declare const selectGiftCards: (state: AppState) => {
21
+ success: boolean;
22
+ loading: RequestStatus;
23
+ error: RequestError;
24
+ giftCards: CustomerGiftCards;
25
+ };
26
+ export declare const giftCardsReducer: import("redux").Reducer<GiftCardsState, import("redux").AnyAction>;
@@ -0,0 +1,59 @@
1
+ import { __awaiter } from "tslib";
2
+ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
3
+ import { ReducerType } from './types';
4
+ import { makeFormErrors } from '@open-tender/utils';
5
+ const initialState = {
6
+ loading: 'idle',
7
+ error: null,
8
+ success: false,
9
+ giftCards: []
10
+ };
11
+ export var GiftCardsActionType;
12
+ (function (GiftCardsActionType) {
13
+ GiftCardsActionType["PurchaseGiftCards"] = "giftCards/purchaseGiftCards";
14
+ })(GiftCardsActionType || (GiftCardsActionType = {}));
15
+ export const purchaseGiftCards = createAsyncThunk(GiftCardsActionType.PurchaseGiftCards, (requestData, { getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
16
+ const { api } = getState().config;
17
+ if (!api)
18
+ return;
19
+ try {
20
+ const giftCards = yield api.postPurchaseGiftCards(requestData.data);
21
+ if (requestData.callback)
22
+ requestData.callback();
23
+ return giftCards;
24
+ }
25
+ catch (err) {
26
+ const errors = makeFormErrors(err);
27
+ return rejectWithValue(errors);
28
+ }
29
+ }));
30
+ const giftCardsSlice = createSlice({
31
+ name: ReducerType.GiftCards,
32
+ initialState,
33
+ reducers: {
34
+ resetGiftCards: () => initialState
35
+ },
36
+ extraReducers: builder => {
37
+ builder
38
+ .addCase(purchaseGiftCards.fulfilled, (state, action) => {
39
+ state.success = true;
40
+ state.giftCards = action.payload;
41
+ state.loading = 'idle';
42
+ state.error = null;
43
+ })
44
+ .addCase(purchaseGiftCards.pending, state => {
45
+ state.loading = 'pending';
46
+ })
47
+ .addCase(purchaseGiftCards.rejected, (state, action) => {
48
+ state.loading = 'idle';
49
+ state.success = false;
50
+ state.error = action.payload;
51
+ });
52
+ }
53
+ });
54
+ export const { resetGiftCards } = giftCardsSlice.actions;
55
+ export const selectGiftCards = (state) => {
56
+ const { success, loading, error, giftCards } = state.giftCards;
57
+ return { success, loading, error, giftCards };
58
+ };
59
+ export const giftCardsReducer = giftCardsSlice.reducer;