@open-tender/cloud 0.5.9 → 0.5.11

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 (283) hide show
  1. package/LICENSE.md +21 -21
  2. package/README.md +3 -3
  3. package/dist/cjs/app/hooks.d.ts +67 -67
  4. package/dist/cjs/app/hooks.js +8 -8
  5. package/dist/cjs/app/index.d.ts +2 -2
  6. package/dist/cjs/app/index.js +5 -5
  7. package/dist/cjs/app/store.d.ts +197 -197
  8. package/dist/cjs/app/store.js +65 -65
  9. package/dist/cjs/index.d.ts +5 -5
  10. package/dist/cjs/index.js +11 -11
  11. package/dist/cjs/services/api.d.ts +173 -173
  12. package/dist/cjs/services/api.js +741 -741
  13. package/dist/cjs/services/errors.d.ts +50 -50
  14. package/dist/cjs/services/errors.js +53 -53
  15. package/dist/cjs/services/index.d.ts +3 -3
  16. package/dist/cjs/services/index.js +7 -7
  17. package/dist/cjs/slices/alerts.d.ts +5 -5
  18. package/dist/cjs/slices/alerts.js +29 -29
  19. package/dist/cjs/slices/allergens.d.ts +101 -101
  20. package/dist/cjs/slices/allergens.js +83 -83
  21. package/dist/cjs/slices/announcements.d.ts +180 -180
  22. package/dist/cjs/slices/announcements.js +81 -81
  23. package/dist/cjs/slices/checkout.d.ts +69 -69
  24. package/dist/cjs/slices/checkout.js +326 -326
  25. package/dist/cjs/slices/completedOrders.d.ts +31 -31
  26. package/dist/cjs/slices/completedOrders.js +61 -61
  27. package/dist/cjs/slices/config.d.ts +317 -317
  28. package/dist/cjs/slices/config.js +195 -195
  29. package/dist/cjs/slices/confirmation.d.ts +8 -8
  30. package/dist/cjs/slices/confirmation.js +23 -23
  31. package/dist/cjs/slices/customer/account.d.ts +128 -128
  32. package/dist/cjs/slices/customer/account.js +351 -351
  33. package/dist/cjs/slices/customer/addresses.d.ts +55 -55
  34. package/dist/cjs/slices/customer/addresses.js +132 -132
  35. package/dist/cjs/slices/customer/allergens.d.ts +37 -37
  36. package/dist/cjs/slices/customer/allergens.js +94 -94
  37. package/dist/cjs/slices/customer/communicationPreferences.d.ts +69 -69
  38. package/dist/cjs/slices/customer/communicationPreferences.js +164 -164
  39. package/dist/cjs/slices/customer/creditCards.d.ts +137 -137
  40. package/dist/cjs/slices/customer/creditCards.js +170 -170
  41. package/dist/cjs/slices/customer/favorites.d.ts +68 -68
  42. package/dist/cjs/slices/customer/favorites.js +173 -173
  43. package/dist/cjs/slices/customer/fcmToken.d.ts +49 -49
  44. package/dist/cjs/slices/customer/fcmToken.js +110 -110
  45. package/dist/cjs/slices/customer/giftCards.d.ts +98 -98
  46. package/dist/cjs/slices/customer/giftCards.js +222 -222
  47. package/dist/cjs/slices/customer/groupOrders.d.ts +118 -118
  48. package/dist/cjs/slices/customer/groupOrders.js +262 -262
  49. package/dist/cjs/slices/customer/history.d.ts +23 -23
  50. package/dist/cjs/slices/customer/history.js +57 -57
  51. package/dist/cjs/slices/customer/houseAccounts.d.ts +26 -26
  52. package/dist/cjs/slices/customer/houseAccounts.js +67 -67
  53. package/dist/cjs/slices/customer/index.d.ts +42 -42
  54. package/dist/cjs/slices/customer/index.js +68 -68
  55. package/dist/cjs/slices/customer/loyalty.d.ts +251 -251
  56. package/dist/cjs/slices/customer/loyalty.js +110 -110
  57. package/dist/cjs/slices/customer/order.d.ts +116 -116
  58. package/dist/cjs/slices/customer/order.js +98 -98
  59. package/dist/cjs/slices/customer/orders.d.ts +27 -27
  60. package/dist/cjs/slices/customer/orders.js +69 -69
  61. package/dist/cjs/slices/customer/pointsShop.d.ts +35 -35
  62. package/dist/cjs/slices/customer/pointsShop.js +86 -86
  63. package/dist/cjs/slices/customer/qrCode.d.ts +23 -23
  64. package/dist/cjs/slices/customer/qrCode.js +57 -57
  65. package/dist/cjs/slices/customer/rewards.d.ts +26 -26
  66. package/dist/cjs/slices/customer/rewards.js +67 -67
  67. package/dist/cjs/slices/customer/thanx.d.ts +23 -23
  68. package/dist/cjs/slices/customer/thanx.js +56 -56
  69. package/dist/cjs/slices/customer/tpls.d.ts +238 -238
  70. package/dist/cjs/slices/customer/tpls.js +102 -102
  71. package/dist/cjs/slices/customer/tplsPointsShop.d.ts +38 -38
  72. package/dist/cjs/slices/customer/tplsPointsShop.js +88 -88
  73. package/dist/cjs/slices/deals.d.ts +25 -25
  74. package/dist/cjs/slices/deals.js +96 -96
  75. package/dist/cjs/slices/donations.d.ts +27 -27
  76. package/dist/cjs/slices/donations.js +57 -57
  77. package/dist/cjs/slices/geolocation.d.ts +11 -11
  78. package/dist/cjs/slices/geolocation.js +36 -36
  79. package/dist/cjs/slices/giftCards.d.ts +27 -27
  80. package/dist/cjs/slices/giftCards.js +58 -58
  81. package/dist/cjs/slices/groupOrder.d.ts +418 -418
  82. package/dist/cjs/slices/groupOrder.js +266 -266
  83. package/dist/cjs/slices/guest.d.ts +51 -51
  84. package/dist/cjs/slices/guest.js +91 -91
  85. package/dist/cjs/slices/index.d.ts +41 -41
  86. package/dist/cjs/slices/index.js +44 -44
  87. package/dist/cjs/slices/loader.d.ts +9 -9
  88. package/dist/cjs/slices/loader.js +25 -25
  89. package/dist/cjs/slices/menu.d.ts +31 -31
  90. package/dist/cjs/slices/menu.js +97 -97
  91. package/dist/cjs/slices/menuDisplay.d.ts +32 -32
  92. package/dist/cjs/slices/menuDisplay.js +59 -59
  93. package/dist/cjs/slices/menuItems.d.ts +26 -26
  94. package/dist/cjs/slices/menuItems.js +57 -57
  95. package/dist/cjs/slices/misc.d.ts +17 -17
  96. package/dist/cjs/slices/misc.js +51 -51
  97. package/dist/cjs/slices/modal.d.ts +5 -5
  98. package/dist/cjs/slices/modal.js +30 -30
  99. package/dist/cjs/slices/nav.d.ts +7 -7
  100. package/dist/cjs/slices/nav.js +23 -23
  101. package/dist/cjs/slices/navSite.d.ts +7 -7
  102. package/dist/cjs/slices/navSite.js +23 -23
  103. package/dist/cjs/slices/notifications.d.ts +5 -5
  104. package/dist/cjs/slices/notifications.js +27 -27
  105. package/dist/cjs/slices/oneTimePasscode.d.ts +40 -40
  106. package/dist/cjs/slices/oneTimePasscode.js +91 -91
  107. package/dist/cjs/slices/order.d.ts +372 -372
  108. package/dist/cjs/slices/order.js +528 -528
  109. package/dist/cjs/slices/orderFulfillment.d.ts +37 -37
  110. package/dist/cjs/slices/orderFulfillment.js +77 -77
  111. package/dist/cjs/slices/orderRating.d.ts +52 -52
  112. package/dist/cjs/slices/orderRating.js +105 -105
  113. package/dist/cjs/slices/posts.d.ts +24 -24
  114. package/dist/cjs/slices/posts.js +55 -55
  115. package/dist/cjs/slices/pushNotifications.d.ts +9 -9
  116. package/dist/cjs/slices/pushNotifications.js +29 -29
  117. package/dist/cjs/slices/qr.d.ts +11 -11
  118. package/dist/cjs/slices/qr.js +34 -34
  119. package/dist/cjs/slices/quote.d.ts +102 -102
  120. package/dist/cjs/slices/quote.js +65 -65
  121. package/dist/cjs/slices/resetPassword.d.ts +41 -41
  122. package/dist/cjs/slices/resetPassword.js +80 -80
  123. package/dist/cjs/slices/revenueCenters.d.ts +35 -35
  124. package/dist/cjs/slices/revenueCenters.js +95 -95
  125. package/dist/cjs/slices/sidebar.d.ts +7 -7
  126. package/dist/cjs/slices/sidebar.js +23 -23
  127. package/dist/cjs/slices/sidebarModal.d.ts +7 -7
  128. package/dist/cjs/slices/sidebarModal.js +23 -23
  129. package/dist/cjs/slices/signUp.d.ts +25 -25
  130. package/dist/cjs/slices/signUp.js +60 -60
  131. package/dist/cjs/slices/tags.d.ts +101 -101
  132. package/dist/cjs/slices/tags.js +90 -90
  133. package/dist/cjs/slices/terms.d.ts +20 -20
  134. package/dist/cjs/slices/terms.js +51 -51
  135. package/dist/cjs/slices/types.d.ts +62 -62
  136. package/dist/cjs/slices/types.js +66 -66
  137. package/dist/cjs/slices/unsubscribe.d.ts +39 -39
  138. package/dist/cjs/slices/unsubscribe.js +78 -78
  139. package/dist/cjs/slices/validTimes.d.ts +23 -23
  140. package/dist/cjs/slices/validTimes.js +57 -57
  141. package/dist/cjs/slices/verifyAccount.d.ts +23 -23
  142. package/dist/cjs/slices/verifyAccount.js +54 -54
  143. package/dist/esm/app/hooks.d.ts +67 -67
  144. package/dist/esm/app/hooks.js +4 -4
  145. package/dist/esm/app/index.d.ts +2 -2
  146. package/dist/esm/app/index.js +2 -2
  147. package/dist/esm/app/store.d.ts +197 -197
  148. package/dist/esm/app/store.js +62 -62
  149. package/dist/esm/index.d.ts +5 -5
  150. package/dist/esm/index.js +5 -5
  151. package/dist/esm/services/api.d.ts +173 -173
  152. package/dist/esm/services/api.js +739 -739
  153. package/dist/esm/services/errors.d.ts +50 -50
  154. package/dist/esm/services/errors.js +50 -50
  155. package/dist/esm/services/index.d.ts +3 -3
  156. package/dist/esm/services/index.js +3 -3
  157. package/dist/esm/slices/alerts.d.ts +5 -5
  158. package/dist/esm/slices/alerts.js +24 -24
  159. package/dist/esm/slices/allergens.d.ts +101 -101
  160. package/dist/esm/slices/allergens.js +77 -77
  161. package/dist/esm/slices/announcements.d.ts +180 -180
  162. package/dist/esm/slices/announcements.js +75 -75
  163. package/dist/esm/slices/checkout.d.ts +69 -69
  164. package/dist/esm/slices/checkout.js +318 -318
  165. package/dist/esm/slices/completedOrders.d.ts +31 -31
  166. package/dist/esm/slices/completedOrders.js +57 -57
  167. package/dist/esm/slices/config.d.ts +317 -317
  168. package/dist/esm/slices/config.js +168 -168
  169. package/dist/esm/slices/confirmation.d.ts +8 -8
  170. package/dist/esm/slices/confirmation.js +18 -18
  171. package/dist/esm/slices/customer/account.d.ts +128 -128
  172. package/dist/esm/slices/customer/account.js +344 -344
  173. package/dist/esm/slices/customer/addresses.d.ts +55 -55
  174. package/dist/esm/slices/customer/addresses.js +127 -127
  175. package/dist/esm/slices/customer/allergens.d.ts +37 -37
  176. package/dist/esm/slices/customer/allergens.js +89 -89
  177. package/dist/esm/slices/customer/communicationPreferences.d.ts +69 -69
  178. package/dist/esm/slices/customer/communicationPreferences.js +159 -159
  179. package/dist/esm/slices/customer/creditCards.d.ts +137 -137
  180. package/dist/esm/slices/customer/creditCards.js +165 -165
  181. package/dist/esm/slices/customer/favorites.d.ts +68 -68
  182. package/dist/esm/slices/customer/favorites.js +168 -168
  183. package/dist/esm/slices/customer/fcmToken.d.ts +49 -49
  184. package/dist/esm/slices/customer/fcmToken.js +106 -106
  185. package/dist/esm/slices/customer/giftCards.d.ts +98 -98
  186. package/dist/esm/slices/customer/giftCards.js +217 -217
  187. package/dist/esm/slices/customer/groupOrders.d.ts +118 -118
  188. package/dist/esm/slices/customer/groupOrders.js +256 -256
  189. package/dist/esm/slices/customer/history.d.ts +23 -23
  190. package/dist/esm/slices/customer/history.js +53 -53
  191. package/dist/esm/slices/customer/houseAccounts.d.ts +26 -26
  192. package/dist/esm/slices/customer/houseAccounts.js +62 -62
  193. package/dist/esm/slices/customer/index.d.ts +42 -42
  194. package/dist/esm/slices/customer/index.js +64 -64
  195. package/dist/esm/slices/customer/loyalty.d.ts +251 -251
  196. package/dist/esm/slices/customer/loyalty.js +102 -102
  197. package/dist/esm/slices/customer/order.d.ts +116 -116
  198. package/dist/esm/slices/customer/order.js +94 -94
  199. package/dist/esm/slices/customer/orders.d.ts +27 -27
  200. package/dist/esm/slices/customer/orders.js +63 -63
  201. package/dist/esm/slices/customer/pointsShop.d.ts +35 -35
  202. package/dist/esm/slices/customer/pointsShop.js +82 -82
  203. package/dist/esm/slices/customer/qrCode.d.ts +23 -23
  204. package/dist/esm/slices/customer/qrCode.js +53 -53
  205. package/dist/esm/slices/customer/rewards.d.ts +26 -26
  206. package/dist/esm/slices/customer/rewards.js +62 -62
  207. package/dist/esm/slices/customer/thanx.d.ts +23 -23
  208. package/dist/esm/slices/customer/thanx.js +52 -52
  209. package/dist/esm/slices/customer/tpls.d.ts +238 -238
  210. package/dist/esm/slices/customer/tpls.js +98 -98
  211. package/dist/esm/slices/customer/tplsPointsShop.d.ts +38 -38
  212. package/dist/esm/slices/customer/tplsPointsShop.js +84 -84
  213. package/dist/esm/slices/deals.d.ts +25 -25
  214. package/dist/esm/slices/deals.js +90 -90
  215. package/dist/esm/slices/donations.d.ts +27 -27
  216. package/dist/esm/slices/donations.js +53 -53
  217. package/dist/esm/slices/geolocation.d.ts +11 -11
  218. package/dist/esm/slices/geolocation.js +30 -30
  219. package/dist/esm/slices/giftCards.d.ts +27 -27
  220. package/dist/esm/slices/giftCards.js +54 -54
  221. package/dist/esm/slices/groupOrder.d.ts +418 -418
  222. package/dist/esm/slices/groupOrder.js +259 -259
  223. package/dist/esm/slices/guest.d.ts +51 -51
  224. package/dist/esm/slices/guest.js +86 -86
  225. package/dist/esm/slices/index.d.ts +41 -41
  226. package/dist/esm/slices/index.js +41 -41
  227. package/dist/esm/slices/loader.d.ts +9 -9
  228. package/dist/esm/slices/loader.js +21 -21
  229. package/dist/esm/slices/menu.d.ts +31 -31
  230. package/dist/esm/slices/menu.js +90 -90
  231. package/dist/esm/slices/menuDisplay.d.ts +32 -32
  232. package/dist/esm/slices/menuDisplay.js +55 -55
  233. package/dist/esm/slices/menuItems.d.ts +26 -26
  234. package/dist/esm/slices/menuItems.js +52 -52
  235. package/dist/esm/slices/misc.d.ts +17 -17
  236. package/dist/esm/slices/misc.js +41 -41
  237. package/dist/esm/slices/modal.d.ts +5 -5
  238. package/dist/esm/slices/modal.js +25 -25
  239. package/dist/esm/slices/nav.d.ts +7 -7
  240. package/dist/esm/slices/nav.js +19 -19
  241. package/dist/esm/slices/navSite.d.ts +7 -7
  242. package/dist/esm/slices/navSite.js +19 -19
  243. package/dist/esm/slices/notifications.d.ts +5 -5
  244. package/dist/esm/slices/notifications.js +22 -22
  245. package/dist/esm/slices/oneTimePasscode.d.ts +40 -40
  246. package/dist/esm/slices/oneTimePasscode.js +86 -86
  247. package/dist/esm/slices/order.d.ts +372 -372
  248. package/dist/esm/slices/order.js +508 -508
  249. package/dist/esm/slices/orderFulfillment.d.ts +37 -37
  250. package/dist/esm/slices/orderFulfillment.js +73 -73
  251. package/dist/esm/slices/orderRating.d.ts +52 -52
  252. package/dist/esm/slices/orderRating.js +101 -101
  253. package/dist/esm/slices/posts.d.ts +24 -24
  254. package/dist/esm/slices/posts.js +51 -51
  255. package/dist/esm/slices/pushNotifications.d.ts +9 -9
  256. package/dist/esm/slices/pushNotifications.js +23 -23
  257. package/dist/esm/slices/qr.d.ts +11 -11
  258. package/dist/esm/slices/qr.js +29 -29
  259. package/dist/esm/slices/quote.d.ts +102 -102
  260. package/dist/esm/slices/quote.js +61 -61
  261. package/dist/esm/slices/resetPassword.d.ts +41 -41
  262. package/dist/esm/slices/resetPassword.js +76 -76
  263. package/dist/esm/slices/revenueCenters.d.ts +35 -35
  264. package/dist/esm/slices/revenueCenters.js +89 -89
  265. package/dist/esm/slices/sidebar.d.ts +7 -7
  266. package/dist/esm/slices/sidebar.js +19 -19
  267. package/dist/esm/slices/sidebarModal.d.ts +7 -7
  268. package/dist/esm/slices/sidebarModal.js +19 -19
  269. package/dist/esm/slices/signUp.d.ts +25 -25
  270. package/dist/esm/slices/signUp.js +56 -56
  271. package/dist/esm/slices/tags.d.ts +101 -101
  272. package/dist/esm/slices/tags.js +84 -84
  273. package/dist/esm/slices/terms.d.ts +20 -20
  274. package/dist/esm/slices/terms.js +47 -47
  275. package/dist/esm/slices/types.d.ts +62 -62
  276. package/dist/esm/slices/types.js +63 -63
  277. package/dist/esm/slices/unsubscribe.d.ts +39 -39
  278. package/dist/esm/slices/unsubscribe.js +74 -74
  279. package/dist/esm/slices/validTimes.d.ts +23 -23
  280. package/dist/esm/slices/validTimes.js +52 -52
  281. package/dist/esm/slices/verifyAccount.d.ts +23 -23
  282. package/dist/esm/slices/verifyAccount.js +50 -50
  283. package/package.json +61 -61
