@zeniai/client-epic-state 4.12.55 → 4.12.56

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 (88) hide show
  1. package/lib/entity/chargeCard/chargeCard.d.ts +5 -2
  2. package/lib/entity/chargeCard/chargeCard.js +2 -0
  3. package/lib/entity/chargeCard/chargeCardPayload.d.ts +4 -2
  4. package/lib/entity/chargeCard/chargeCardPayload.js +44 -27
  5. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  6. package/lib/entity/snackbar/snackbarTypes.js +2 -0
  7. package/lib/entity/tenant/clearAllEpic.d.ts +2 -1
  8. package/lib/entity/tenant/clearAllEpic.js +2 -0
  9. package/lib/entity/toastNotification/epic/pushToastNotificationEpic.d.ts +1 -1
  10. package/lib/epic.d.ts +7 -1
  11. package/lib/epic.js +7 -1
  12. package/lib/index.d.ts +12 -8
  13. package/lib/index.js +40 -22
  14. package/lib/reducer.d.ts +4 -1
  15. package/lib/reducer.js +4 -1
  16. package/lib/view/addressView/addressViewReducer.d.ts +2 -0
  17. package/lib/view/addressView/addressViewReducer.js +13 -2
  18. package/lib/view/addressView/addressViewState.d.ts +1 -1
  19. package/lib/view/cardPayment/epic/addCardPaymentSourceEpic.d.ts +1 -1
  20. package/lib/view/cardPayment/epic/confirmCardSetupIntentEpic.d.ts +1 -1
  21. package/lib/view/cardPayment/epic/createCardSetupIntentEpic.d.ts +1 -1
  22. package/lib/view/cardPayment/epic/fetchPaymentSourcesEpic.d.ts +1 -1
  23. package/lib/view/companyView/epic/companyPassport/updateCompanyPassportLocalStoreDataEpic.d.ts +2 -2
  24. package/lib/view/companyView/epic/companyPassport/updateCompanyPassportLocalStoreDataEpic.js +8 -1
  25. package/lib/view/people/changeZeniPersonRolesEpic.d.ts +1 -1
  26. package/lib/view/people/deletePersonEpic.d.ts +1 -1
  27. package/lib/view/people/invitePeopleEpic.d.ts +1 -1
  28. package/lib/view/people/inviteZeniPeopleEpic.d.ts +1 -1
  29. package/lib/view/people/resendInviteEpic.d.ts +1 -1
  30. package/lib/view/settingsView/epic/fetchMyProfileEpic.d.ts +12 -2
  31. package/lib/view/settingsView/epic/fetchMyProfileEpic.js +10 -2
  32. package/lib/view/settingsView/epic/initializeMyProfileLocalDataEpic.d.ts +7 -0
  33. package/lib/view/settingsView/epic/initializeMyProfileLocalDataEpic.js +50 -0
  34. package/lib/view/settingsView/epic/saveNotificationSettingsEpic.d.ts +1 -1
  35. package/lib/view/settingsView/epic/updateMyProfileEpic.d.ts +11 -0
  36. package/lib/view/settingsView/epic/updateMyProfileEpic.js +86 -0
  37. package/lib/view/settingsView/settingsViewPayload.d.ts +12 -0
  38. package/lib/view/settingsView/settingsViewReducer.d.ts +13 -2
  39. package/lib/view/settingsView/settingsViewReducer.js +82 -7
  40. package/lib/view/settingsView/settingsViewSelector.js +14 -2
  41. package/lib/view/settingsView/settingsViewState.d.ts +16 -4
  42. package/lib/view/settingsView/types/settingsViewSelectorTypes.d.ts +11 -1
  43. package/lib/view/spendManagement/chargeCards/cardUserOnboarding/cardUserOnboardingReducer.d.ts +13 -0
  44. package/lib/view/spendManagement/chargeCards/cardUserOnboarding/cardUserOnboardingReducer.js +94 -0
  45. package/lib/view/spendManagement/chargeCards/cardUserOnboarding/cardUserOnboardingSelector.d.ts +18 -0
  46. package/lib/view/spendManagement/chargeCards/cardUserOnboarding/cardUserOnboardingSelector.js +34 -0
  47. package/lib/view/spendManagement/chargeCards/cardUserOnboarding/cardUserOnboardingState.d.ts +20 -0
  48. package/lib/view/spendManagement/chargeCards/cardUserOnboarding/cardUserOnboardingState.js +2 -0
  49. package/lib/view/spendManagement/chargeCards/cardUserOnboarding/epics/initializeCardUserOnboardingLocalDataEpic.d.ts +7 -0
  50. package/lib/view/spendManagement/chargeCards/cardUserOnboarding/epics/initializeCardUserOnboardingLocalDataEpic.js +50 -0
  51. package/lib/view/spendManagement/chargeCards/cardUserOnboarding/epics/saveCardOnboardingUserDetailsEpic.d.ts +7 -0
  52. package/lib/view/spendManagement/chargeCards/cardUserOnboarding/epics/saveCardOnboardingUserDetailsEpic.js +16 -0
  53. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailPayload.d.ts +2 -0
  54. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailSelector.d.ts +2 -2
  55. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailSelector.js +20 -6
  56. package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailEpic.d.ts +2 -2
  57. package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailEpic.js +1 -1
  58. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +7 -0
  59. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.js +8 -1
  60. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListPayload.d.ts +3 -0
  61. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.d.ts +8 -2
  62. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +43 -2
  63. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.d.ts +9 -4
  64. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +49 -9
  65. package/lib/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListEpic.d.ts +2 -1
  66. package/lib/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListEpic.js +2 -1
  67. package/lib/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.js +6 -0
  68. package/lib/view/spendManagement/chargeCards/chargeCardList/issueChargeCardEpic.d.ts +2 -1
  69. package/lib/view/spendManagement/chargeCards/chargeCardList/issueChargeCardEpic.js +3 -2
  70. package/lib/view/spendManagement/chargeCards/chargeCardList/resendCardInviteEpic.d.ts +9 -0
  71. package/lib/view/spendManagement/chargeCards/chargeCardList/resendCardInviteEpic.js +31 -0
  72. package/lib/view/spendManagement/chargeCards/chargeCardList/revokeCardInviteEpic.d.ts +8 -0
  73. package/lib/view/spendManagement/chargeCards/chargeCardList/revokeCardInviteEpic.js +29 -0
  74. package/lib/view/tagView/epics/createTagEpic.d.ts +1 -1
  75. package/lib/view/tagView/epics/deleteTagEpic.d.ts +1 -1
  76. package/lib/view/twoFactorAuthentication/resendOtpEpic.d.ts +3 -1
  77. package/lib/view/twoFactorAuthentication/resendOtpEpic.js +30 -0
  78. package/lib/view/twoFactorAuthentication/sendOtpEpic.d.ts +3 -1
  79. package/lib/view/twoFactorAuthentication/sendOtpEpic.js +30 -0
  80. package/lib/view/twoFactorAuthentication/twoFactorAuthentication.d.ts +1 -1
  81. package/lib/view/twoFactorAuthentication/twoFactorAuthenticationSelector.d.ts +12 -0
  82. package/lib/view/twoFactorAuthentication/twoFactorAuthenticationSelector.js +7 -0
  83. package/lib/view/twoFactorAuthentication/verifyOtpEpic.d.ts +3 -1
  84. package/lib/view/twoFactorAuthentication/verifyOtpEpic.js +26 -0
  85. package/lib/view/userListView/fetchUserListByTypeEpic.js +3 -1
  86. package/lib/view/userListView/userListViewReducer.js +1 -0
  87. package/lib/view/userListView/userListViewState.d.ts +2 -1
  88. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  var _a;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.clearSettingsView = exports.updateSettingsViewUIState = exports.refreshQBODataFailure = exports.refreshQBODataSuccess = exports.refreshQBOData = exports.resetNotificationSettingsUpdateStatus = exports.updateNotificationSettingsOnSaveFailure = exports.updateNotificationSettingsOnSaveSuccess = exports.saveNotificationSettings = exports.resetNotificationSettingsLocalData = exports.updateNotificationSettingsLocalData = exports.updateNotificationSettingsOnFailure = exports.updateNotificationSettingsOnSuccess = exports.fetchNotificationSettings = exports.fetchBankAccountsList = exports.updateBankConnectionOnFailure = exports.updateBankConnectionOnSuccess = exports.fetchBillingAccountsView = exports.fetchBankConnectionsView = exports.updateMyProfileOnFailure = exports.updateMyProfileOnSuccess = exports.fetchNotificationSettingsView = exports.fetchMyProfile = exports.fetchMyProfileView = exports.initialState = void 0;
