@zeniai/client-epic-state 4.16.9 → 4.16.12

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 (165) hide show
  1. package/README.md +0 -78
  2. package/lib/commonStateTypes/animations.d.ts +1 -1
  3. package/lib/commonStateTypes/animations.js +1 -1
  4. package/lib/entity/chargeCard/chargeCard.d.ts +8 -26
  5. package/lib/entity/chargeCard/chargeCard.js +6 -25
  6. package/lib/entity/chargeCard/chargeCardPayload.d.ts +5 -41
  7. package/lib/entity/chargeCard/chargeCardPayload.js +8 -20
  8. package/lib/entity/chargeCardTransaction/chargeCardTransaction.d.ts +1 -1
  9. package/lib/entity/chargeCardTransaction/chargeCardTransaction.js +1 -5
  10. package/lib/entity/company/companyPayload.d.ts +1 -12
  11. package/lib/entity/company/companyPayload.js +0 -14
  12. package/lib/entity/company/companyStateTypes.d.ts +0 -11
  13. package/lib/entity/depositAccount/depositAccount.d.ts +2 -20
  14. package/lib/entity/depositAccount/depositAccountPayload.d.ts +1 -22
  15. package/lib/entity/depositAccount/depositAccountPayload.js +1 -39
  16. package/lib/entity/depositAccount/depositAccountReducer.d.ts +2 -2
  17. package/lib/entity/depositAccount/depositAccountReducer.js +2 -8
  18. package/lib/entity/depositAccount/depositAccountSelector.d.ts +1 -3
  19. package/lib/entity/depositAccount/depositAccountSelector.js +0 -10
  20. package/lib/entity/snackbar/snackbarTypes.d.ts +1 -1
  21. package/lib/entity/snackbar/snackbarTypes.js +0 -2
  22. package/lib/entity/tenant/clearAllEpic.d.ts +1 -2
  23. package/lib/entity/tenant/clearAllEpic.js +0 -2
  24. package/lib/entity/tenant/tenantSelector.d.ts +2 -6
  25. package/lib/entity/tenant/tenantSelector.js +2 -10
  26. package/lib/epic.d.ts +1 -5
  27. package/lib/epic.js +1 -5
  28. package/lib/index.d.ts +18 -20
  29. package/lib/index.js +29 -42
  30. package/lib/reducer.d.ts +1 -4
  31. package/lib/reducer.js +0 -3
  32. package/lib/view/addressView/__mocks__/json/createCompanyAddressSuccess.json +0 -8
  33. package/lib/view/addressView/__mocks__/json/createCompanyUserAddressSuccess.json +0 -16
  34. package/lib/view/addressView/addressViewState.d.ts +1 -1
  35. package/lib/view/dashboard/dashboardSelector.js +6 -7
  36. package/lib/view/expenseAutomationView/epics/accountRecon/updateReconcileTabLocalDataEpic.js +4 -5
  37. package/lib/view/expenseAutomationView/epics/common/fetchAllExpenseAutomationTabsEpic.js +2 -1
  38. package/lib/view/expenseAutomationView/epics/fluxAnalysis/fetchFluxAnalysisViewEpic.js +6 -18
  39. package/lib/view/expenseAutomationView/epics/fluxAnalysis/reviewFluxAnalysisEpic.js +4 -1
  40. package/lib/view/expenseAutomationView/helpers/helpers.js +4 -4
  41. package/lib/view/expenseAutomationView/payload/fluxAnalysisPayload.d.ts +9 -22
  42. package/lib/view/expenseAutomationView/payload/fluxAnalysisPayload.js +2 -2
  43. package/lib/view/expenseAutomationView/reducers/fluxAnalysisViewReducer.d.ts +5 -13
  44. package/lib/view/expenseAutomationView/reducers/fluxAnalysisViewReducer.js +115 -245
  45. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +15 -9
  46. package/lib/view/expenseAutomationView/selectorTypes/fluxAnalysisViewSelectorTypes.d.ts +9 -29
  47. package/lib/view/expenseAutomationView/selectors/fluxAnalysisViewSelector.js +40 -108
  48. package/lib/view/expenseAutomationView/types/fluxAnalysisViewState.d.ts +15 -40
  49. package/lib/view/expenseAutomationView/types/fluxAnalysisViewState.js +1 -1
  50. package/lib/view/onboardingView/cockpitView/epic/initializeOnboardingCustomerViewUpdateDataEpic.js +4 -4
  51. package/lib/view/onboardingView/cockpitView/onboardingCockpitViewReducer.d.ts +1 -2
  52. package/lib/view/onboardingView/cockpitView/onboardingCockpitViewReducer.js +2 -2
  53. package/lib/view/settingsView/settingsViewHelpers.d.ts +4 -4
  54. package/lib/view/settingsView/settingsViewHelpers.js +8 -9
  55. package/lib/view/spendManagement/billPay/billPayReview/billPayReviewSelector.js +1 -1
  56. package/lib/view/spendManagement/billPay/editBillView/editBillViewReducer.d.ts +1 -6
  57. package/lib/view/spendManagement/billPay/editBillView/editBillViewReducer.js +2 -20
  58. package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.d.ts +0 -5
  59. package/lib/view/spendManagement/billPay/editBillView/editBillViewSelector.js +2 -9
  60. package/lib/view/spendManagement/billPay/editBillView/editBillViewState.d.ts +0 -1
  61. package/lib/view/spendManagement/chargeCards/cardUserOnboarding/cardUserOnboardingSelector.js +3 -4
  62. package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigPayload.d.ts +3 -5
  63. package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigPayload.js +2 -4
  64. package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigReducer.js +3 -8
  65. package/lib/view/spendManagement/chargeCards/chargeCardConfig/chargeCardConfigState.d.ts +2 -4
  66. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetail.d.ts +0 -12
  67. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetail.js +0 -26
  68. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailPayload.d.ts +0 -2
  69. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.d.ts +4 -43
  70. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer.js +9 -104
  71. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailSelector.d.ts +0 -15
  72. package/lib/view/spendManagement/chargeCards/chargeCardDetail/chargeCardDetailSelector.js +16 -70
  73. package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailEpic.d.ts +1 -2
  74. package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardDetailEpic.js +3 -12
  75. package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchChargeCardTransactionListEpic.js +1 -2
  76. package/lib/view/spendManagement/chargeCards/chargeCardDetail/updateChargeCardLimitEpic.js +2 -2
  77. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.d.ts +1 -11
  78. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardList.js +1 -20
  79. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListPayload.d.ts +1 -16
  80. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.d.ts +4 -6
  81. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListReducer.js +4 -30
  82. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.d.ts +2 -5
  83. package/lib/view/spendManagement/chargeCards/chargeCardList/chargeCardListSelector.js +14 -26
  84. package/lib/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.d.ts +2 -2
  85. package/lib/view/spendManagement/chargeCards/chargeCardList/fetchChargeCardListPageEpic.js +5 -20
  86. package/lib/view/spendManagement/chargeCards/chargeCardSetUp/chargeCardSetUpViewReducer.d.ts +1 -2
  87. package/lib/view/spendManagement/chargeCards/chargeCardSetUp/chargeCardSetUpViewReducer.js +2 -4
  88. package/lib/view/spendManagement/chargeCards/chargeCardSetUp/chargeCardSetUpViewSelector.d.ts +1 -2
  89. package/lib/view/spendManagement/chargeCards/chargeCardSetUp/chargeCardSetUpViewSelector.js +0 -2
  90. package/lib/view/spendManagement/chargeCards/chargeCardSetUp/epic/acceptChargeCardTermsEpic.js +2 -19
  91. package/lib/view/spendManagement/chargeCards/issueChargeCard/fetchIssueCardPageEpic.d.ts +2 -2
  92. package/lib/view/spendManagement/chargeCards/issueChargeCard/fetchIssueCardPageEpic.js +3 -15
  93. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardEpic.d.ts +2 -2
  94. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardEpic.js +25 -65
  95. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer.d.ts +3 -11
  96. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardReducer.js +11 -45
  97. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector.d.ts +3 -6
  98. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardSelector.js +18 -33
  99. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardState.d.ts +8 -41
  100. package/lib/view/spendManagement/chargeCards/issueChargeCard/issueChargeCardState.js +21 -0
  101. package/lib/view/spendManagement/commonSetup/epic/setup/enableSetupEpic.js +0 -9
  102. package/lib/view/spendManagement/commonSetup/epic/setup/updateBusinessVerificationDetailsEpic.js +3 -8
  103. package/lib/view/spendManagement/commonSetup/setupViewReducer.d.ts +4 -4
  104. package/lib/view/spendManagement/commonSetup/setupViewSelector.js +1 -2
  105. package/lib/view/spendManagement/commonSetup/setupViewState.d.ts +1 -3
  106. package/lib/view/spendManagement/commonSetup/setupViewState.js +1 -13
  107. package/lib/view/spendManagement/helpers.d.ts +0 -3
  108. package/lib/view/spendManagement/helpers.js +1 -13
  109. package/lib/view/spendManagement/plaidAccount/epic/paymentAccounts/getPaymentAccountsEpic.js +1 -2
  110. package/lib/view/spendManagement/plaidAccount/epic/paymentAccounts/updatePaymentAccountEpic.js +1 -2
  111. package/lib/view/spendManagement/plaidAccount/epic/paymentAccounts/updatePaymentAccountLoginStatusEpic.js +1 -2
  112. package/lib/view/spendManagement/plaidAccount/epic/paymentAccounts/updatePaymentAccountStatusEpic.js +1 -2
  113. package/lib/view/spendManagement/plaidAccount/epic/plaidConnection/establishPlaidConnectionEpic.d.ts +1 -2
  114. package/lib/view/spendManagement/plaidAccount/epic/plaidConnection/establishPlaidConnectionEpic.js +1 -6
  115. package/lib/view/spendManagement/plaidAccount/plaidAccountViewReducer.d.ts +10 -10
  116. package/lib/view/spendManagement/plaidAccount/plaidAccountViewReducer.js +0 -1
  117. package/lib/view/spendManagement/plaidAccount/plaidAccountViewState.d.ts +1 -1
  118. package/lib/view/spendManagement/zeniAccounts/checkDeposit/checkDepositSelector.js +1 -1
  119. package/lib/view/spendManagement/zeniAccounts/depositAccountList/depositAccountListSelector.d.ts +1 -1
  120. package/lib/view/spendManagement/zeniAccounts/depositAccountList/depositAccountListSelector.js +3 -3
  121. package/lib/view/spendManagement/zeniAccounts/expressPay/expressPaySelector.js +1 -1
  122. package/lib/view/spendManagement/zeniAccounts/transferDetail/transferDetailSelector.js +1 -1
  123. package/lib/view/spendManagement/zeniAccounts/zeniAccountList/zeniAccountListSelector.js +1 -1
  124. package/lib/view/twoFactorAuthentication/resendOtpEpic.d.ts +2 -3
  125. package/lib/view/twoFactorAuthentication/resendOtpEpic.js +19 -44
  126. package/lib/view/twoFactorAuthentication/sendOtpEpic.d.ts +1 -2
  127. package/lib/view/twoFactorAuthentication/sendOtpEpic.js +18 -45
  128. package/lib/view/twoFactorAuthentication/twoFactorAuthentication.d.ts +5 -17
  129. package/lib/view/twoFactorAuthentication/twoFactorAuthentication.js +0 -33
  130. package/lib/view/twoFactorAuthentication/twoFactorAuthenticationPayload.d.ts +7 -7
  131. package/lib/view/twoFactorAuthentication/twoFactorAuthenticationPayload.js +6 -6
  132. package/lib/view/twoFactorAuthentication/twoFactorAuthenticationReducer.d.ts +6 -22
  133. package/lib/view/twoFactorAuthentication/twoFactorAuthenticationReducer.js +60 -176
  134. package/lib/view/twoFactorAuthentication/twoFactorAuthenticationSelector.d.ts +3 -5
  135. package/lib/view/twoFactorAuthentication/twoFactorAuthenticationSelector.js +2 -13
  136. package/lib/view/twoFactorAuthentication/verifyOtpEpic.d.ts +2 -5
  137. package/lib/view/twoFactorAuthentication/verifyOtpEpic.js +5 -46
  138. package/lib/view/userListView/fetchUserListByTypeEpic.d.ts +2 -2
  139. package/lib/view/userListView/fetchUserListByTypeEpic.js +3 -4
  140. package/lib/view/userListView/userListViewPayload.d.ts +0 -11
  141. package/lib/view/vendorTabView/vendorTabViewReducer.d.ts +2 -4
  142. package/lib/view/vendorTabView/vendorTabViewReducer.js +2 -15
  143. package/lib/view/vendorTabView/vendorTabViewState.d.ts +1 -7
  144. package/lib/view/vendorTabView/vendorTabViewState.js +0 -12
  145. package/package.json +7 -10
  146. package/lib/entity/connectedAccount/connectedAccount.d.ts +0 -19
  147. package/lib/entity/connectedAccount/connectedAccount.js +0 -10
  148. package/lib/entity/connectedAccount/connectedAccountPayload.d.ts +0 -11
  149. package/lib/entity/connectedAccount/connectedAccountPayload.js +0 -15
  150. package/lib/entity/connectedAccount/connectedAccountReducer.d.ts +0 -6
  151. package/lib/entity/connectedAccount/connectedAccountReducer.js +0 -27
  152. package/lib/entity/connectedAccount/connectedAccountSelector.d.ts +0 -4
  153. package/lib/entity/connectedAccount/connectedAccountSelector.js +0 -17
  154. package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchDepositAccountLimitEpic.d.ts +0 -8
  155. package/lib/view/spendManagement/chargeCards/chargeCardDetail/fetchDepositAccountLimitEpic.js +0 -41
  156. package/lib/view/spendManagement/chargeCards/chargeCardDetail/updateDebitCardPinAttemptEpic.d.ts +0 -11
  157. package/lib/view/spendManagement/chargeCards/chargeCardDetail/updateDebitCardPinAttemptEpic.js +0 -42
  158. package/lib/view/spendManagement/chargeCards/chargeCardList/fetchDebitCardSummaryEpic.d.ts +0 -7
  159. package/lib/view/spendManagement/chargeCards/chargeCardList/fetchDebitCardSummaryEpic.js +0 -23
  160. package/lib/view/spendManagement/chargeCards/issueChargeCard/depositAccountWithLimitPayload.d.ts +0 -6
  161. package/lib/view/spendManagement/chargeCards/issueChargeCard/depositAccountWithLimitPayload.js +0 -2
  162. package/lib/view/spendManagement/chargeCards/issueChargeCard/fetchDepositAccountListForCardsEpic.d.ts +0 -8
  163. package/lib/view/spendManagement/chargeCards/issueChargeCard/fetchDepositAccountListForCardsEpic.js +0 -31
  164. package/lib/view/vendorTabView/vendorTabViewSelector.d.ts +0 -8
  165. package/lib/view/vendorTabView/vendorTabViewSelector.js +0 -15