@@ -1,344 +1,344 @@
1
- import { __awaiter } from "tslib";
2
- import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
3
- import { ReducerType } from '../types';
4
- import { MISSING_CUSTOMER, MISSING_CUSTOMER_TOKEN } from '@open-tender/types';
5
- import { makeCustomerProfile, makeFavoritesLookup } from '@open-tender/utils';
6
- import { showNotification } from '../notifications';
7
- import { resetCustomerAllergens, setCustomerAllergens } from './allergens';
8
- import { setSelectedAllergens } from '../allergens';
9
- import { resetCustomerFavorites, setCustomerFavorites, setCustomerFavoritesLookup } from './favorites';
10
- import { resetCustomerCreditCards } from './creditCards';
11
- import { resetCustomerAddresses } from './addresses';
12
- import { resetCustomerHouseAccounts } from './houseAccounts';
13
- import { resetCustomerLoyalty } from './loyalty';
14
- import { resetCustomerOrder } from './order';
15
- import { resetCustomerOrders } from './orders';
16
- import { resetCustomerRewards } from './rewards';
17
- import { resetCustomerCommunicationPreferences } from './communicationPreferences';
18
- import { resetCustomerGiftCards, setCustomerGiftCards } from './giftCards';
19
- import { addMessage, resetOrder, setAlert } from '../order';
20
- import { resetCheckout, updateCheckoutCustomer } from '../checkout';
21
- import { resetGroupOrder } from '../groupOrder';
22
- import { resetGuest } from '../guest';
23
- import { resetCustomerTpls } from './tpls';
24
- const initialState = {
25
- auth: null,
26
- profile: null,
27
- loading: 'idle',
28
- error: null
29
- };
30
- export var AccountActionType;
31
- (function (AccountActionType) {
32
- AccountActionType["LoginCustomer"] = "customer/loginCustomer";
33
- AccountActionType["LogoutCustomer"] = "customer/logoutCustomer";
34
- AccountActionType["FetchCustomer"] = "customer/fetchCustomer";
35
- AccountActionType["UpdateCustomer"] = "customer/updateCustomer";
36
- AccountActionType["VerifyCustomer"] = "customer/verifyCustomer";
37
- AccountActionType["LinkPosToken"] = "customer/linkPosToken";
38
- AccountActionType["DeleteCustomer"] = "customer/deleteCustomer";
39
- AccountActionType["LoginCustomerThanx"] = "customer/loginCustomerThanx";
40
- AccountActionType["AuthCustomerThanx"] = "customer/authCustomerThanx";
41
- })(AccountActionType || (AccountActionType = {}));
42
- export const checkAuth = (err, dispatch, rejectWithValue) => __awaiter(void 0, void 0, void 0, function* () {
43
- if ((err === null || err === void 0 ? void 0 : err.status) === 401) {
44
- yield dispatch(logoutCustomer());
45
- dispatch(addMessage('Please login to reauthenticate your account'));
46
- return null;
47
- }
48
- else {
49
- return rejectWithValue();
50
- }
51
- });
52
- export const fetchCustomer = createAsyncThunk(AccountActionType.FetchCustomer,
53
- // eslint-disable-next-line no-unused-vars
54
- (_, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
55
- try {
56
- const api = getState().config.api;
57
- const token = selectToken(getState());
58
- if (!token)
59
- throw new Error(MISSING_CUSTOMER);
60
- const customer = yield api.getCustomer(token);
61
- const { allergens, gift_cards, favorites } = customer;
62
- dispatch(setCustomerAllergens(allergens || []));
63
- dispatch(setSelectedAllergens(allergens || []));
64
- dispatch(setCustomerGiftCards(gift_cards || []));
65
- dispatch(setCustomerFavorites(favorites || []));
66
- const lookup = makeFavoritesLookup(favorites);
67
- dispatch(setCustomerFavoritesLookup(lookup || {}));
68
- const profile = makeCustomerProfile(customer);
69
- return profile;
70
- }
71
- catch (err) {
72
- const error = err;
73
- return checkAuth(error, dispatch, () => rejectWithValue(error));
74
- }
75
- }));
76
- export const loginCustomer = createAsyncThunk(AccountActionType.LoginCustomer, ({ email, password }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
77
- try {
78
- const api = getState().config.api;
79
- const auth = yield api.postLogin(email, password);
80
- dispatch(setCustomerAuth(auth));
81
- yield dispatch(fetchCustomer());
82
- return;
83
- }
84
- catch (err) {
85
- return rejectWithValue(err);
86
- }
87
- }));
88
- export const logoutCustomer = createAsyncThunk(AccountActionType.LogoutCustomer, (isReset, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
89
- try {
90
- const { api } = getState().config;
91
- const token = selectToken(getState());
92
- if (!token)
93
- throw new Error(undefined);
94
- if (isReset) {
95
- dispatch(resetOrder());
96
- dispatch(resetCheckout());
97
- dispatch(setSelectedAllergens(null));
98
- }
99
- yield api.postLogout(token);
100
- dispatch(updateCheckoutCustomer(null));
101
- dispatch(resetCustomerAddresses());
102
- dispatch(resetCustomerAllergens());
103
- dispatch(resetCustomerCreditCards());
104
- dispatch(resetCustomerFavorites());
105
- dispatch(resetCustomerGiftCards());
106
- dispatch(resetCustomerHouseAccounts());
107
- dispatch(resetCustomerLoyalty());
108
- dispatch(resetCustomerOrder());
109
- dispatch(resetCustomerOrders());
110
- dispatch(resetGroupOrder());
111
- dispatch(resetCustomerRewards());
112
- dispatch(resetCustomerCommunicationPreferences());
113
- dispatch(resetGuest());
114
- dispatch(resetCustomerTpls());
115
- return null;
116
- }
117
- catch (err) {
118
- return rejectWithValue(err);
119
- }
120
- }));
121
- export const linkPosToken = createAsyncThunk(AccountActionType.LinkPosToken, (posToken, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
122
- try {
123
- const api = getState().config.api;
124
- const token = selectToken(getState());
125
- if (!token)
126
- throw new Error(MISSING_CUSTOMER);
127
- yield api.postCustomerPosToken(token, posToken);
128
- dispatch(showNotification('Order successfully linked!'));
129
- dispatch(fetchCustomer());
130
- return;
131
- }
132
- catch (err) {
133
- const error = err;
134
- dispatch(addMessage((error === null || error === void 0 ? void 0 : error.detail) || (error === null || error === void 0 ? void 0 : error.message)));
135
- return rejectWithValue(error);
136
- }
137
- }));
138
- export const updateCustomer = createAsyncThunk(AccountActionType.UpdateCustomer, ({ data, callback }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
139
- try {
140
- const token = selectToken(getState());
141
- const api = getState().config.api;
142
- if (!token)
143
- throw new Error(MISSING_CUSTOMER);
144
- const customer = yield api.putCustomer(token, data);
145
- const profile = makeCustomerProfile(customer);
146
- dispatch(showNotification('Account updated!'));
147
- if (callback)
148
- callback(data);
149
- return profile;
150
- }
151
- catch (err) {
152
- const error = err;
153
- return checkAuth(error, dispatch, () => rejectWithValue(error));
154
- }
155
- }));
156
- export const sendCustomerVerificationEmail = createAsyncThunk(AccountActionType.VerifyCustomer, (linkUrl, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
157
- try {
158
- const api = getState().config.api;
159
- const token = selectToken(getState());
160
- if (!token) {
161
- dispatch(addMessage('Missing customer token'));
162
- throw new Error(MISSING_CUSTOMER_TOKEN);
163
- }
164
- yield api.postSendVerificationEmail(token, linkUrl);
165
- dispatch(showNotification('Verification email sent!'));
166
- return;
167
- }
168
- catch (err) {
169
- dispatch(addMessage(err.detail || err.message));
170
- return rejectWithValue(err);
171
- }
172
- }));
173
- export const loginCustomerThanx = createAsyncThunk(AccountActionType.LoginCustomerThanx, ({ email, origin }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
174
- try {
175
- const api = getState().config.api;
176
- yield api.postThanxLogin(email, origin);
177
- dispatch(setAlert({ type: 'close' }));
178
- dispatch(addMessage('Thanks! Please check your email on this device.'));
179
- return;
180
- }
181
- catch (err) {
182
- const errr = err;
183
- if (errr) {
184
- const error = (errr === null || errr === void 0 ? void 0 : errr.params) ? errr.params['$.email'] : null;
185
- if (error && error.includes("'email'")) {
186
- errr.detail = 'Please enter a valid email address';
187
- }
188
- }
189
- return rejectWithValue(errr);
190
- }
191
- }));
192
- export const authCustomerThanx = createAsyncThunk(AccountActionType.AuthCustomerThanx, (data, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
193
- try {
194
- const api = getState().config.api;
195
- const auth = yield api.postThanxAuth(data.code, data.path, data.origin);
196
- dispatch(setCustomerAuth(auth));
197
- yield dispatch(fetchCustomer());
198
- return;
199
- }
200
- catch (err) {
201
- return rejectWithValue(err);
202
- }
203
- }));
204
- export const deleteCustomer = createAsyncThunk(AccountActionType.DeleteCustomer, ({ data, callback }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
205
- try {
206
- const token = selectToken(getState());
207
- const api = getState().config.api;
208
- if (!token)
209
- throw new Error(MISSING_CUSTOMER);
210
- yield api.deleteCustomer(token);
211
- yield api.postLogout(token);
212
- dispatch(updateCheckoutCustomer(null));
213
- dispatch(resetCustomerAddresses());
214
- dispatch(resetCustomerAllergens());
215
- dispatch(resetCustomerCreditCards());
216
- dispatch(resetCustomerFavorites());
217
- dispatch(resetCustomerGiftCards());
218
- dispatch(resetCustomerHouseAccounts());
219
- dispatch(resetCustomerLoyalty());
220
- dispatch(resetCustomerOrder());
221
- dispatch(resetCustomerOrders());
222
- dispatch(resetGroupOrder());
223
- dispatch(resetCustomerRewards());
224
- dispatch(resetCustomerCommunicationPreferences());
225
- dispatch(resetGuest());
226
- dispatch(showNotification('Account deleted!'));
227
- if (callback)
228
- callback(data);
229
- return;
230
- }
231
- catch (err) {
232
- const error = err;
233
- return checkAuth(error, dispatch, () => rejectWithValue(error));
234
- }
235
- }));
236
- const accountSlice = createSlice({
237
- name: ReducerType.Account,
238
- initialState,
239
- reducers: {
240
- resetCustomer: () => initialState,
241
- resetLoginError: state => {
242
- state.loading = 'idle';
243
- state.error = null;
244
- },
245
- setCustomerAuth: (state, action) => {
246
- state.auth = action.payload;
247
- // state.loading = 'idle'
248
- // state.error = null
249
- }
250
- },
251
- extraReducers: builder => {
252
- builder
253
- .addCase(loginCustomer.fulfilled, state => {
254
- // state.auth = action.payload
255
- state.loading = 'idle';
256
- state.error = null;
257
- })
258
- .addCase(loginCustomer.pending, state => {
259
- state.loading = 'pending';
260
- })
261
- .addCase(loginCustomer.rejected, (state, action) => {
262
- state.loading = 'idle';
263
- state.error = action.payload;
264
- })
265
- .addCase(fetchCustomer.fulfilled, (state, action) => {
266
- state.profile = action.payload;
267
- state.loading = 'idle';
268
- state.error = null;
269
- })
270
- .addCase(fetchCustomer.pending, state => {
271
- state.loading = 'pending';
272
- })
273
- .addCase(fetchCustomer.rejected, (state, action) => {
274
- state.loading = 'idle';
275
- state.error = action.payload;
276
- })
277
- .addCase(updateCustomer.fulfilled, (state, action) => {
278
- state.profile = action.payload;
279
- state.loading = 'idle';
280
- state.error = null;
281
- })
282
- .addCase(updateCustomer.pending, state => {
283
- state.loading = 'pending';
284
- })
285
- .addCase(updateCustomer.rejected, (state, action) => {
286
- state.loading = 'idle';
287
- state.error = action.payload;
288
- })
289
- .addCase(logoutCustomer.fulfilled, () => initialState)
290
- .addCase(logoutCustomer.pending, state => {
291
- state.loading = 'pending';
292
- })
293
- .addCase(logoutCustomer.rejected, () => initialState)
294
- .addCase(sendCustomerVerificationEmail.fulfilled, state => {
295
- state.loading = 'idle';
296
- })
297
- .addCase(sendCustomerVerificationEmail.pending, state => {
298
- state.loading = 'pending';
299
- })
300
- .addCase(sendCustomerVerificationEmail.rejected, state => {
301
- state.loading = 'idle';
302
- })
303
- .addCase(linkPosToken.fulfilled, () => {
304
- //do nothing
305
- })
306
- .addCase(linkPosToken.pending, () => {
307
- //do nothing
308
- })
309
- .addCase(linkPosToken.rejected, () => {
310
- //do nothing
311
- })
312
- .addCase(deleteCustomer.fulfilled, () => initialState)
313
- .addCase(deleteCustomer.pending, state => {
314
- state.loading = 'pending';
315
- })
316
- .addCase(deleteCustomer.rejected, () => initialState)
317
- .addCase(loginCustomerThanx.fulfilled, state => {
318
- state.loading = 'idle';
319
- state.error = null;
320
- })
321
- .addCase(loginCustomerThanx.pending, state => {
322
- state.loading = 'pending';
323
- })
324
- .addCase(loginCustomerThanx.rejected, (state, action) => {
325
- state.loading = 'idle';
326
- state.error = action.payload;
327
- })
328
- .addCase(authCustomerThanx.fulfilled, state => {
329
- state.loading = 'idle';
330
- state.error = null;
331
- })
332
- .addCase(authCustomerThanx.pending, state => {
333
- state.loading = 'pending';
334
- })
335
- .addCase(authCustomerThanx.rejected, (state, action) => {
336
- state.loading = 'idle';
337
- state.error = action.payload;
338
- });
339
- }
340
- });
341
- export const { resetCustomer, resetLoginError, setCustomerAuth } = accountSlice.actions;
342
- export const selectToken = (state) => state.customer.account.auth ? state.customer.account.auth.access_token : null;
343
- export const selectCustomer = (state) => state.customer.account;
344
- export const accountReducer = accountSlice.reducer;
1
+ import { __awaiter } from "tslib";
2
+ import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
3
+ import { ReducerType } from '../types';
4
+ import { MISSING_CUSTOMER, MISSING_CUSTOMER_TOKEN } from '@open-tender/types';
5
+ import { makeCustomerProfile, makeFavoritesLookup } from '@open-tender/utils';
6
+ import { showNotification } from '../notifications';
7
+ import { resetCustomerAllergens, setCustomerAllergens } from './allergens';
8
+ import { setSelectedAllergens } from '../allergens';
9
+ import { resetCustomerFavorites, setCustomerFavorites, setCustomerFavoritesLookup } from './favorites';
10
+ import { resetCustomerCreditCards } from './creditCards';
11
+ import { resetCustomerAddresses } from './addresses';
12
+ import { resetCustomerHouseAccounts } from './houseAccounts';
13
+ import { resetCustomerLoyalty } from './loyalty';
14
+ import { resetCustomerOrder } from './order';
15
+ import { resetCustomerOrders } from './orders';
16
+ import { resetCustomerRewards } from './rewards';
17
+ import { resetCustomerCommunicationPreferences } from './communicationPreferences';
18
+ import { resetCustomerGiftCards, setCustomerGiftCards } from './giftCards';
19
+ import { addMessage, resetOrder, setAlert } from '../order';
20
+ import { resetCheckout, updateCheckoutCustomer } from '../checkout';
21
+ import { resetGroupOrder } from '../groupOrder';
22
+ import { resetGuest } from '../guest';
23
+ import { resetCustomerTpls } from './tpls';
24
+ const initialState = {
25
+ auth: null,
26
+ profile: null,
27
+ loading: 'idle',
28
+ error: null
29
+ };
30
+ export var AccountActionType;
31
+ (function (AccountActionType) {
32
+ AccountActionType["LoginCustomer"] = "customer/loginCustomer";
33
+ AccountActionType["LogoutCustomer"] = "customer/logoutCustomer";
34
+ AccountActionType["FetchCustomer"] = "customer/fetchCustomer";
35
+ AccountActionType["UpdateCustomer"] = "customer/updateCustomer";
36
+ AccountActionType["VerifyCustomer"] = "customer/verifyCustomer";
37
+ AccountActionType["LinkPosToken"] = "customer/linkPosToken";
38
+ AccountActionType["DeleteCustomer"] = "customer/deleteCustomer";
39
+ AccountActionType["LoginCustomerThanx"] = "customer/loginCustomerThanx";
40
+ AccountActionType["AuthCustomerThanx"] = "customer/authCustomerThanx";
41
+ })(AccountActionType || (AccountActionType = {}));
42
+ export const checkAuth = (err, dispatch, rejectWithValue) => __awaiter(void 0, void 0, void 0, function* () {
43
+ if ((err === null || err === void 0 ? void 0 : err.status) === 401) {
44
+ yield dispatch(logoutCustomer());
45
+ dispatch(addMessage('Please login to reauthenticate your account'));
46
+ return null;
47
+ }
48
+ else {
49
+ return rejectWithValue();
50
+ }
51
+ });
52
+ export const fetchCustomer = createAsyncThunk(AccountActionType.FetchCustomer,
53
+ // eslint-disable-next-line no-unused-vars
54
+ (_, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
55
+ try {
56
+ const api = getState().config.api;
57
+ const token = selectToken(getState());
58
+ if (!token)
59
+ throw new Error(MISSING_CUSTOMER);
60
+ const customer = yield api.getCustomer(token);
61
+ const { allergens, gift_cards, favorites } = customer;
62
+ dispatch(setCustomerAllergens(allergens || []));
63
+ dispatch(setSelectedAllergens(allergens || []));
64
+ dispatch(setCustomerGiftCards(gift_cards || []));
65
+ dispatch(setCustomerFavorites(favorites || []));
66
+ const lookup = makeFavoritesLookup(favorites);
67
+ dispatch(setCustomerFavoritesLookup(lookup || {}));
68
+ const profile = makeCustomerProfile(customer);
69
+ return profile;
70
+ }
71
+ catch (err) {
72
+ const error = err;
73
+ return checkAuth(error, dispatch, () => rejectWithValue(error));
74
+ }
75
+ }));
76
+ export const loginCustomer = createAsyncThunk(AccountActionType.LoginCustomer, ({ email, password }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
77
+ try {
78
+ const api = getState().config.api;
79
+ const auth = yield api.postLogin(email, password);
80
+ dispatch(setCustomerAuth(auth));
81
+ yield dispatch(fetchCustomer());
82
+ return;
83
+ }
84
+ catch (err) {
85
+ return rejectWithValue(err);
86
+ }
87
+ }));
88
+ export const logoutCustomer = createAsyncThunk(AccountActionType.LogoutCustomer, (isReset, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
89
+ try {
90
+ const { api } = getState().config;
91
+ const token = selectToken(getState());
92
+ if (!token)
93
+ throw new Error(undefined);
94
+ if (isReset) {
95
+ dispatch(resetOrder());
96
+ dispatch(resetCheckout());
97
+ dispatch(setSelectedAllergens(null));
98
+ }
99
+ yield api.postLogout(token);
100
+ dispatch(updateCheckoutCustomer(null));
101
+ dispatch(resetCustomerAddresses());
102
+ dispatch(resetCustomerAllergens());
103
+ dispatch(resetCustomerCreditCards());
104
+ dispatch(resetCustomerFavorites());
105
+ dispatch(resetCustomerGiftCards());
106
+ dispatch(resetCustomerHouseAccounts());
107
+ dispatch(resetCustomerLoyalty());
108
+ dispatch(resetCustomerOrder());
109
+ dispatch(resetCustomerOrders());
110
+ dispatch(resetGroupOrder());
111
+ dispatch(resetCustomerRewards());
112
+ dispatch(resetCustomerCommunicationPreferences());
113
+ dispatch(resetGuest());
114
+ dispatch(resetCustomerTpls());
115
+ return null;
116
+ }
117
+ catch (err) {
118
+ return rejectWithValue(err);
119
+ }
120
+ }));
121
+ export const linkPosToken = createAsyncThunk(AccountActionType.LinkPosToken, (posToken, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
122
+ try {
123
+ const api = getState().config.api;
124
+ const token = selectToken(getState());
125
+ if (!token)
126
+ throw new Error(MISSING_CUSTOMER);
127
+ yield api.postCustomerPosToken(token, posToken);
128
+ dispatch(showNotification('Order successfully linked!'));
129
+ dispatch(fetchCustomer());
130
+ return;
131
+ }
132
+ catch (err) {
133
+ const error = err;
134
+ dispatch(addMessage((error === null || error === void 0 ? void 0 : error.detail) || (error === null || error === void 0 ? void 0 : error.message)));
135
+ return rejectWithValue(error);
136
+ }
137
+ }));
138
+ export const updateCustomer = createAsyncThunk(AccountActionType.UpdateCustomer, ({ data, callback }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
139
+ try {
140
+ const token = selectToken(getState());
141
+ const api = getState().config.api;
142
+ if (!token)
143
+ throw new Error(MISSING_CUSTOMER);
144
+ const customer = yield api.putCustomer(token, data);
145
+ const profile = makeCustomerProfile(customer);
146
+ dispatch(showNotification('Account updated!'));
147
+ if (callback)
148
+ callback(data);
149
+ return profile;
150
+ }
151
+ catch (err) {
152
+ const error = err;
153
+ return checkAuth(error, dispatch, () => rejectWithValue(error));
154
+ }
155
+ }));
156
+ export const sendCustomerVerificationEmail = createAsyncThunk(AccountActionType.VerifyCustomer, (linkUrl, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
157
+ try {
158
+ const api = getState().config.api;
159
+ const token = selectToken(getState());
160
+ if (!token) {
161
+ dispatch(addMessage('Missing customer token'));
162
+ throw new Error(MISSING_CUSTOMER_TOKEN);
163
+ }
164
+ yield api.postSendVerificationEmail(token, linkUrl);
165
+ dispatch(showNotification('Verification email sent!'));
166
+ return;
167
+ }
168
+ catch (err) {
169
+ dispatch(addMessage(err.detail || err.message));
170
+ return rejectWithValue(err);
171
+ }
172
+ }));
173
+ export const loginCustomerThanx = createAsyncThunk(AccountActionType.LoginCustomerThanx, ({ email, origin }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
174
+ try {
175
+ const api = getState().config.api;
176
+ yield api.postThanxLogin(email, origin);
177
+ dispatch(setAlert({ type: 'close' }));
178
+ dispatch(addMessage('Thanks! Please check your email on this device.'));
179
+ return;
180
+ }
181
+ catch (err) {
182
+ const errr = err;
183
+ if (errr) {
184
+ const error = (errr === null || errr === void 0 ? void 0 : errr.params) ? errr.params['$.email'] : null;
185
+ if (error && error.includes("'email'")) {
186
+ errr.detail = 'Please enter a valid email address';
187
+ }
188
+ }
189
+ return rejectWithValue(errr);
190
+ }
191
+ }));
192
+ export const authCustomerThanx = createAsyncThunk(AccountActionType.AuthCustomerThanx, (data, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
193
+ try {
194
+ const api = getState().config.api;
195
+ const auth = yield api.postThanxAuth(data.code, data.path, data.origin);
196
+ dispatch(setCustomerAuth(auth));
197
+ yield dispatch(fetchCustomer());
198
+ return;
199
+ }
200
+ catch (err) {
201
+ return rejectWithValue(err);
202
+ }
203
+ }));
204
+ export const deleteCustomer = createAsyncThunk(AccountActionType.DeleteCustomer, ({ data, callback }, { dispatch, getState, rejectWithValue }) => __awaiter(void 0, void 0, void 0, function* () {
205
+ try {
206
+ const token = selectToken(getState());
207
+ const api = getState().config.api;
208
+ if (!token)
209
+ throw new Error(MISSING_CUSTOMER);
210
+ yield api.deleteCustomer(token);
211
+ yield api.postLogout(token);
212
+ dispatch(updateCheckoutCustomer(null));
213
+ dispatch(resetCustomerAddresses());
214
+ dispatch(resetCustomerAllergens());
215
+ dispatch(resetCustomerCreditCards());
216
+ dispatch(resetCustomerFavorites());
217
+ dispatch(resetCustomerGiftCards());
218
+ dispatch(resetCustomerHouseAccounts());
219
+ dispatch(resetCustomerLoyalty());
220
+ dispatch(resetCustomerOrder());
221
+ dispatch(resetCustomerOrders());
222
+ dispatch(resetGroupOrder());
223
+ dispatch(resetCustomerRewards());
224
+ dispatch(resetCustomerCommunicationPreferences());
225
+ dispatch(resetGuest());
226
+ dispatch(showNotification('Account deleted!'));
227
+ if (callback)
228
+ callback(data);
229
+ return;
230
+ }
231
+ catch (err) {
232
+ const error = err;
233
+ return checkAuth(error, dispatch, () => rejectWithValue(error));
234
+ }
235
+ }));
236
+ const accountSlice = createSlice({
237
+ name: ReducerType.Account,
238
+ initialState,
239
+ reducers: {
240
+ resetCustomer: () => initialState,
241
+ resetLoginError: state => {
242
+ state.loading = 'idle';
243
+ state.error = null;
244
+ },
245
+ setCustomerAuth: (state, action) => {
246
+ state.auth = action.payload;
247
+ // state.loading = 'idle'
248
+ // state.error = null
249
+ }
250
+ },
251
+ extraReducers: builder => {
252
+ builder
253
+ .addCase(loginCustomer.fulfilled, state => {
254
+ // state.auth = action.payload
255
+ state.loading = 'idle';
256
+ state.error = null;
257
+ })
258
+ .addCase(loginCustomer.pending, state => {
259
+ state.loading = 'pending';
260
+ })
261
+ .addCase(loginCustomer.rejected, (state, action) => {
262
+ state.loading = 'idle';
263
+ state.error = action.payload;
264
+ })
265
+ .addCase(fetchCustomer.fulfilled, (state, action) => {
266
+ state.profile = action.payload;
267
+ state.loading = 'idle';
268
+ state.error = null;
269
+ })
270
+ .addCase(fetchCustomer.pending, state => {
271
+ state.loading = 'pending';
272
+ })
273
+ .addCase(fetchCustomer.rejected, (state, action) => {
274
+ state.loading = 'idle';
275
+ state.error = action.payload;
276
+ })
277
+ .addCase(updateCustomer.fulfilled, (state, action) => {
278
+ state.profile = action.payload;
279
+ state.loading = 'idle';
280
+ state.error = null;
281
+ })
282
+ .addCase(updateCustomer.pending, state => {
283
+ state.loading = 'pending';
284
+ })
285
+ .addCase(updateCustomer.rejected, (state, action) => {
286
+ state.loading = 'idle';
287
+ state.error = action.payload;
288
+ })
289
+ .addCase(logoutCustomer.fulfilled, () => initialState)
290
+ .addCase(logoutCustomer.pending, state => {
291
+ state.loading = 'pending';
292
+ })
293
+ .addCase(logoutCustomer.rejected, () => initialState)
294
+ .addCase(sendCustomerVerificationEmail.fulfilled, state => {
295
+ state.loading = 'idle';
296
+ })
297
+ .addCase(sendCustomerVerificationEmail.pending, state => {
298
+ state.loading = 'pending';
299
+ })
300
+ .addCase(sendCustomerVerificationEmail.rejected, state => {
301
+ state.loading = 'idle';
302
+ })
303
+ .addCase(linkPosToken.fulfilled, () => {
304
+ //do nothing
305
+ })
306
+ .addCase(linkPosToken.pending, () => {
307
+ //do nothing
308
+ })
309
+ .addCase(linkPosToken.rejected, () => {
310
+ //do nothing
311
+ })
312
+ .addCase(deleteCustomer.fulfilled, () => initialState)
313
+ .addCase(deleteCustomer.pending, state => {
314
+ state.loading = 'pending';
315
+ })
316
+ .addCase(deleteCustomer.rejected, () => initialState)
317
+ .addCase(loginCustomerThanx.fulfilled, state => {
318
+ state.loading = 'idle';
319
+ state.error = null;
320
+ })
321
+ .addCase(loginCustomerThanx.pending, state => {
322
+ state.loading = 'pending';
323
+ })
324
+ .addCase(loginCustomerThanx.rejected, (state, action) => {
325
+ state.loading = 'idle';
326
+ state.error = action.payload;
327
+ })
328
+ .addCase(authCustomerThanx.fulfilled, state => {
329
+ state.loading = 'idle';
330
+ state.error = null;
331
+ })
332
+ .addCase(authCustomerThanx.pending, state => {
333
+ state.loading = 'pending';
334
+ })
335
+ .addCase(authCustomerThanx.rejected, (state, action) => {
336
+ state.loading = 'idle';
337
+ state.error = action.payload;
338
+ });
339
+ }
340
+ });
341
+ export const { resetCustomer, resetLoginError, setCustomerAuth } = accountSlice.actions;
342
+ export const selectToken = (state) => state.customer.account.auth ? state.customer.account.auth.access_token : null;
343
+ export const selectCustomer = (state) => state.customer.account;
344
+ export const accountReducer = accountSlice.reducer;