4
+ exports.clearSettingsView = exports.verifyOtpMyProfileSuccess = exports.verifyOtpMyProfileFailure = exports.verifyOtpMyProfile = exports.resendOtpMyProfile = exports.sendOtpMyProfileSuccess = exports.sendOtpMyProfileFailure = exports.sendOtpMyProfile = exports.updateMyProfileSuccess = exports.updateMyProfileFailure = exports.updateMyProfile = exports.updateMyProfileLocalData = exports.initializeMyProfileLocalData = exports.updateSettingsViewUIState = exports.refreshQBODataFailure = exports.refreshQBODataSuccess = exports.refreshQBOData = exports.resetNotificationSettingsUpdateStatus = exports.updateNotificationSettingsOnSaveFailure = exports.updateNotificationSettingsOnSaveSuccess = exports.saveNotificationSettings = exports.resetNotificationSettingsLocalData = exports.updateNotificationSettingsLocalData = exports.updateNotificationSettingsOnFailure = exports.updateNotificationSettingsOnSuccess = exports.fetchNotificationSettings = exports.fetchBankAccountsList = exports.updateBankConnectionOnFailure = exports.updateBankConnectionOnSuccess = exports.fetchBillingAccountsView = exports.fetchBankConnectionsView = exports.updateMyProfileOnFailure = exports.updateMyProfileOnSuccess = exports.fetchNotificationSettingsView = exports.fetchMyProfile = exports.fetchMyProfileView = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const settingsViewState_1 = require("./settingsViewState");
7
7
  const initialNotificationSettingsData = {
@@ -16,6 +16,24 @@ const initialNotificationSettingsData = {
16
16
  recipientEmailIds: [],
17
17
  },
18
18
  };
19
+ const initialMyProfileState = {
20
+ fetchState: 'Not-Started',
21
+ error: undefined,
22
+ userId: null,
23
+ myProfileLocalData: {},
24
+ updateStatus: {
25
+ fetchState: 'Not-Started',
26
+ error: undefined,
27
+ },
28
+ sendOtpStatus: {
29
+ fetchState: 'Not-Started',
30
+ error: undefined,
31
+ },
32
+ verifyOtpStatus: {
33
+ fetchState: 'Not-Started',
34
+ error: undefined,
35
+ },
36
+ };
19
37
  const initialRemindersLocalData = {
20
38
  preferredMode: [],
21
39
  frequency: 'bi-weekly',
@@ -33,11 +51,7 @@ const initialNotificationSettingsLocalData = {
33
51
  },
34
52
  };
35
53
  exports.initialState = {
36
- profile: {
37
- fetchState: 'Not-Started',
38
- error: undefined,
39
- userId: null,
40
- },
54
+ profile: initialMyProfileState,
41
55
  bankConnection: {
42
56
  fetchState: 'Not-Started',
43
57
  error: undefined,
@@ -203,12 +217,73 @@ const settings = (0, toolkit_1.createSlice)({
203
217
  const updatedUiState = action.payload;
204
218
  draft.uiState = Object.assign(Object.assign({}, draft.uiState), updatedUiState);
205
219
  },
220
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
221
+ initializeMyProfileLocalData(_draft) {
222
+ // Nothing to do here
223
+ },
224
+ updateMyProfileLocalData(draft, action) {
225
+ draft.profile.myProfileLocalData = action.payload.localData;
226
+ },
227
+ updateMyProfile: {
228
+ reducer(draft,
229
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
230
+ _action) {
231
+ draft.profile.updateStatus.fetchState = 'In-Progress';
232
+ draft.profile.updateStatus.error = undefined;
233
+ },
234
+ prepare(origin = 'MyProfile', phone, otpChallenge, birthday, address) {
235
+ return { payload: { origin, phone, otpChallenge, birthday, address } };
236
+ },
237
+ },
238
+ updateMyProfileSuccess(draft) {
239
+ draft.profile.updateStatus.fetchState = 'Completed';
240
+ draft.profile.updateStatus.error = undefined;
241
+ },
242
+ updateMyProfileFailure(draft, action) {
243
+ draft.profile.updateStatus.fetchState = 'Error';
244
+ draft.profile.updateStatus.error = action.payload;
245
+ },
246
+ sendOtpMyProfile(draft) {
247
+ draft.profile.sendOtpStatus.fetchState = 'In-Progress';
248
+ draft.profile.sendOtpStatus.error = undefined;
249
+ },
250
+ resendOtpMyProfile(draft) {
251
+ draft.profile.sendOtpStatus.fetchState = 'In-Progress';
252
+ draft.profile.sendOtpStatus.error = undefined;
253
+ },
254
+ sendOtpMyProfileSuccess(draft, action) {
255
+ if (draft.profile.myProfileLocalData != null) {
256
+ draft.profile.myProfileLocalData.otpChallenge =
257
+ action.payload.otpChallenge;
258
+ }
259
+ draft.profile.sendOtpStatus.fetchState = 'Completed';
260
+ draft.profile.sendOtpStatus.error = undefined;
261
+ },
262
+ sendOtpMyProfileFailure(draft, action) {
263
+ draft.profile.sendOtpStatus.fetchState = 'Error';
264
+ draft.profile.sendOtpStatus.error = action.payload;
265
+ },
266
+ verifyOtpMyProfile(draft) {
267
+ draft.profile.verifyOtpStatus.fetchState = 'In-Progress';
268
+ draft.profile.verifyOtpStatus.error = undefined;
269
+ },
270
+ verifyOtpMyProfileSuccess(draft) {
271
+ if (draft.profile.myProfileLocalData != null) {
272
+ draft.profile.myProfileLocalData.isPhoneVerified = true;
273
+ }
274
+ draft.profile.verifyOtpStatus.fetchState = 'Completed';
275
+ draft.profile.verifyOtpStatus.error = undefined;
276
+ },
277
+ verifyOtpMyProfileFailure(draft, action) {
278
+ draft.profile.verifyOtpStatus.fetchState = 'Error';
279
+ draft.profile.verifyOtpStatus.error = action.payload;
280
+ },
206
281
  clearSettingsView(draft) {
207
282
  Object.assign(draft, exports.initialState);
208
283
  },
209
284
  },
210
285
  });