@@ -8,14 +8,27 @@ const vendorViewReducer_1 = require("../commonVendorView/vendorView/vendorViewRe
8
8
  const onboardingCustomerViewReducer_1 = require("../onboardingView/customerView/onboardingCustomerViewReducer");
9
9
  const settingsViewReducer_1 = require("../settingsView/settingsViewReducer");
10
10
  const cardUserOnboardingReducer_1 = require("../spendManagement/chargeCards/cardUserOnboarding/cardUserOnboardingReducer");
11
- const chargeCardDetailReducer_1 = require("../spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer");
12
11
  const setupViewReducer_1 = require("../spendManagement/commonSetup/setupViewReducer");
13
12
  const twoFactorAuthenticationReducer_1 = require("./twoFactorAuthenticationReducer");
14
- const resendOtpEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(twoFactorAuthenticationReducer_1.resendOtp.match), (0, operators_1.mergeMap)((action) => {
13
+ const resendOtpEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(twoFactorAuthenticationReducer_1.resendOtp.match), (0, operators_1.mergeMap)((action) => {
14
+ var _a;
15
15
  const resendOtpActions = [];
16
- const { otpChallenge, twoFASource, entityId } = action.payload;
16
+ const { otpChallenge, twoFASource } = action.payload;
17
+ const tenantState = state$.value.tenantState;
18
+ const companyState = state$.value.companyState;
19
+ const { currentTenantId } = tenantState;
20
+ const companyId = currentTenantId != null
21
+ ? (_a = tenantState.tenantsById[currentTenantId]) === null || _a === void 0 ? void 0 : _a.companyId
22
+ : undefined;
23
+ const isCardsEnabled = companyId != null
24
+ ? companyState.companiesById[companyId].companyChargeCardInfo
25
+ .isChargeCardEnabled
26
+ : false;
17
27
  const payload = {
18
28
  otp_challenge: otpChallenge,
29
+ is_for_charge_cards: twoFASource === 'ChargeCard' ||
30
+ twoFASource === 'CardUserOnboarding' ||
31
+ (twoFASource === 'MyProfile' && isCardsEnabled),
19
32
  };
20
33
  switch (twoFASource) {
21
34
  case 'SpendManagementSetup':
@@ -39,11 +52,7 @@ const resendOtpEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operator
39
52
  .pipe((0, operators_1.mergeMap)((response) => {
40
53
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
41
54
  const updateActions = [
42
- (0, twoFactorAuthenticationReducer_1.sendOtpSuccess)({
43
- otpChallenge: response.data.otp_challenge,
44
- twoFASource,
45
- entityId,
46
- }),
55
+ (0, twoFactorAuthenticationReducer_1.sendOtpSuccess)({ otpChallenge: response.data.otp_challenge }),
47
56
  ];
48
57
  switch (twoFASource) {
49
58
  case 'SpendManagementSetup':
@@ -71,24 +80,12 @@ const resendOtpEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operator
71
80
  otpChallenge: response.data.otp_challenge,
72
81
  }));
73
82
  break;
74
- case 'ChargeCardHolder':
75
- if (entityId != null) {
76
- updateActions.push((0, chargeCardDetailReducer_1.sendOtpCardHolderSuccess)({
77
- otpChallenge: response.data.otp_challenge,
78
- chargeCardId: entityId,
79
- }));
80
- }
81
- break;
82
83
  }
83
84
  return (0, rxjs_1.from)(updateActions);
84
85
  }
85
86
  else {
86
87
  const updateActions = [
87
- (0, twoFactorAuthenticationReducer_1.sendOtpFailure)({
88
- error: response.status,
89
- twoFASource,
90
- entityId,
91
- }),
88
+ (0, twoFactorAuthenticationReducer_1.sendOtpFailure)(response.status),
92
89
  ];
93
90
  switch (twoFASource) {
94
91
  case 'SpendManagementSetup':
@@ -106,26 +103,12 @@ const resendOtpEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operator
106
103
  case 'CardUserOnboarding':
107
104
  updateActions.push((0, cardUserOnboardingReducer_1.sendOtpCardUserOnboardingFailure)(response.status));
108
105
  break;
109
- case 'ChargeCardHolder':
110
- if (entityId != null) {
111
- updateActions.push((0, chargeCardDetailReducer_1.sendOtpCardHolderFailure)({
112
- error: response.status,
113
- chargeCardId: entityId,
114
- }));
115
- }
116
- break;
117
106
  }
118
107
  return (0, rxjs_1.from)(updateActions);
119
108
  }
120
109
  }), (0, operators_1.catchError)((error) => {
121
110
  const zeniAPIStatus = (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Resend otp api errored out' + JSON.stringify(error));
122
- const updateActions = [
123
- (0, twoFactorAuthenticationReducer_1.sendOtpFailure)({
124
- error: zeniAPIStatus,
125
- twoFASource,
126
- entityId,
127
- }),
128
- ];
111
+ const updateActions = [(0, twoFactorAuthenticationReducer_1.sendOtpFailure)(zeniAPIStatus)];
129
112
  switch (twoFASource) {
130
113
  case 'SpendManagementSetup':
131
114
  updateActions.push((0, setupViewReducer_1.sendOtpFailureSpendManagementSetUp)(zeniAPIStatus));
@@ -142,14 +125,6 @@ const resendOtpEpic = (actions$, _state$, zeniAPI) => actions$.pipe((0, operator
142
125
  case 'CardUserOnboarding':
143
126
  updateActions.push((0, cardUserOnboardingReducer_1.sendOtpCardUserOnboardingFailure)(zeniAPIStatus));
144
127
  break;
145
- case 'ChargeCardHolder':
146
- if (entityId != null) {
147
- updateActions.push((0, chargeCardDetailReducer_1.sendOtpCardHolderFailure)({
148
- error: zeniAPIStatus,
149
- chargeCardId: entityId,
150
- }));
151
- }
152
- break;
153
128
  }
154
129
  return (0, rxjs_1.from)(updateActions);
155
130
  }));
@@ -6,8 +6,7 @@ import { sendOtpVendorView, sendOtpVendorViewFailure, sendOtpVendorViewSuccess }
6
6
  import { sendOnboardingOfficerOtp, sendOnboardingOfficerOtpFailure, sendOnboardingOfficerOtpSuccess } from '../onboardingView/customerView/onboardingCustomerViewReducer';
7
7
  import { sendOtpMyProfile, sendOtpMyProfileFailure, sendOtpMyProfileSuccess } from '../settingsView/settingsViewReducer';
8
8
  import { sendOtpCardUserOnboarding, sendOtpCardUserOnboardingFailure, sendOtpCardUserOnboardingSuccess } from '../spendManagement/chargeCards/cardUserOnboarding/cardUserOnboardingReducer';
9
- import { sendOtpCardHolder, sendOtpCardHolderFailure, sendOtpCardHolderSuccess } from '../spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer';
10
9
  import { sendOtpFailureSpendManagementSetUp, sendOtpSpendManagementSetUp, sendOtpSuccessSpendManagementSetUp } from '../spendManagement/commonSetup/setupViewReducer';
11
10
  import { sendOtp, sendOtpFailure, sendOtpSuccess } from './twoFactorAuthenticationReducer';
12
- export type ActionType = ReturnType<typeof sendOtp> | ReturnType<typeof sendOtpSuccess> | ReturnType<typeof sendOtpFailure> | ReturnType<typeof sendOtpSpendManagementSetUp> | ReturnType<typeof sendOtpSuccessSpendManagementSetUp> | ReturnType<typeof sendOtpFailureSpendManagementSetUp> | ReturnType<typeof sendOtpVendorView> | ReturnType<typeof sendOtpVendorViewSuccess> | ReturnType<typeof sendOtpVendorViewFailure> | ReturnType<typeof sendOnboardingOfficerOtp> | ReturnType<typeof sendOnboardingOfficerOtpSuccess> | ReturnType<typeof sendOnboardingOfficerOtpFailure> | ReturnType<typeof sendOtpCardUserOnboarding> | ReturnType<typeof sendOtpCardUserOnboardingSuccess> | ReturnType<typeof sendOtpCardUserOnboardingFailure> | ReturnType<typeof sendOtpMyProfile> | ReturnType<typeof sendOtpCardHolder> | ReturnType<typeof sendOtpCardHolderSuccess> | ReturnType<typeof sendOtpCardHolderFailure> | ReturnType<typeof sendOtpMyProfileFailure> | ReturnType<typeof sendOtpMyProfileSuccess>;
11
+ export type ActionType = ReturnType<typeof sendOtp> | ReturnType<typeof sendOtpSuccess> | ReturnType<typeof sendOtpFailure> | ReturnType<typeof sendOtpSpendManagementSetUp> | ReturnType<typeof sendOtpSuccessSpendManagementSetUp> | ReturnType<typeof sendOtpFailureSpendManagementSetUp> | ReturnType<typeof sendOtpVendorView> | ReturnType<typeof sendOtpVendorViewSuccess> | ReturnType<typeof sendOtpVendorViewFailure> | ReturnType<typeof sendOnboardingOfficerOtp> | ReturnType<typeof sendOnboardingOfficerOtpSuccess> | ReturnType<typeof sendOnboardingOfficerOtpFailure> | ReturnType<typeof sendOtpCardUserOnboarding> | ReturnType<typeof sendOtpCardUserOnboardingSuccess> | ReturnType<typeof sendOtpCardUserOnboardingFailure> | ReturnType<typeof sendOtpMyProfile> | ReturnType<typeof sendOtpMyProfileFailure> | ReturnType<typeof sendOtpMyProfileSuccess>;
13
12
  export declare const sendOtpEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
@@ -8,23 +8,31 @@ const vendorViewReducer_1 = require("../commonVendorView/vendorView/vendorViewRe
8
8
  const onboardingCustomerViewReducer_1 = require("../onboardingView/customerView/onboardingCustomerViewReducer");
9
9
  const settingsViewReducer_1 = require("../settingsView/settingsViewReducer");
10
10
  const cardUserOnboardingReducer_1 = require("../spendManagement/chargeCards/cardUserOnboarding/cardUserOnboardingReducer");
11
- const chargeCardDetailReducer_1 = require("../spendManagement/chargeCards/chargeCardDetail/chargeCardDetailReducer");
12
11
  const setupViewReducer_1 = require("../spendManagement/commonSetup/setupViewReducer");
13
12
  const twoFactorAuthenticationReducer_1 = require("./twoFactorAuthenticationReducer");
14
13
  const sendOtpEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(twoFactorAuthenticationReducer_1.sendOtp.match), (0, operators_1.mergeMap)((action) => {
14
+ var _a;
15
15
  const sendOtpActions = [];
16
- const { phoneNumber, twoFASource, entityId } = action.payload;
16
+ const { phoneNumber, twoFASource } = action.payload;
17
+ const tenantState = state$.value.tenantState;
18
+ const companyState = state$.value.companyState;
19
+ const { currentTenantId } = tenantState;
20
+ const companyId = currentTenantId != null
21
+ ? (_a = tenantState.tenantsById[currentTenantId]) === null || _a === void 0 ? void 0 : _a.companyId
22
+ : undefined;
23
+ const isCardsEnabled = companyId != null
24
+ ? companyState.companiesById[companyId].companyChargeCardInfo
25
+ .isChargeCardEnabled
26
+ : false;
17
27
  const queryPayload = {
18
28
  channel_type: 'phone',
19
29
  channel_info: {
20
30
  phone_number: phoneNumber,
21
31
  },
32
+ is_for_charge_cards: twoFASource === 'ChargeCard' ||
33
+ twoFASource === 'CardUserOnboarding' ||
34
+ (twoFASource === 'MyProfile' && isCardsEnabled),
22
35
  };
23
- if (twoFASource === 'ChargeCardHolder' && entityId != null) {
24
- const chargeCardProviderId = state$.value.chargeCardState.chargeCardByID[entityId].cardProviderID;
25
- queryPayload.provider_card_id = chargeCardProviderId;
26
- queryPayload.is_for_charge_cards = true;
27
- }
28
36
  switch (twoFASource) {
29
37
  case 'SpendManagementSetup':
30
38
  sendOtpActions.push((0, setupViewReducer_1.sendOtpSpendManagementSetUp)());
@@ -41,22 +49,13 @@ const sendOtpEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1
41
49
  case 'CardUserOnboarding':
42
50
  sendOtpActions.push((0, cardUserOnboardingReducer_1.sendOtpCardUserOnboarding)());
43
51
  break;
44
- case 'ChargeCardHolder':
45
- if (entityId != null) {
46
- sendOtpActions.push((0, chargeCardDetailReducer_1.sendOtpCardHolder)({ phone: phoneNumber, chargeCardId: entityId }));
47
- }
48
- break;
49
52
  }
50
53
  const setOtp$ = zeniAPI
51
54
  .postAndGetJSON(`${zeniAPI.apiEndPoints.authMicroServiceBaseUrl}/1.0/otp/send`, queryPayload)
52
55
  .pipe((0, operators_1.mergeMap)((response) => {
53
56
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
54
57
  const updateActions = [
55
- (0, twoFactorAuthenticationReducer_1.sendOtpSuccess)({
56
- otpChallenge: response.data.otp_challenge,
57
- twoFASource,
58
- entityId,
59
- }),
58
+ (0, twoFactorAuthenticationReducer_1.sendOtpSuccess)({ otpChallenge: response.data.otp_challenge }),
60
59
  ];
61
60
  switch (twoFASource) {
62
61
  case 'SpendManagementSetup':
@@ -84,20 +83,12 @@ const sendOtpEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1
84
83
  otpChallenge: response.data.otp_challenge,
85
84
  }));
86
85
  break;
87
- case 'ChargeCardHolder':
88
- if (entityId != null) {
89
- updateActions.push((0, chargeCardDetailReducer_1.sendOtpCardHolderSuccess)({
90
- otpChallenge: response.data.otp_challenge,
91
- chargeCardId: entityId,
92
- }));
93
- }
94
- break;
95
86
  }
96
87
  return (0, rxjs_1.from)(updateActions);
97
88
  }
98
89
  else {
99
90
  const updateActions = [
100
- (0, twoFactorAuthenticationReducer_1.sendOtpFailure)({ error: response.status, twoFASource, entityId }),
91
+ (0, twoFactorAuthenticationReducer_1.sendOtpFailure)(response.status),
101
92
  ];
102
93
  switch (twoFASource) {
103
94
  case 'SpendManagementSetup':
@@ -115,22 +106,12 @@ const sendOtpEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1
115
106
  case 'CardUserOnboarding':
116
107
  updateActions.push((0, cardUserOnboardingReducer_1.sendOtpCardUserOnboardingFailure)(response.status));
117
108
  break;
118
- case 'ChargeCardHolder':
119
- if (entityId != null) {
120
- updateActions.push((0, chargeCardDetailReducer_1.sendOtpCardHolderFailure)({
121
- error: response.status,
122
- chargeCardId: entityId,
123
- }));
124
- }
125
- break;
126
109
  }
127
110
  return (0, rxjs_1.from)(updateActions);
128
111
  }
129
112
  }), (0, operators_1.catchError)((error) => {
130
113
  const zeniAPIStatus = (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'Send otp api errored out' + JSON.stringify(error));
131
- const updateActions = [
132
- (0, twoFactorAuthenticationReducer_1.sendOtpFailure)({ error: zeniAPIStatus, twoFASource, entityId }),
133
- ];
114
+ const updateActions = [(0, twoFactorAuthenticationReducer_1.sendOtpFailure)(zeniAPIStatus)];
134
115
  switch (twoFASource) {
135
116
  case 'SpendManagementSetup':
136
117
  updateActions.push((0, setupViewReducer_1.sendOtpFailureSpendManagementSetUp)(zeniAPIStatus));
@@ -147,14 +128,6 @@ const sendOtpEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1
147
128
  case 'CardUserOnboarding':
148
129
  updateActions.push((0, cardUserOnboardingReducer_1.sendOtpCardUserOnboardingFailure)(zeniAPIStatus));
149
130
  break;
150
- case 'ChargeCardHolder':
151
- if (entityId != null) {
152
- updateActions.push((0, chargeCardDetailReducer_1.sendOtpCardHolderFailure)({
153
- error: zeniAPIStatus,
154
- chargeCardId: entityId,
155
- }));
156
- }
157
- break;
158
131
  }
159
132
  return (0, rxjs_1.from)(updateActions);
160
133
  }));
@@ -1,28 +1,16 @@
1
- import { FetchStateAndError, ID } from '../../commonStateTypes/common';
1
+ import { FetchStateAndError } from '../../commonStateTypes/common';
2
2
  import { ZeniDate } from '../../zeniDayJS';
3
- export interface TwoFactorAuthentication {
3
+ export interface TwoFactorAuthenticationState {
4
4
  sendOtpStatus: FetchStateAndError;
5
5
  otpVerificationStatus: FetchStateAndError;
6
- token?: Token;
6
+ customerToken?: CustomerToken;
7
7
  phone?: string;
8
8
  otpChallenge?: string;
9
9
  }
10
- export type TwoFactorAuthenticationWithoutToken = Omit<TwoFactorAuthentication, 'token'>;
11
- export declare const defaultTwoFactorAuthenticationState: TwoFactorAuthentication;
12
- export interface TwoFactorAuthenticationState {
13
- common: TwoFactorAuthentication;
14
- chargeCardHolder: Record<ID, TwoFactorAuthentication>;
15
- cardUserOnboarding: TwoFactorAuthenticationWithoutToken;
16
- }
17
- export declare const COMMON_TWO_FA_SOURCE: readonly ["BillPayVendor", "SpendManagementSetup", "MyProfile", "CustomerOnboarding"];
18
- export declare const toCommonTwoFASource: (v: string) => "MyProfile" | "BillPayVendor" | "SpendManagementSetup" | "CustomerOnboarding";
19
- export type CommonTwoFASource = ReturnType<typeof toCommonTwoFASource>;
20
- export type TwoFASourceView = CommonTwoFASource | 'ChargeCardHolder' | 'CardUserOnboarding';
21
- export interface Token {
10
+ export type TwoFASourceView = 'BillPayVendor' | 'ChargeCard' | 'SpendManagementSetup' | 'CardUserOnboarding' | 'MyProfile' | 'CustomerOnboarding';
11
+ export interface CustomerToken {
22
12
  provider: string;
23
13
  token: string;
24
14
  expiry: ZeniDate;
25
15
  message: string;
26
16
  }
27
- export declare const initialTwoFactorAuthenticationWithoutToken: TwoFactorAuthenticationWithoutToken;
28
- export declare const initialTwoFactorAuthentication: TwoFactorAuthentication;
@@ -1,35 +1,2 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.initialTwoFactorAuthentication = exports.initialTwoFactorAuthenticationWithoutToken = exports.toCommonTwoFASource = exports.COMMON_TWO_FA_SOURCE = exports.defaultTwoFactorAuthenticationState = void 0;
4
- const stringToUnion_1 = require("../../commonStateTypes/stringToUnion");
5
- exports.defaultTwoFactorAuthenticationState = {
6
- sendOtpStatus: {
7
- fetchState: 'Not-Started',
8
- error: undefined,
9
- },
10
- otpVerificationStatus: {
11
- fetchState: 'Not-Started',
12
- error: undefined,
13
- },
14
- };
15
- exports.COMMON_TWO_FA_SOURCE = [
16
- 'BillPayVendor',
17
- 'SpendManagementSetup',
18
- 'MyProfile',
19
- 'CustomerOnboarding',
20
- ];
21
- const toCommonTwoFASource = (v) => (0, stringToUnion_1.stringToUnion)(v, exports.COMMON_TWO_FA_SOURCE);
22
- exports.toCommonTwoFASource = toCommonTwoFASource;
23
- exports.initialTwoFactorAuthenticationWithoutToken = {
24
- sendOtpStatus: {
25
- fetchState: 'Not-Started',
26
- error: undefined,
27
- },
28
- otpVerificationStatus: {
29
- fetchState: 'Not-Started',
30
- error: undefined,
31
- },
32
- phone: undefined,
33
- otpChallenge: undefined,
34
- };
35
- exports.initialTwoFactorAuthentication = Object.assign(Object.assign({}, exports.initialTwoFactorAuthenticationWithoutToken), { token: undefined });
@@ -1,5 +1,5 @@
1
1
  import { ZeniAPIResponse } from '../../responsePayload';
2
- import { Token } from './twoFactorAuthentication';
2
+ import { CustomerToken } from './twoFactorAuthentication';
3
3
  interface SendOtpPayload {
4
4
  otp_challenge: string;
5
5
  }
@@ -7,14 +7,14 @@ export type SendOtpResponse = ZeniAPIResponse<SendOtpPayload>;
7
7
  interface VerifyOtpPayload {
8
8
  is_verified: boolean;
9
9
  message: string;
10
- token_info?: TokenPayload;
10
+ customer_token_info?: CustomerTokenPayload;
11
11
  }
12
- export interface TokenPayload {
13
- token_provider: string;
14
- token: string;
15
- token_expiration_time: string;
12
+ export interface CustomerTokenPayload {
13
+ customer_token_provider: string;
14
+ customer_token: string;
15
+ customer_token_expiration_time: string;
16
16
  message: string;
17
17
  }
18
18
  export type VerifyOtpResponse = ZeniAPIResponse<VerifyOtpPayload>;
19
- export declare const toToken: (payload: TokenPayload) => Token;
19
+ export declare const toCustomerToken: (payload: CustomerTokenPayload) => CustomerToken;
20
20
  export {};
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toToken = void 0;
3
+ exports.toCustomerToken = void 0;
4
4
  const zeniDayJS_1 = require("../../zeniDayJS");
5
- const toToken = (payload) => ({
6
- provider: payload.token_provider,
7
- token: payload.token,
8
- expiry: (0, zeniDayJS_1.date)(payload.token_expiration_time),
5
+ const toCustomerToken = (payload) => ({
6
+ provider: payload.customer_token_provider,
7
+ token: payload.customer_token,
8
+ expiry: (0, zeniDayJS_1.date)(payload.customer_token_expiration_time),
9
9
  message: payload.message,
10
10
  });
11
- exports.toToken = toToken;
11
+ exports.toCustomerToken = toCustomerToken;
@@ -1,37 +1,21 @@
1
- import { ID } from '../../commonStateTypes/common';
2
1
  import { ZeniAPIStatus } from '../../responsePayload';
3
2
  import { TwoFASourceView, TwoFactorAuthenticationState } from './twoFactorAuthentication';
4
- import { TokenPayload } from './twoFactorAuthenticationPayload';
3
+ import { CustomerTokenPayload } from './twoFactorAuthenticationPayload';
5
4
  export declare const initialState: TwoFactorAuthenticationState;
6
- export declare const sendOtp: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[phoneNumber: string, twoFASource: TwoFASourceView, entityId?: string | undefined], {
5
+ export declare const sendOtp: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[phoneNumber: string, twoFASource: TwoFASourceView], {
7
6
  phoneNumber: string;
8
7
  twoFASource: TwoFASourceView;
9
- entityId: string | undefined;
10
- }, "twoFactorAuthentication/sendOtp", never, never>, resendOtp: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[otpChallenge: string, twoFASource: TwoFASourceView, entityId?: string | undefined], {
8
+ }, "twoFactorAuthentication/sendOtp", never, never>, resendOtp: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[otpChallenge: string, twoFASource: TwoFASourceView], {
11
9
  otpChallenge: string;
12
10
  twoFASource: TwoFASourceView;
13
- entityId: string | undefined;
14
11
  }, "twoFactorAuthentication/resendOtp", never, never>, sendOtpSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
15
12
  otpChallenge: string;
16
- twoFASource: TwoFASourceView;
17
- entityId?: ID;
18
- }, "twoFactorAuthentication/sendOtpSuccess">, sendOtpFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
19
- error: ZeniAPIStatus;
20
- twoFASource: TwoFASourceView;
21
- entityId?: ID;
22
- }, "twoFactorAuthentication/sendOtpFailure">, verifyOtp: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[otpCode: string, otpChallenge: string, twoFASource: TwoFASourceView, entityId?: string | undefined], {
13
+ }, "twoFactorAuthentication/sendOtpSuccess">, sendOtpFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "twoFactorAuthentication/sendOtpFailure">, verifyOtp: import("@reduxjs/toolkit").ActionCreatorWithPreparedPayload<[otpCode: string, otpChallenge: string, twoFASource: TwoFASourceView], {
23
14
  otpCode: string;
24
15
  otpChallenge: string;
25
16
  twoFASource: TwoFASourceView;
26
- entityId: string | undefined;
27
17
  }, "twoFactorAuthentication/verifyOtp", never, never>, verifyOtpSuccess: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
28
- twoFASource: TwoFASourceView;
29
- tokenPayload: TokenPayload | undefined;
30
- entityId?: ID;
31
- }, "twoFactorAuthentication/verifyOtpSuccess">, verifyOtpFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<{
32
- error: ZeniAPIStatus;
33
- twoFASource: TwoFASourceView;
34
- entityId?: ID;
35
- }, "twoFactorAuthentication/verifyOtpFailure">, clearTwoFactorAuthentication: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"twoFactorAuthentication/clearTwoFactorAuthentication">;
18
+ customerTokenPayload: CustomerTokenPayload | undefined;
19
+ }, "twoFactorAuthentication/verifyOtpSuccess">, verifyOtpFailure: import("@reduxjs/toolkit").ActionCreatorWithPayload<ZeniAPIStatus<Record<string, unknown>>, "twoFactorAuthentication/verifyOtpFailure">, clearTwoFactorAuthentication: import("@reduxjs/toolkit").ActionCreatorWithoutPayload<"twoFactorAuthentication/clearTwoFactorAuthentication">;
36
20
  declare const _default: import("redux").Reducer<TwoFactorAuthenticationState>;
37
21
  export default _default;