211
- _a = settings.actions, exports.fetchMyProfileView = _a.fetchMyProfileView, exports.fetchMyProfile = _a.fetchMyProfile, exports.fetchNotificationSettingsView = _a.fetchNotificationSettingsView, exports.updateMyProfileOnSuccess = _a.updateMyProfileOnSuccess, exports.updateMyProfileOnFailure = _a.updateMyProfileOnFailure, exports.fetchBankConnectionsView = _a.fetchBankConnectionsView, exports.fetchBillingAccountsView = _a.fetchBillingAccountsView, exports.updateBankConnectionOnSuccess = _a.updateBankConnectionOnSuccess, exports.updateBankConnectionOnFailure = _a.updateBankConnectionOnFailure, exports.fetchBankAccountsList = _a.fetchBankAccountsList, exports.fetchNotificationSettings = _a.fetchNotificationSettings, exports.updateNotificationSettingsOnSuccess = _a.updateNotificationSettingsOnSuccess, exports.updateNotificationSettingsOnFailure = _a.updateNotificationSettingsOnFailure, exports.updateNotificationSettingsLocalData = _a.updateNotificationSettingsLocalData, exports.resetNotificationSettingsLocalData = _a.resetNotificationSettingsLocalData, exports.saveNotificationSettings = _a.saveNotificationSettings, exports.updateNotificationSettingsOnSaveSuccess = _a.updateNotificationSettingsOnSaveSuccess, exports.updateNotificationSettingsOnSaveFailure = _a.updateNotificationSettingsOnSaveFailure, exports.resetNotificationSettingsUpdateStatus = _a.resetNotificationSettingsUpdateStatus, exports.refreshQBOData = _a.refreshQBOData, exports.refreshQBODataSuccess = _a.refreshQBODataSuccess, exports.refreshQBODataFailure = _a.refreshQBODataFailure, exports.updateSettingsViewUIState = _a.updateSettingsViewUIState, exports.clearSettingsView = _a.clearSettingsView;
286
+ _a = settings.actions, exports.fetchMyProfileView = _a.fetchMyProfileView, exports.fetchMyProfile = _a.fetchMyProfile, exports.fetchNotificationSettingsView = _a.fetchNotificationSettingsView, exports.updateMyProfileOnSuccess = _a.updateMyProfileOnSuccess, exports.updateMyProfileOnFailure = _a.updateMyProfileOnFailure, exports.fetchBankConnectionsView = _a.fetchBankConnectionsView, exports.fetchBillingAccountsView = _a.fetchBillingAccountsView, exports.updateBankConnectionOnSuccess = _a.updateBankConnectionOnSuccess, exports.updateBankConnectionOnFailure = _a.updateBankConnectionOnFailure, exports.fetchBankAccountsList = _a.fetchBankAccountsList, exports.fetchNotificationSettings = _a.fetchNotificationSettings, exports.updateNotificationSettingsOnSuccess = _a.updateNotificationSettingsOnSuccess, exports.updateNotificationSettingsOnFailure = _a.updateNotificationSettingsOnFailure, exports.updateNotificationSettingsLocalData = _a.updateNotificationSettingsLocalData, exports.resetNotificationSettingsLocalData = _a.resetNotificationSettingsLocalData, exports.saveNotificationSettings = _a.saveNotificationSettings, exports.updateNotificationSettingsOnSaveSuccess = _a.updateNotificationSettingsOnSaveSuccess, exports.updateNotificationSettingsOnSaveFailure = _a.updateNotificationSettingsOnSaveFailure, exports.resetNotificationSettingsUpdateStatus = _a.resetNotificationSettingsUpdateStatus, exports.refreshQBOData = _a.refreshQBOData, exports.refreshQBODataSuccess = _a.refreshQBODataSuccess, exports.refreshQBODataFailure = _a.refreshQBODataFailure, exports.updateSettingsViewUIState = _a.updateSettingsViewUIState, exports.initializeMyProfileLocalData = _a.initializeMyProfileLocalData, exports.updateMyProfileLocalData = _a.updateMyProfileLocalData, exports.updateMyProfile = _a.updateMyProfile, exports.updateMyProfileFailure = _a.updateMyProfileFailure, exports.updateMyProfileSuccess = _a.updateMyProfileSuccess, exports.sendOtpMyProfile = _a.sendOtpMyProfile, exports.sendOtpMyProfileFailure = _a.sendOtpMyProfileFailure, exports.sendOtpMyProfileSuccess = _a.sendOtpMyProfileSuccess, exports.resendOtpMyProfile = _a.resendOtpMyProfile, exports.verifyOtpMyProfile = _a.verifyOtpMyProfile, exports.verifyOtpMyProfileFailure = _a.verifyOtpMyProfileFailure, exports.verifyOtpMyProfileSuccess = _a.verifyOtpMyProfileSuccess, exports.clearSettingsView = _a.clearSettingsView;
212
287
  exports.default = settings.reducer;
213
288
  /**
214
289
  * Helpers
@@ -22,6 +22,8 @@ const setupViewSelector_1 = require("../../view/spendManagement/commonSetup/setu
22
22
  const depositAccountSelector_1 = require("../../entity/depositAccount/depositAccountSelector");
23
23
  const getCompanyView_1 = require("../companyView/selectorHelpers/getCompanyView");
24
24
  const cardPaymentViewSelector_1 = require("../cardPayment/cardPaymentViewSelector");
25
+ const addressSelector_1 = require("../../entity/address/addressSelector");
26
+ const twoFactorAuthenticationSelector_1 = require("../twoFactorAuthentication/twoFactorAuthenticationSelector");
25
27
  function getApprovalRuleViewDetails(state) {
26
28
  const { billPaySetupApproverViewState, remiSetupApproverViewState } = state;
27
29
  const fetchState = (0, reduceFetchState_1.reduceAnyFetchState)([
@@ -140,8 +142,8 @@ function getIntegrationsView(state, companyId) {
140
142
  };
141
143
  }
142
144
  exports.getIntegrationsView = getIntegrationsView;
143
- exports.getMyProfileView = (0, toolkit_1.createSelector)((state) => state.tenantState, (state) => state.userState, (state) => state.userRoleState, (state) => state.settingsViewState, (state) => state.classState, (state) => state.classListState, (state) => (0, companyPassportViewSelector_1.getCompanyPassportView)(state), (state) => state.userListViewState, (_state, shouldFetchClasses) => shouldFetchClasses, (tenantState, userState, userRoleState, settingsViewState, classState, classListState, companyPassportView, userListViewState, shouldFetchClasses) => {
144
- var _a, _b, _c, _d;
145
+ exports.getMyProfileView = (0, toolkit_1.createSelector)((state) => state, (state) => state.tenantState, (state) => state.userState, (state) => state.userRoleState, (state) => state.addressState, (state) => state.addressViewState, (state) => state.settingsViewState, (state) => state.classState, (state) => state.classListState, (state) => (0, companyPassportViewSelector_1.getCompanyPassportView)(state), (state) => state.userListViewState, (_state, shouldFetchClasses) => shouldFetchClasses, (state, tenantState, userState, userRoleState, addressState, addressViewState, settingsViewState, classState, classListState, companyPassportView, userListViewState, shouldFetchClasses) => {
146
+ var _a, _b, _c, _d, _e;
145
147
  const userId = (_a = tenantState.loggedInUser) === null || _a === void 0 ? void 0 : _a.userId;
146
148
  const managersListView = (0, userListViewSelector_1.getUserList)(userState, userRoleState, userListViewState, 'manager');
147
149
  if (userId == null) {
@@ -149,10 +151,14 @@ exports.getMyProfileView = (0, toolkit_1.createSelector)((state) => state.tenant
149
151
  }
150
152
  const user = (0, userSelector_1.getUserByUserId)(userState, userId);
151
153
  const userRole = (0, userRoleSelector_1.getUserRoleByUserId)(userRoleState, userId);
154
+ const address = (userRole === null || userRole === void 0 ? void 0 : userRole.addressId) != null
155
+ ? (0, addressSelector_1.getAddressByAddressId)(addressState, userRole.addressId)
156
+ : undefined;
152
157
  const person = {
153
158
  userId,
154
159
  user,
155
160
  userRole,
161
+ address,
156
162
  };
157
163
  const isZeniUser = (_b = userRole === null || userRole === void 0 ? void 0 : userRole.isZeni) !== null && _b !== void 0 ? _b : true;
158
164
  const departmentIds = (_c = userRole === null || userRole === void 0 ? void 0 : userRole.accountingClassIDs) !== null && _c !== void 0 ? _c : [];
@@ -183,8 +189,14 @@ exports.getMyProfileView = (0, toolkit_1.createSelector)((state) => state.tenant
183
189
  person,
184
190
  department,
185
191
  classList,
192
+ myProfileLocalData: settingsViewState.profile.myProfileLocalData,
186
193
  controllersList,
187
194
  managersList: managersListView.users,
195
+ addressData: (_e = addressViewState.newAddressState) === null || _e === void 0 ? void 0 : _e['user_address'],
196
+ twoFAView: (0, twoFactorAuthenticationSelector_1.getTwoFactorAuthenticationView)(state),
197
+ sendOtpStatus: settingsViewState.profile.sendOtpStatus,
198
+ verifyOtpStatus: settingsViewState.profile.verifyOtpStatus,
199
+ updateProfileStatus: settingsViewState.profile.updateStatus,
188
200
  };
189
201
  const managerId = userRole === null || userRole === void 0 ? void 0 : userRole.managerUserId;
190
202
  if (managerId != null) {
@@ -1,7 +1,5 @@
1
1
  import { ID, FetchStateAndError } from '../../commonStateTypes/common';
2
- interface MyProfile extends FetchStateAndError {
3
- userId: ID | null;
4
- }
2
+ import { ZeniDate } from '../../zeniDayJS';
5
3
  interface BankConnection extends FetchStateAndError {
6
4
  bankAccountIds: ID[];
7
5
  }
@@ -48,8 +46,22 @@ export interface NotificationSettings extends FetchStateAndError {
48
46
  notificationSettingsLocalData: NotificationSettingsLocalData;
49
47
  updateStatus: FetchStateAndError;
50
48
  }
49
+ export interface MyProfileSettingsLocalData {
50
+ phone?: string;
51
+ isPhoneVerified?: boolean;
52
+ otpChallenge?: string;
53
+ dateOfBirth?: ZeniDate;
54
+ syncToken?: string;
55
+ }
56
+ export interface MyProfileSettings extends FetchStateAndError {
57
+ userId: ID | null;
58
+ myProfileLocalData: MyProfileSettingsLocalData;
59
+ updateStatus: FetchStateAndError;
60
+ sendOtpStatus: FetchStateAndError;
61
+ verifyOtpStatus: FetchStateAndError;
62
+ }
51
63
  export interface SettingsViewState {
52
- profile: MyProfile;
64
+ profile: MyProfileSettings;
53
65
  bankConnection: BankConnection;
54
66
  notification: NotificationSettings;
55
67
  integrations: IntegrationsSettings;
@@ -7,18 +7,27 @@ import { UserRole } from '../../../entity/userRole/userRoleState';
7
7
  import { Person } from '../../people/peopleSelectorTypes';
8
8
  import { FundingAccount, SetupView } from '../../spendManagement/commonSetup/setupViewSelector';
9
9
  import { UserFinancialAccountSelectorView } from '../../userFinancialAccount/userFinancialAccountSelector';
10
- import { IntegrationsSettings, NotificationSettings, SettingsViewUIState } from '../settingsViewState';
10
+ import { IntegrationsSettings, MyProfileSettingsLocalData, NotificationSettings, SettingsViewUIState } from '../settingsViewState';
11
11
  import { TenantExternalConnections } from '../../../entity/tenant/tenantState';
12
12
  import { Company } from '../../../entity/company/companyStateTypes';
13
13
  import { EntityType as SpendManagementEntityType } from '../../../entity/entityApprovalStatus/entityApprovalStatusState';
14
14
  import { AccountBase } from '../../../entity/account/accountState';
15
15
  import { CardPaymentSelectorView } from '../../cardPayment/cardPaymentViewSelector';
16
+ import { Address } from '../../../entity/address/addressState';
17
+ import { NewAddressData } from '../../addressView/addressViewState';
18
+ import { TwoFactorAuthenticationView } from '../../twoFactorAuthentication/twoFactorAuthenticationSelector';
16
19
  export interface MyProfileSelectorView extends SelectorView {
17
20
  isZeniUser: boolean;
18
21
  person: MyProfile;
19
22
  classList: Class[];
20
23
  managersList: Person[];
21
24
  controllersList: User[];
25
+ myProfileLocalData: MyProfileSettingsLocalData;
26
+ twoFAView: TwoFactorAuthenticationView;
27
+ sendOtpStatus: FetchStateAndError;
28
+ verifyOtpStatus: FetchStateAndError;
29
+ updateProfileStatus: FetchStateAndError;
30
+ addressData?: NewAddressData;
22
31
  manager?: MyProfile;
23
32
  department?: Class;
24
33
  }
@@ -26,6 +35,7 @@ export interface MyProfile {
26
35
  userId: ID;
27
36
  user: User | undefined;
28
37
  userRole: UserRole | undefined;
38
+ address?: Address;
29
39
  }
30
40
  export interface MyBankConnectionsView extends UserFinancialAccountSelectorView {
31
41
  paymentAccounts: PaymentAccount[];
@@ -0,0 +1,13 @@
1
+ import { CardUserOnboardingState, CardUserOnboardingLocalData } from './cardUserOnboardingState';
2
+ import { ID } from '../../../../commonStateTypes/common';
3
+ import { ZeniAPIStatus } from '../../../../responsePayload';
4
+ export declare const initialState: CardUserOnboardingState;
5
+ export declare const initializeCardUserOnboardingLocalData: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
6
+ userId: ID;
7
+ }, string>, updateCardUserOnboardingLocalData: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
8
+ localData: CardUserOnboardingLocalData;
9
+ }, string>, sendOtpCardUserOnboarding: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, sendOtpCardUserOnboardingSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
10
+ otpChallenge: string;
11
+ }, string>, sendOtpCardUserOnboardingFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, string>, resendOtpCardUserOnboarding: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, verifyOtpCardUserOnboarding: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, verifyOtpCardUserOnboardingSuccess: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, verifyOtpCardUserOnboardingFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, string>, saveCardOnboardingUserDetails: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, startActivationWait: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, completeActivationWait: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setFirstViewAfterActivation: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, setFirstViewCompleteAfterActivation: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>, clearCardUserOnboarding: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<string>;
12
+ declare const _default: import("@reduxjs/toolkit").Reducer<CardUserOnboardingState, import("@reduxjs/toolkit").AnyAction>;
13
+ export default _default;
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var _a;
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.clearCardUserOnboarding = exports.setFirstViewCompleteAfterActivation = exports.setFirstViewAfterActivation = exports.completeActivationWait = exports.startActivationWait = exports.saveCardOnboardingUserDetails = exports.verifyOtpCardUserOnboardingFailure = exports.verifyOtpCardUserOnboardingSuccess = exports.verifyOtpCardUserOnboarding = exports.resendOtpCardUserOnboarding = exports.sendOtpCardUserOnboardingFailure = exports.sendOtpCardUserOnboardingSuccess = exports.sendOtpCardUserOnboarding = exports.updateCardUserOnboardingLocalData = exports.initializeCardUserOnboardingLocalData = exports.initialState = void 0;
5
+ const toolkit_1 = require("@reduxjs/toolkit");
6
+ exports.initialState = {
7
+ cardUserOnboardingLocalData: undefined,
8
+ firstViewAfterActivation: false,
9
+ sendOtpStatus: {
10
+ fetchState: 'Not-Started',
11
+ error: undefined,
12
+ },
13
+ verifyOtpStatus: {
14
+ fetchState: 'Not-Started',
15
+ error: undefined,
16
+ },
17
+ activationWaitStatus: {
18
+ fetchState: 'Not-Started',
19
+ error: undefined,
20
+ },
21
+ };
22
+ const cardUserOnboarding = (0, toolkit_1.createSlice)({
23
+ name: 'cardUserOnboarding',
24
+ initialState: exports.initialState,
25
+ reducers: {
26
+ initializeCardUserOnboardingLocalData(
27
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
28
+ _draft,
29
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
30
+ _action) {
31
+ // Do nothing here
32
+ },
33
+ updateCardUserOnboardingLocalData(draft, action) {
34
+ draft.cardUserOnboardingLocalData = action.payload.localData;
35
+ },
36
+ sendOtpCardUserOnboarding(draft) {
37
+ draft.sendOtpStatus.fetchState = 'In-Progress';
38
+ draft.sendOtpStatus.error = undefined;
39
+ },
40
+ resendOtpCardUserOnboarding(draft) {
41
+ draft.sendOtpStatus.fetchState = 'In-Progress';
42
+ draft.sendOtpStatus.error = undefined;
43
+ },
44
+ sendOtpCardUserOnboardingSuccess(draft, action) {
45
+ if (draft.cardUserOnboardingLocalData != null) {
46
+ draft.cardUserOnboardingLocalData.otpChallenge =
47
+ action.payload.otpChallenge;
48
+ }
49
+ draft.sendOtpStatus.fetchState = 'Completed';
50
+ draft.sendOtpStatus.error = undefined;
51
+ },
52
+ sendOtpCardUserOnboardingFailure(draft, action) {
53
+ draft.sendOtpStatus.fetchState = 'Error';
54
+ draft.sendOtpStatus.error = action.payload;
55
+ },
56
+ verifyOtpCardUserOnboarding(draft) {
57
+ draft.verifyOtpStatus.fetchState = 'In-Progress';
58
+ draft.verifyOtpStatus.error = undefined;
59
+ },
60
+ verifyOtpCardUserOnboardingSuccess(draft) {
61
+ if (draft.cardUserOnboardingLocalData != null) {
62
+ draft.cardUserOnboardingLocalData.isPhoneVerified = true;
63
+ }
64
+ draft.verifyOtpStatus.fetchState = 'Completed';
65
+ draft.verifyOtpStatus.error = undefined;
66
+ },
67
+ verifyOtpCardUserOnboardingFailure(draft, action) {
68
+ draft.verifyOtpStatus.fetchState = 'Error';
69
+ draft.verifyOtpStatus.error = action.payload;
70
+ },
71
+ saveCardOnboardingUserDetails(
72
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
73
+ _draft) {
74
+ // Do nothing here
75
+ },
76
+ startActivationWait(draft) {
77
+ draft.activationWaitStatus.fetchState = 'In-Progress';
78
+ },
79
+ completeActivationWait(draft) {
80
+ draft.activationWaitStatus.fetchState = 'Completed';
81
+ },
82
+ setFirstViewAfterActivation(draft) {
83
+ draft.firstViewAfterActivation = true;
84
+ },
85
+ setFirstViewCompleteAfterActivation(draft) {
86
+ draft.firstViewAfterActivation = false;
87
+ },
88
+ clearCardUserOnboarding(draft) {
89
+ Object.assign(draft, exports.initialState);
90
+ },
91
+ },
92
+ });
93
+ _a = cardUserOnboarding.actions, exports.initializeCardUserOnboardingLocalData = _a.initializeCardUserOnboardingLocalData, exports.updateCardUserOnboardingLocalData = _a.updateCardUserOnboardingLocalData, exports.sendOtpCardUserOnboarding = _a.sendOtpCardUserOnboarding, exports.sendOtpCardUserOnboardingSuccess = _a.sendOtpCardUserOnboardingSuccess, exports.sendOtpCardUserOnboardingFailure = _a.sendOtpCardUserOnboardingFailure, exports.resendOtpCardUserOnboarding = _a.resendOtpCardUserOnboarding, exports.verifyOtpCardUserOnboarding = _a.verifyOtpCardUserOnboarding, exports.verifyOtpCardUserOnboardingSuccess = _a.verifyOtpCardUserOnboardingSuccess, exports.verifyOtpCardUserOnboardingFailure = _a.verifyOtpCardUserOnboardingFailure, exports.saveCardOnboardingUserDetails = _a.saveCardOnboardingUserDetails, exports.startActivationWait = _a.startActivationWait, exports.completeActivationWait = _a.completeActivationWait, exports.setFirstViewAfterActivation = _a.setFirstViewAfterActivation, exports.setFirstViewCompleteAfterActivation = _a.setFirstViewCompleteAfterActivation, exports.clearCardUserOnboarding = _a.clearCardUserOnboarding;
94
+ exports.default = cardUserOnboarding.reducer;
@@ -0,0 +1,18 @@
1
+ import { View } from '../../../../commonStateTypes/viewAndReport/viewAndReport';
2
+ import { RootState } from '../../../../reducer';
3
+ import { CardUserOnboardingLocalData } from './cardUserOnboardingState';
4
+ import { FetchStateAndError } from '../../../../commonStateTypes/common';
5
+ import { NewAddressData } from '../../../addressView/addressViewState';
6
+ import { TwoFactorAuthenticationView } from '../../../twoFactorAuthentication/twoFactorAuthenticationSelector';
7
+ export interface CardUserOnboardingView extends View {
8
+ cardUserOnboardingLocalData?: CardUserOnboardingLocalData;
9
+ isDOBPresent: boolean;
10
+ firstViewAfterActivation: boolean;
11
+ twoFAView: TwoFactorAuthenticationView;
12
+ onboardingProgressStatus: FetchStateAndError;
13
+ updateStatus: FetchStateAndError;
14
+ sendOtpStatus: FetchStateAndError;
15
+ verifyOtpStatus: FetchStateAndError;
16
+ addressData?: NewAddressData;
17
+ }
18
+ export declare const getCardUserOnboardingView: (state: RootState) => CardUserOnboardingView;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCardUserOnboardingView = void 0;
4
+ const toolkit_1 = require("@reduxjs/toolkit");
5
+ const twoFactorAuthenticationSelector_1 = require("../../../twoFactorAuthentication/twoFactorAuthenticationSelector");
6
+ const reduceFetchState_1 = require("../../../../commonStateTypes/reduceFetchState");
7
+ const userSelector_1 = require("../../../../entity/user/userSelector");
8
+ exports.getCardUserOnboardingView = (0, toolkit_1.createSelector)((state) => state, (state) => state.addressViewState, (state) => state.cardUserOnboardingState, (state) => state.settingsViewState, (state) => state.tenantState, (state) => state.userState, (state, addressViewState, cardUserOnboardingState, settingsViewState, tenantState, userState) => {
9
+ var _a, _b;
10
+ const twoFAView = (0, twoFactorAuthenticationSelector_1.getTwoFactorAuthenticationView)(state);
11
+ const updateStatus = (0, reduceFetchState_1.reduceAllFetchState)([
12
+ settingsViewState.profile.updateStatus,
13
+ cardUserOnboardingState.sendOtpStatus,
14
+ cardUserOnboardingState.verifyOtpStatus,
15
+ cardUserOnboardingState.activationWaitStatus,
16
+ ]);
17
+ const userId = (_a = tenantState.loggedInUser) === null || _a === void 0 ? void 0 : _a.userId;
18
+ if (userId == null) {
19
+ throw new Error(`User not logged in`);
20
+ }
21
+ const user = (0, userSelector_1.getUserByUserId)(userState, userId);
22
+ const isDOBPresent = (user === null || user === void 0 ? void 0 : user.birthday) != null;
23
+ return {
24
+ cardUserOnboardingLocalData: cardUserOnboardingState.cardUserOnboardingLocalData,
25
+ addressData: (_b = addressViewState.newAddressState) === null || _b === void 0 ? void 0 : _b['user_address'],
26
+ onboardingProgressStatus: updateStatus,
27
+ updateStatus: settingsViewState.profile.updateStatus,
28
+ sendOtpStatus: cardUserOnboardingState.sendOtpStatus,
29
+ verifyOtpStatus: cardUserOnboardingState.verifyOtpStatus,
30
+ twoFAView,
31
+ isDOBPresent,
32
+ firstViewAfterActivation: cardUserOnboardingState.firstViewAfterActivation,
33
+ };
34
+ });
@@ -0,0 +1,20 @@
1
+ import { FetchStateAndError, ID } from '../../../../commonStateTypes/common';
2
+ import { ZeniDate } from '../../../../zeniDayJS';
3
+ export interface CardUserOnboardingLocalData {
4
+ userId: ID;
5
+ firstName: string;
6
+ lastName: string;
7
+ email: string;
8
+ phone?: string;
9
+ isPhoneVerified?: boolean;
10
+ otpChallenge?: string;
11
+ dateOfBirth?: ZeniDate;
12
+ syncToken?: string;
13
+ }
14
+ export interface CardUserOnboardingState {
15
+ cardUserOnboardingLocalData?: CardUserOnboardingLocalData;
16
+ sendOtpStatus: FetchStateAndError;
17
+ verifyOtpStatus: FetchStateAndError;
18
+ activationWaitStatus: FetchStateAndError;
19
+ firstViewAfterActivation: boolean;
20
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { RootState } from '../../../../../reducer';
4
+ import { newAddressInLocalStore, resetNewAddressDataInLocalStore } from '../../../../addressView/addressViewReducer';
5
+ import { initializeCardUserOnboardingLocalData, updateCardUserOnboardingLocalData } from '../cardUserOnboardingReducer';
6
+ export declare type ActionType = ReturnType<typeof initializeCardUserOnboardingLocalData> | ReturnType<typeof updateCardUserOnboardingLocalData> | ReturnType<typeof newAddressInLocalStore> | ReturnType<typeof resetNewAddressDataInLocalStore>;
7
+ export declare const initializeCardUserOnboardingLocalDataEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.initializeCardUserOnboardingLocalDataEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const addressSelector_1 = require("../../../../../entity/address/addressSelector");
7
+ const addressViewReducer_1 = require("../../../../addressView/addressViewReducer");
8
+ const cardUserOnboardingReducer_1 = require("../cardUserOnboardingReducer");
9
+ const userRoleSelector_1 = require("../../../../../entity/userRole/userRoleSelector");
10
+ const userSelector_1 = require("../../../../../entity/user/userSelector");
11
+ const initializeCardUserOnboardingLocalDataEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(cardUserOnboardingReducer_1.initializeCardUserOnboardingLocalData.match), (0, operators_1.mergeMap)((action) => {
12
+ const { userId } = action.payload;
13
+ const actions = [
14
+ (0, addressViewReducer_1.resetNewAddressDataInLocalStore)('user_address'),
15
+ ];
16
+ const userState = state$.value.userState;
17
+ const userRoleState = state$.value.userRoleState;
18
+ const user = (0, userSelector_1.getUserByUserId)(userState, userId);
19
+ const userRole = (0, userRoleSelector_1.getUserRoleByUserId)(userRoleState, userId);
20
+ const userAddress = (userRole === null || userRole === void 0 ? void 0 : userRole.addressId) != null
21
+ ? (0, addressSelector_1.getAddressByAddressId)(state$.value.addressState, userRole.addressId)
22
+ : undefined;
23
+ if (userAddress != null) {
24
+ actions.push((0, addressViewReducer_1.newAddressInLocalStore)({
25
+ addressType: 'user_address',
26
+ addressToCreate: userAddress,
27
+ }));
28
+ }
29
+ if (user != null && userRole != null) {
30
+ const dateOfBirth = user.birthday;
31
+ const phoneNumber = user.phone;
32
+ const isPhoneVerified = user === null || user === void 0 ? void 0 : user.isPhoneVerified;
33
+ const syncToken = user === null || user === void 0 ? void 0 : user.syncToken;
34
+ const cardUserOnboardingLocalData = {
35
+ userId,
36
+ firstName: user.firstName,
37
+ lastName: user.lastName,
38
+ email: user.email,
39
+ dateOfBirth,
40
+ phone: phoneNumber,
41
+ isPhoneVerified,
42
+ syncToken,
43
+ };
44
+ actions.push((0, cardUserOnboardingReducer_1.updateCardUserOnboardingLocalData)({
45
+ localData: cardUserOnboardingLocalData,
46
+ }));
47
+ }
48
+ return (0, rxjs_1.from)(actions);
49
+ }));
50
+ exports.initializeCardUserOnboardingLocalDataEpic = initializeCardUserOnboardingLocalDataEpic;
@@ -0,0 +1,7 @@
1
+ import { ActionsObservable, StateObservable } from 'redux-observable';
2
+ import { Observable } from 'rxjs';
3
+ import { RootState } from '../../../../../reducer';
4
+ import { saveCardOnboardingUserDetails } from '../cardUserOnboardingReducer';
5
+ import { updateMyProfile } from '../../../../settingsView/settingsViewReducer';
6
+ export declare type ActionType = ReturnType<typeof saveCardOnboardingUserDetails> | ReturnType<typeof updateMyProfile>;
7
+ export declare const saveCardOnboardingUserDetailsEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>) => Observable<ActionType>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.saveCardOnboardingUserDetailsEpic = void 0;
4
+ const rxjs_1 = require("rxjs");
5
+ const operators_1 = require("rxjs/operators");
6
+ const cardUserOnboardingReducer_1 = require("../cardUserOnboardingReducer");
7
+ const settingsViewReducer_1 = require("../../../../settingsView/settingsViewReducer");
8
+ const saveCardOnboardingUserDetailsEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(cardUserOnboardingReducer_1.saveCardOnboardingUserDetails.match), (0, operators_1.mergeMap)(() => {
9
+ var _a;
10
+ const localData = state$.value.cardUserOnboardingState.cardUserOnboardingLocalData;
11
+ const address = (_a = state$.value.addressViewState.newAddressState) === null || _a === void 0 ? void 0 : _a.user_address.addressToCreate;
12
+ return (0, rxjs_1.from)([
13
+ (0, settingsViewReducer_1.updateMyProfile)('CardUserOnboarding', localData === null || localData === void 0 ? void 0 : localData.phone, localData === null || localData === void 0 ? void 0 : localData.otpChallenge, localData === null || localData === void 0 ? void 0 : localData.dateOfBirth, address),
14
+ ]);
15
+ }));
16
+ exports.saveCardOnboardingUserDetailsEpic = saveCardOnboardingUserDetailsEpic;
@@ -3,6 +3,7 @@ import { ChargeCardTransactionPayload } from '../../../../entity/chargeCardTrans
3
3
  import { AttachmentPayload } from '../../../../entity/transaction/payloadTypes/attachmentPayload';
4
4
  import { UserPayload } from '../../../../entity/user/userPayload';
5
5
  import { UserRolePayload } from '../../../../entity/userRole/userRolePayload';
6
+ import { AddressPayload } from '../../../../entity/address/addressPayload';
6
7
  import { ZeniAPIResponse } from '../../../../responsePayload';
7
8
  interface ChargeCardTransactionAttachmentPayload {
8
9
  attachments: AttachmentPayload[];
@@ -12,6 +13,7 @@ interface ChargeCardDetailPayload {
12
13
  card: ChargeCardPayload;
13
14
  users: UserPayload[];
14
15
  user_roles: UserRolePayload[];
16
+ addresses: AddressPayload[];
15
17
  }
16
18
  export declare type FetchChargeCardDetailResponse = ZeniAPIResponse<ChargeCardDetailPayload>;
17
19
  export interface ChargeCardTransactionListPayload {
@@ -5,8 +5,8 @@ import { RootState } from '../../../../reducer';
5
5
  import { ChargeCardConfigState } from '../chargeCardConfig/chargeCardConfigState';
6
6
  import { ChargeCardWithUser } from '../chargeCardList/chargeCardListSelector';
7
7
  import { ChargeCardDetailUiState } from './chargeCardDetail';
8
- import { TwoFactorAuthenticationState } from '../../../twoFactorAuthentication/twoFactorAuthentication';
9
8
  import { Attachment } from '../../../../entity/transaction/stateTypes/attachment';
9
+ import { TwoFactorAuthenticationView } from '../../../twoFactorAuthentication/twoFactorAuthenticationSelector';
10
10
  export interface ChargeCardDetailSelectorView extends SelectorView {
11
11
  chargeCardConfig: ChargeCardConfigState;
12
12
  transactions: ChargeCardTransaction[];
@@ -15,7 +15,7 @@ export interface ChargeCardDetailSelectorView extends SelectorView {
15
15
  isViewReceiptClickedImmediatelyAfterUploadTransactionId: Record<ID, boolean>;
16
16
  uiState: ChargeCardDetailUiState;
17
17
  transactionListFetchState: FetchStateAndError;
18
- twoFAView: TwoFactorAuthenticationState;
18
+ twoFAView: TwoFactorAuthenticationView;
19
19
  loggedInUserPhone: string;
20
20
  updateFetchState: FetchStateAndError;
21
21
  chargeCard?: ChargeCardWithUser;
@@ -13,11 +13,13 @@ const classSelector_1 = require("../../../../entity/class/classSelector");
13
13
  const userSelector_1 = require("../../../../entity/user/userSelector");
14
14
  const userRoleSelector_1 = require("../../../../entity/userRole/userRoleSelector");
15
15
  const chargeCardDetail_1 = require("./chargeCardDetail");
16
+ const twoFactorAuthenticationSelector_1 = require("../../../twoFactorAuthentication/twoFactorAuthenticationSelector");
16
17
  const getChargeCardDetailView = (state, chargeCardId) => {
17
18
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
18
- const { tenantState, addressState, chargeCardDetailState, chargeCardState, classState, userState, userRoleState, chargeCardConfigState, chargeCardTransactionState, twoFactorAuthenticationState, } = state;
19
+ const { tenantState, addressState, chargeCardDetailState, chargeCardState, classState, userState, userRoleState, chargeCardConfigState, chargeCardTransactionState, } = state;
20
+ const twoFactorAuthenticationView = (0, twoFactorAuthenticationSelector_1.getTwoFactorAuthenticationView)(state);
19
21
  const loggedInUserId = (_b = (_a = tenantState.loggedInUser) === null || _a === void 0 ? void 0 : _a.userId) !== null && _b !== void 0 ? _b : '';
20
- const loggedInUserPhone = (_e = (_c = twoFactorAuthenticationState.phone) !== null && _c !== void 0 ? _c : (_d = (0, userSelector_1.getUserByUserId)(userState, loggedInUserId)) === null || _d === void 0 ? void 0 : _d.phone) !== null && _e !== void 0 ? _e : '';
22
+ const loggedInUserPhone = (_e = (_c = twoFactorAuthenticationView.phone) !== null && _c !== void 0 ? _c : (_d = (0, userSelector_1.getUserByUserId)(userState, loggedInUserId)) === null || _d === void 0 ? void 0 : _d.phone) !== null && _e !== void 0 ? _e : '';
21
23
  let chargeCardWithUser = undefined;
22
24
  const chargeCardDetail = (0, get_1.default)(chargeCardDetailState.detailById, chargeCardId, undefined);
23
25
  const chargeCard = (0, chargeCardSelector_1.getChargeCardById)(chargeCardState, chargeCardId);
@@ -40,6 +42,7 @@ const getChargeCardDetailView = (state, chargeCardId) => {
40
42
  if (chargeCardDetail &&
41
43
  chargeCardDetail.fetchState === 'Completed' &&
42
44
  chargeCard != null) {
45
+ const cardCreatedByUser = (0, userSelector_1.getUserByUserId)(userState, chargeCard.cardCreaterUserId);
43
46
  const cardHolderUser = (0, userSelector_1.getUserByUserId)(userState, chargeCard.cardHolderUserId);
44
47
  const cardHolderUserRole = (0, userRoleSelector_1.getUserRoleByUserId)(userRoleState, chargeCard.cardHolderUserId);
45
48
  const department = cardHolderUserRole != null
@@ -48,9 +51,20 @@ const getChargeCardDetailView = (state, chargeCardId) => {
48
51
  reportId: 'class_list',
49
52
  })
50
53
  : undefined;
51
- const address = (0, addressSelector_1.getAddressByAddressId)(addressState, chargeCard === null || chargeCard === void 0 ? void 0 : chargeCard.addressId);
52
- chargeCardWithUser = Object.assign(Object.assign({}, chargeCard), { cardHolderUser, cardHolderRoles: cardHolderUserRole, department,
53
- address });
54
+ const mailingAddress = (chargeCard === null || chargeCard === void 0 ? void 0 : chargeCard.mailingAddressId) != null
55
+ ? (0, addressSelector_1.getAddressByAddressId)(addressState, chargeCard.mailingAddressId)
56
+ : undefined;
57
+ const billingAddress = (0, addressSelector_1.getAddressByAddressId)(addressState, chargeCard.billingAddressId);
58
+ if (cardCreatedByUser == null ||
59
+ cardHolderUser == null ||
60
+ cardHolderUserRole == null ||
61
+ billingAddress == null) {
62
+ throw Error(`Cannot find details for card detail ${chargeCard.id}`);
63
+ }
64
+ chargeCardWithUser = Object.assign(Object.assign({}, chargeCard), { cardCreatedByUser,
65
+ cardHolderUser, cardHolderRoles: cardHolderUserRole, department,
66
+ mailingAddress,
67
+ billingAddress });
54
68
  const transactionIds = chargeCardDetail.transactionList.transactionIds;
55
69
  transactions = (0, chargeCardTransactionSelector_1.getChargeCardTransactionsByIds)(chargeCardTransactionState, transactionIds);
56
70
  transactionListFetchState = {
@@ -74,7 +88,7 @@ const getChargeCardDetailView = (state, chargeCardId) => {
74
88
  isViewReceiptClickedImmediatelyAfterUploadTransactionId: (_j = chargeCardDetail === null || chargeCardDetail === void 0 ? void 0 : chargeCardDetail.transactionList.isViewReceiptClickedImmediatelyAfterUploadTransactionId) !== null && _j !== void 0 ? _j : {},
75
89
  uiState,
76
90
  transactionListFetchState,
77
- twoFAView: twoFactorAuthenticationState,
91
+ twoFAView: twoFactorAuthenticationView,
78
92
  loggedInUserPhone,
79
93
  version: '1.0',
80
94
  };