@zeniai/client-epic-state 5.0.89 → 5.0.90-beta0ND

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 (78) hide show
  1. package/lib/commonStateTypes/animations.d.ts +1 -1
  2. package/lib/commonStateTypes/animations.js +1 -0
  3. package/lib/entity/company/companyPayload.d.ts +4 -0
  4. package/lib/entity/company/companyPayload.js +4 -0
  5. package/lib/entity/company/companyStateTypes.d.ts +4 -0
  6. package/lib/entity/paymentAccount/paymentAccountSelector.d.ts +1 -0
  7. package/lib/entity/paymentAccount/paymentAccountSelector.js +4 -0
  8. package/lib/entity/tenant/epic/deleteConnectionEpic.d.ts +1 -1
  9. package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.d.ts +21 -0
  10. package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.js +54 -0
  11. package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.d.ts +1 -1
  12. package/lib/entity/tenant/epic/saveConnectorCredentialsEpic.d.ts +3 -3
  13. package/lib/entity/tenant/epic/saveOAuthConnectionEpic.d.ts +1 -1
  14. package/lib/entity/tenant/tenantPayload.d.ts +1 -0
  15. package/lib/entity/tenant/tenantReducer.d.ts +38 -25
  16. package/lib/entity/tenant/tenantReducer.js +65 -5
  17. package/lib/entity/tenant/tenantState.d.ts +1 -0
  18. package/lib/epic.d.ts +8 -3
  19. package/lib/epic.js +9 -3
  20. package/lib/esm/commonStateTypes/animations.js +1 -0
  21. package/lib/esm/entity/company/companyPayload.js +4 -0
  22. package/lib/esm/entity/paymentAccount/paymentAccountSelector.js +3 -0
  23. package/lib/esm/entity/tenant/epic/initEmailConnectOAuthEpic.js +50 -0
  24. package/lib/esm/entity/tenant/tenantReducer.js +63 -3
  25. package/lib/esm/epic.js +9 -3
  26. package/lib/esm/index.js +9 -6
  27. package/lib/esm/view/expenseAutomationView/transactionFilterHelpers.js +106 -18
  28. package/lib/esm/view/fileView/epic/deleteFileEpic.js +2 -2
  29. package/lib/esm/view/fileView/epic/deleteFileListEpic.js +2 -2
  30. package/lib/esm/view/fileView/epic/updateFileNameEpic.js +2 -2
  31. package/lib/esm/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +42 -0
  32. package/lib/esm/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.js +29 -0
  33. package/lib/esm/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +40 -0
  34. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewReducer.js +217 -50
  35. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewSelector.js +7 -1
  36. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewState.js +12 -0
  37. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +52 -0
  38. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +59 -0
  39. package/lib/esm/view/spendManagement/commonSetup/kycKybAutofillActions.js +14 -0
  40. package/lib/esm/view/spendManagement/commonSetup/kycKybParseMapper.js +205 -0
  41. package/lib/esm/view/spendManagement/commonSetup/setupViewReducer.js +105 -52
  42. package/lib/esm/view/spendManagement/commonSetup/setupViewSelector.js +6 -1
  43. package/lib/esm/view/spendManagement/commonSetup/types/kycKybAutofill.js +28 -0
  44. package/lib/index.d.ts +11 -7
  45. package/lib/index.js +51 -31
  46. package/lib/view/expenseAutomationView/transactionFilterHelpers.js +106 -18
  47. package/lib/view/fileView/epic/deleteFileEpic.js +1 -1
  48. package/lib/view/fileView/epic/deleteFileListEpic.js +1 -1
  49. package/lib/view/fileView/epic/updateFileNameEpic.js +1 -1
  50. package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.d.ts +7 -0
  51. package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +46 -0
  52. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.d.ts +8 -0
  53. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.js +33 -0
  54. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.d.ts +9 -0
  55. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +44 -0
  56. package/lib/view/onboardingView/customerView/onboardingCustomerViewPayload.d.ts +3 -0
  57. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.d.ts +41 -4
  58. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.js +219 -51
  59. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.d.ts +5 -1
  60. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.js +11 -2
  61. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.d.ts +40 -0
  62. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.js +13 -1
  63. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.d.ts +28 -0
  64. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +56 -0
  65. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.d.ts +30 -0
  66. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +63 -0
  67. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.d.ts +33 -0
  68. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.js +17 -0
  69. package/lib/view/spendManagement/commonSetup/kycKybParseMapper.d.ts +24 -0
  70. package/lib/view/spendManagement/commonSetup/kycKybParseMapper.js +213 -0
  71. package/lib/view/spendManagement/commonSetup/setupViewReducer.d.ts +28 -2
  72. package/lib/view/spendManagement/commonSetup/setupViewReducer.js +106 -53
  73. package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +7 -2
  74. package/lib/view/spendManagement/commonSetup/setupViewSelector.js +6 -1
  75. package/lib/view/spendManagement/commonSetup/setupViewState.d.ts +19 -0
  76. package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.d.ts +125 -0
  77. package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.js +32 -0
  78. package/package.json +1 -1
@@ -1,5 +1,7 @@
1
1
  import { createSlice } from '@reduxjs/toolkit';
2
2
  import { date } from '../../../zeniDayJS';
3
+ import { parseUploadedKybDocument, parseUploadedKybDocumentFailure, parseUploadedKycDocument, parseUploadedKycDocumentFailure, } from '../../spendManagement/commonSetup/kycKybAutofillActions';
4
+ import { emptyAiAgentsActivationSubview, } from './onboardingCustomerViewState';
3
5
  const initialStatus = {
4
6
  fetchState: 'Not-Started',
5
7
  error: undefined,
@@ -9,61 +11,31 @@ export const initialState = {
9
11
  saveStatus: initialStatus,
10
12
  dashboardLoadedStatus: initialStatus,
11
13
  currentStep: 'link_payment_account',
14
+ parsingDocumentFileIds: [],
12
15
  companyDetails: {
16
+ autoFilledFields: [],
13
17
  localData: undefined,
14
18
  },
15
- companyOfficerUpdateStatus: {
16
- Officer_1: {
19
+ companyOfficerUpdateStatus: (() => {
20
+ const emptyOfficerSlot = {
21
+ autoFilledFields: [],
17
22
  localData: undefined,
18
23
  sendOtpStatus: initialStatus,
19
24
  otpverificationStatus: initialStatus,
20
- },
21
- Officer_2: {
22
- localData: undefined,
23
- sendOtpStatus: initialStatus,
24
- otpverificationStatus: initialStatus,
25
- },
26
- Officer_3: {
27
- localData: undefined,
28
- sendOtpStatus: initialStatus,
29
- otpverificationStatus: initialStatus,
30
- },
31
- Officer_4: {
32
- localData: undefined,
33
- sendOtpStatus: initialStatus,
34
- otpverificationStatus: initialStatus,
35
- },
36
- Officer_5: {
37
- localData: undefined,
38
- sendOtpStatus: initialStatus,
39
- otpverificationStatus: initialStatus,
40
- },
41
- Officer_6: {
42
- localData: undefined,
43
- sendOtpStatus: initialStatus,
44
- otpverificationStatus: initialStatus,
45
- },
46
- Officer_7: {
47
- localData: undefined,
48
- sendOtpStatus: initialStatus,
49
- otpverificationStatus: initialStatus,
50
- },
51
- Officer_8: {
52
- localData: undefined,
53
- sendOtpStatus: initialStatus,
54
- otpverificationStatus: initialStatus,
55
- },
56
- Officer_9: {
57
- localData: undefined,
58
- sendOtpStatus: initialStatus,
59
- otpverificationStatus: initialStatus,
60
- },
61
- Officer_10: {
62
- localData: undefined,
63
- sendOtpStatus: initialStatus,
64
- otpverificationStatus: initialStatus,
65
- },
66
- },
25
+ };
26
+ return {
27
+ Officer_1: { ...emptyOfficerSlot },
28
+ Officer_2: { ...emptyOfficerSlot },
29
+ Officer_3: { ...emptyOfficerSlot },
30
+ Officer_4: { ...emptyOfficerSlot },
31
+ Officer_5: { ...emptyOfficerSlot },
32
+ Officer_6: { ...emptyOfficerSlot },
33
+ Officer_7: { ...emptyOfficerSlot },
34
+ Officer_8: { ...emptyOfficerSlot },
35
+ Officer_9: { ...emptyOfficerSlot },
36
+ Officer_10: { ...emptyOfficerSlot },
37
+ };
38
+ })(),
67
39
  primaryContactDetails: {},
68
40
  paymentAccountDetails: {
69
41
  fetchStatus: initialStatus,
@@ -91,6 +63,7 @@ export const initialState = {
91
63
  },
92
64
  fetchState: 'Not-Started',
93
65
  error: undefined,
66
+ aiAgentsActivation: { ...emptyAiAgentsActivationSubview },
94
67
  uiState: {
95
68
  isQBOPopupOpen: false,
96
69
  isCardPaymentPopupOpen: false,
@@ -180,6 +153,126 @@ const onboardingCustomerView = createSlice({
180
153
  };
181
154
  },
182
155
  },
156
+ acknowledgeOnboardingAiFinanceTeam: {
157
+ reducer(draft) {
158
+ draft.aiFinanceTeamAcknowledgementStatus = {
159
+ fetchState: 'In-Progress',
160
+ error: undefined,
161
+ };
162
+ },
163
+ prepare(companyId) {
164
+ return {
165
+ payload: { companyId },
166
+ };
167
+ },
168
+ },
169
+ acknowledgeOnboardingAiFinanceTeamSuccess(draft) {
170
+ draft.aiFinanceTeamAcknowledgementStatus = {
171
+ fetchState: 'Completed',
172
+ error: undefined,
173
+ };
174
+ },
175
+ acknowledgeOnboardingAiFinanceTeamFailure: {
176
+ reducer(draft, action) {
177
+ draft.aiFinanceTeamAcknowledgementStatus = {
178
+ fetchState: 'Error',
179
+ error: action.payload,
180
+ };
181
+ },
182
+ prepare(error) {
183
+ return {
184
+ payload: error,
185
+ };
186
+ },
187
+ },
188
+ acknowledgeOnboardingAiActivationViewed: {
189
+ reducer(draft) {
190
+ draft.aiActivationViewedAcknowledgementStatus = {
191
+ fetchState: 'In-Progress',
192
+ error: undefined,
193
+ };
194
+ },
195
+ prepare(companyId) {
196
+ return {
197
+ payload: { companyId },
198
+ };
199
+ },
200
+ },
201
+ acknowledgeOnboardingAiActivationViewedSuccess(draft) {
202
+ draft.aiActivationViewedAcknowledgementStatus = {
203
+ fetchState: 'Completed',
204
+ error: undefined,
205
+ };
206
+ },
207
+ acknowledgeOnboardingAiActivationViewedFailure: {
208
+ reducer(draft, action) {
209
+ draft.aiActivationViewedAcknowledgementStatus = {
210
+ fetchState: 'Error',
211
+ error: action.payload,
212
+ };
213
+ },
214
+ prepare(error) {
215
+ return {
216
+ payload: error,
217
+ };
218
+ },
219
+ },
220
+ fetchAiAgentsActivationStatus(draft) {
221
+ draft.aiAgentsActivation.fetchStatus = {
222
+ fetchState: 'In-Progress',
223
+ error: undefined,
224
+ };
225
+ },
226
+ fetchAiAgentsActivationStatusSuccess: {
227
+ reducer(draft, action) {
228
+ draft.aiAgentsActivation.fetchStatus = {
229
+ fetchState: 'Completed',
230
+ error: undefined,
231
+ };
232
+ draft.aiAgentsActivation.phases = action.payload.phases;
233
+ draft.aiAgentsActivation.counts = action.payload.counts;
234
+ },
235
+ prepare(payload) {
236
+ return { payload };
237
+ },
238
+ },
239
+ fetchAiAgentsActivationStatusFailure: {
240
+ reducer(draft, action) {
241
+ draft.aiAgentsActivation.fetchStatus = {
242
+ fetchState: 'Error',
243
+ error: action.payload,
244
+ };
245
+ },
246
+ prepare(error) {
247
+ return { payload: error };
248
+ },
249
+ },
250
+ aiAgentsActivationCountsUpdated: {
251
+ reducer(draft, action) {
252
+ draft.aiAgentsActivation.counts = {
253
+ ...draft.aiAgentsActivation.counts,
254
+ ...action.payload,
255
+ };
256
+ },
257
+ prepare(payload) {
258
+ return { payload };
259
+ },
260
+ },
261
+ aiAgentsActivationPhaseChanged: {
262
+ reducer(draft, action) {
263
+ const target = draft.aiAgentsActivation.phases;
264
+ const index = target.findIndex((phase) => phase.key === action.payload.key);
265
+ if (index === -1) {
266
+ target.push(action.payload);
267
+ }
268
+ else {
269
+ target[index] = { ...target[index], ...action.payload };
270
+ }
271
+ },
272
+ prepare(payload) {
273
+ return { payload };
274
+ },
275
+ },
183
276
  updateOnboardingCustomerViewDashboardLoaded: {
184
277
  reducer(draft) {
185
278
  draft.dashboardLoadedStatus = {
@@ -592,7 +685,81 @@ const onboardingCustomerView = createSlice({
592
685
  clearOnboardingCustomerView(draft) {
593
686
  Object.assign(draft, initialState);
594
687
  },
688
+ /** Merge AI-parsed officer fields into the officer's onboarding localData. */
689
+ applyKycDocumentAutofillForOnboarding: {
690
+ reducer(draft, action) {
691
+ const { officerType, values, autoFilledFieldNames, fileId } = action.payload;
692
+ const slot = draft.companyOfficerUpdateStatus[officerType];
693
+ slot.localData = Object.assign({}, slot.localData, values);
694
+ slot.autoFilledFields = Array.from(new Set([...slot.autoFilledFields, ...autoFilledFieldNames]));
695
+ draft.parsingDocumentFileIds = draft.parsingDocumentFileIds.filter((id) => id !== fileId);
696
+ },
697
+ prepare(payload) {
698
+ return { payload };
699
+ },
700
+ },
701
+ /** Merge AI-parsed company fields into companyDetails onboarding localData. */
702
+ applyKybDocumentAutofillForOnboarding: {
703
+ reducer(draft, action) {
704
+ const { values, autoFilledFieldNames, fileId } = action.payload;
705
+ draft.companyDetails.localData = Object.assign({}, draft.companyDetails.localData, values);
706
+ const prev = draft.companyDetails.autoFilledFields ?? [];
707
+ draft.companyDetails.autoFilledFields = Array.from(new Set([...prev, ...autoFilledFieldNames]));
708
+ draft.parsingDocumentFileIds = draft.parsingDocumentFileIds.filter((id) => id !== fileId);
709
+ },
710
+ prepare(payload) {
711
+ return { payload };
712
+ },
713
+ },
714
+ /** Wipe AI-autofill badges during onboarding. */
715
+ clearKycKybAutofillForOnboarding: {
716
+ reducer(draft, action) {
717
+ const { officerType } = action.payload;
718
+ if (officerType != null) {
719
+ draft.companyOfficerUpdateStatus[officerType].autoFilledFields = [];
720
+ }
721
+ else {
722
+ draft.companyDetails.autoFilledFields = [];
723
+ Object.keys(draft.companyOfficerUpdateStatus).forEach((key) => {
724
+ draft.companyOfficerUpdateStatus[key].autoFilledFields = [];
725
+ });
726
+ }
727
+ },
728
+ prepare(payload = {}) {
729
+ return { payload };
730
+ },
731
+ },
732
+ },
733
+ extraReducers: (builder) => {
734
+ const addParsingFileId = (draft, fileId) => {
735
+ if (!draft.parsingDocumentFileIds.includes(fileId)) {
736
+ draft.parsingDocumentFileIds.push(fileId);
737
+ }
738
+ };
739
+ const removeParsingFileId = (draft, fileId) => {
740
+ draft.parsingDocumentFileIds = draft.parsingDocumentFileIds.filter((id) => id !== fileId);
741
+ };
742
+ builder.addCase(parseUploadedKycDocument, (draft, action) => {
743
+ if (action.payload.target === 'onboarding') {
744
+ addParsingFileId(draft, action.payload.fileId);
745
+ }
746
+ });
747
+ builder.addCase(parseUploadedKybDocument, (draft, action) => {
748
+ if (action.payload.target === 'onboarding') {
749
+ addParsingFileId(draft, action.payload.fileId);
750
+ }
751
+ });
752
+ builder.addCase(parseUploadedKycDocumentFailure, (draft, action) => {
753
+ if (action.payload.target === 'onboarding') {
754
+ removeParsingFileId(draft, action.payload.fileId);
755
+ }
756
+ });
757
+ builder.addCase(parseUploadedKybDocumentFailure, (draft, action) => {
758
+ if (action.payload.target === 'onboarding') {
759
+ removeParsingFileId(draft, action.payload.fileId);
760
+ }
761
+ });
595
762
  },
596
763
  });
597
- export const { fetchOnboardingCustomerView, fetchOnboardingCustomerSetupView, fetchOnboardingCustomerSetupViewSuccess, fetchOnboardingCustomerSetupViewFailure, updateOnboardingCustomerViewCompleteStatus, updateOnboardingCustomerViewCompleteStatusSuccess, updateOnboardingCustomerViewCompleteStatusFailure, updateOnboardingCustomerViewDashboardLoaded, updateOnboardingCustomerViewDashboardLoadedSuccess, updateOnboardingCustomerViewDashboardLoadedFailure, updateOnboardingCustomerView, updateOnboardingCustomerViewSuccess, updateOnboardingCustomerViewFailure, updateOnboardingPaymentAccountStatus, updateOnboardingPaymentAccountStatusSuccess, updateOnboardingPaymentAccountStatusFailure, updateOnboardingPaymentAccountLoginStatus, updateOnboardingPaymentAccountLoginStatusSuccess, updateOnboardingPaymentAccountLoginStatusFailure, establishOnboardingPlaidConnection, establishOnboardingPlaidConnectionSuccess, establishOnboardingPlaidConnectionFailure, getOnboardingPlaidLinkToken, getOnboardingPlaidLinkTokenSuccess, getOnboardingPlaidLinkTokenFailure, updateCurrentStep, updateOnboardingCustomerViewAccountDetails, updateOnboardingCustomerViewLocalStoreData, saveOnboardingCustomerViewDataInLocalStore, saveOnboardingCompnayOfficerPhoneInLocalStore, updateOnboardingCustomerViewUIState, sendOnboardingOfficerOtp, sendOnboardingOfficerOtpSuccess, sendOnboardingOfficerOtpFailure, resendOnboardingOfficerOtp, verifyOnboardingOfficerOtp, verifyOnboardingOfficerOtpSuccess, verifyOnboardingOfficerOtpFailure, clearOnboardingCustomerViewDataInLocalStore, clearOnboardingCustomerView, } = onboardingCustomerView.actions;
764
+ export const { fetchOnboardingCustomerView, fetchOnboardingCustomerSetupView, fetchOnboardingCustomerSetupViewSuccess, fetchOnboardingCustomerSetupViewFailure, updateOnboardingCustomerViewCompleteStatus, updateOnboardingCustomerViewCompleteStatusSuccess, updateOnboardingCustomerViewCompleteStatusFailure, acknowledgeOnboardingAiFinanceTeam, acknowledgeOnboardingAiFinanceTeamSuccess, acknowledgeOnboardingAiFinanceTeamFailure, acknowledgeOnboardingAiActivationViewed, acknowledgeOnboardingAiActivationViewedSuccess, acknowledgeOnboardingAiActivationViewedFailure, fetchAiAgentsActivationStatus, fetchAiAgentsActivationStatusSuccess, fetchAiAgentsActivationStatusFailure, aiAgentsActivationCountsUpdated, aiAgentsActivationPhaseChanged, updateOnboardingCustomerViewDashboardLoaded, updateOnboardingCustomerViewDashboardLoadedSuccess, updateOnboardingCustomerViewDashboardLoadedFailure, updateOnboardingCustomerView, updateOnboardingCustomerViewSuccess, updateOnboardingCustomerViewFailure, updateOnboardingPaymentAccountStatus, updateOnboardingPaymentAccountStatusSuccess, updateOnboardingPaymentAccountStatusFailure, updateOnboardingPaymentAccountLoginStatus, updateOnboardingPaymentAccountLoginStatusSuccess, updateOnboardingPaymentAccountLoginStatusFailure, establishOnboardingPlaidConnection, establishOnboardingPlaidConnectionSuccess, establishOnboardingPlaidConnectionFailure, getOnboardingPlaidLinkToken, getOnboardingPlaidLinkTokenSuccess, getOnboardingPlaidLinkTokenFailure, updateCurrentStep, updateOnboardingCustomerViewAccountDetails, updateOnboardingCustomerViewLocalStoreData, saveOnboardingCustomerViewDataInLocalStore, saveOnboardingCompnayOfficerPhoneInLocalStore, updateOnboardingCustomerViewUIState, sendOnboardingOfficerOtp, sendOnboardingOfficerOtpSuccess, sendOnboardingOfficerOtpFailure, resendOnboardingOfficerOtp, verifyOnboardingOfficerOtp, verifyOnboardingOfficerOtpSuccess, verifyOnboardingOfficerOtpFailure, clearOnboardingCustomerViewDataInLocalStore, clearOnboardingCustomerView, applyKycDocumentAutofillForOnboarding, applyKybDocumentAutofillForOnboarding, clearKycKybAutofillForOnboarding, } = onboardingCustomerView.actions;
598
765
  export default onboardingCustomerView.reducer;
@@ -11,7 +11,7 @@ import { getCompanyAndIdentityDetails, } from '../../spendManagement/commonSetup
11
11
  import { ALL_ONBOARDING_STEPS, ALL_ZENI_USER_ONBOARDING_STEPS, REQUIRED_ONBOARDING_STEPS, ZENI_USER_REQUIRED_ONBOARDING_STEPS, toOnboardingStepType, } from './onboardingCustomerViewState';
12
12
  export function getOnboardingCustomerView(state, companyId) {
13
13
  const { fileState, paymentAccountState, onboardingCustomerViewState, userState, userRoleState, subscriptionPaymentAccountState, companyConfigState, cardPaymentViewState, countryListState, addressViewState, } = state;
14
- const { companyDetails, companyOfficerUpdateStatus, primaryContactDetails, subscriptionPaymentAccountIds, paymentAccountDetails, plaidConnectionDetails, updateStatus, saveStatus, currentStep, uiState, fetchState, error, } = onboardingCustomerViewState;
14
+ const { companyDetails, companyOfficerUpdateStatus, primaryContactDetails, subscriptionPaymentAccountIds, paymentAccountDetails, plaidConnectionDetails, parsingDocumentFileIds, updateStatus, saveStatus, currentStep, uiState, fetchState, error, } = onboardingCustomerViewState;
15
15
  const { paymentAccountIds } = paymentAccountDetails;
16
16
  let subscriptionPaymentAccount;
17
17
  let paymentAccount;
@@ -54,6 +54,7 @@ export function getOnboardingCustomerView(state, companyId) {
54
54
  companyDetails,
55
55
  companyOfficerUpdateStatus,
56
56
  primaryContactDetails,
57
+ parsingDocumentFileIds,
57
58
  });
58
59
  const companyAddress = addressViewState.newAddressState?.company_address;
59
60
  if (companyAddress == null &&
@@ -119,6 +120,7 @@ export function getOnboardingCustomerView(state, companyId) {
119
120
  return {
120
121
  companyDetailsLocalData,
121
122
  companyOfficerLocalData,
123
+ parsingDocumentFileIds,
122
124
  subscriptionBillingAddress: subscriptionBillingAddress?.addressToCreate,
123
125
  companyView,
124
126
  allNationalityCountries,
@@ -323,3 +325,7 @@ export const getProductSettingsString = (productSettings) => {
323
325
  .map((key) => productKeyMap[key])
324
326
  .join(',');
325
327
  };
328
+ const fromActivationView = (state) => state.onboardingCustomerViewState.aiAgentsActivation;
329
+ export const getAiAgentsActivationSubview = (state) => fromActivationView(state);
330
+ export const getAiAgentsActivationPhases = (state) => fromActivationView(state).phases;
331
+ export const getAiAgentsActivationCounts = (state) => fromActivationView(state).counts;
@@ -26,3 +26,15 @@ export const ALL_ONBOARDING_STEPS = [
26
26
  ...ALL_ZENI_USER_ONBOARDING_STEPS_WITHOUT_ACCOUNT,
27
27
  ];
28
28
  export const toOnboardingStepType = (v) => stringToUnion(v, ALL_ONBOARDING_STEPS);
29
+ export const emptyAiAgentsActivationCounts = {
30
+ customerCount: 0,
31
+ glAccountCount: 0,
32
+ targetTransactionCount: 0,
33
+ transactionCount: 0,
34
+ vendorCount: 0,
35
+ };
36
+ export const emptyAiAgentsActivationSubview = {
37
+ counts: emptyAiAgentsActivationCounts,
38
+ fetchStatus: { fetchState: 'Not-Started', error: undefined },
39
+ phases: [],
40
+ };
@@ -0,0 +1,52 @@
1
+ import { of } from 'rxjs';
2
+ import { catchError, filter, mergeMap } from 'rxjs/operators';
3
+ import { isSuccessResponse } from '../../../../../responsePayload';
4
+ import { applyKybDocumentAutofillForOnboarding } from '../../../../onboardingView/customerView/onboardingCustomerViewReducer';
5
+ import { parseUploadedKybDocument, parseUploadedKybDocumentFailure, } from '../../kycKybAutofillActions';
6
+ import { mapCoiToCompanyDetails, mapTaxEinToCompanyDetails, } from '../../kycKybParseMapper';
7
+ import { applyKybDocumentAutofillForSetup } from '../../setupViewReducer';
8
+ const PROCESS_DOCUMENT_SYNC_PATH = '/1.0/documents/process/sync';
9
+ export const parseUploadedKybDocumentEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(parseUploadedKybDocument.match), mergeMap((action) => {
10
+ const { target, companyId, fileId, documentType } = action.payload;
11
+ const url = `${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}${PROCESS_DOCUMENT_SYNC_PATH}`;
12
+ const requestPayload = {
13
+ provided_document_type: documentType,
14
+ files: [{ file_id: fileId }],
15
+ processing_priority: 10,
16
+ metadata: { source: 'kyc_kyb_autofill' },
17
+ };
18
+ const failureAction = parseUploadedKybDocumentFailure({ target, fileId });
19
+ return zeniAPI
20
+ .postAndGetJSON(url, requestPayload)
21
+ .pipe(mergeMap((response) => {
22
+ if (!isSuccessResponse(response) || response.data == null) {
23
+ return of(failureAction);
24
+ }
25
+ let result;
26
+ switch (documentType) {
27
+ case 'certificate_of_incorporation':
28
+ result = mapCoiToCompanyDetails(response.data);
29
+ break;
30
+ case 'tax_ein':
31
+ result = mapTaxEinToCompanyDetails(response.data);
32
+ break;
33
+ }
34
+ if (result.autoFilledFieldNames.length === 0) {
35
+ return of(failureAction);
36
+ }
37
+ const applyAction = target === 'setup'
38
+ ? applyKybDocumentAutofillForSetup({
39
+ companyId,
40
+ fileId,
41
+ values: result.values,
42
+ autoFilledFieldNames: result.autoFilledFieldNames,
43
+ })
44
+ : applyKybDocumentAutofillForOnboarding({
45
+ companyId,
46
+ fileId,
47
+ values: result.values,
48
+ autoFilledFieldNames: result.autoFilledFieldNames,
49
+ });
50
+ return of(applyAction);
51
+ }), catchError(() => of(failureAction)));
52
+ }));
@@ -0,0 +1,59 @@
1
+ import { of } from 'rxjs';
2
+ import { catchError, filter, mergeMap } from 'rxjs/operators';
3
+ import { getCountryList } from '../../../../../entity/countryList/countryListSelector';
4
+ import { isSuccessResponse } from '../../../../../responsePayload';
5
+ import { applyKycDocumentAutofillForOnboarding } from '../../../../onboardingView/customerView/onboardingCustomerViewReducer';
6
+ import { parseUploadedKycDocument, parseUploadedKycDocumentFailure, } from '../../kycKybAutofillActions';
7
+ import { mapDrivingLicenseToOfficer, mapPassportToOfficer, mapSsnCardToOfficer, } from '../../kycKybParseMapper';
8
+ import { applyKycDocumentAutofillForSetup } from '../../setupViewReducer';
9
+ const PROCESS_DOCUMENT_SYNC_PATH = '/1.0/documents/process/sync';
10
+ export const parseUploadedKycDocumentEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(parseUploadedKycDocument.match), mergeMap((action) => {
11
+ const { target, companyId, officerType, fileId, documentType } = action.payload;
12
+ const url = `${zeniAPI.apiEndPoints.communicationAgentMicroServiceBaseUrl}${PROCESS_DOCUMENT_SYNC_PATH}`;
13
+ const requestPayload = {
14
+ provided_document_type: documentType,
15
+ files: [{ file_id: fileId }],
16
+ processing_priority: 10,
17
+ metadata: { source: 'kyc_kyb_autofill' },
18
+ };
19
+ const failureAction = parseUploadedKycDocumentFailure({ target, fileId });
20
+ return zeniAPI
21
+ .postAndGetJSON(url, requestPayload)
22
+ .pipe(mergeMap((response) => {
23
+ if (!isSuccessResponse(response) || response.data == null) {
24
+ return of(failureAction);
25
+ }
26
+ const allCountries = getCountryList(state$.value.countryListState, 'nationalityCountryList').countries;
27
+ let result;
28
+ switch (documentType) {
29
+ case 'passport':
30
+ result = mapPassportToOfficer(response.data, allCountries);
31
+ break;
32
+ case 'driving_license':
33
+ result = mapDrivingLicenseToOfficer(response.data);
34
+ break;
35
+ case 'social_security_card':
36
+ result = mapSsnCardToOfficer(response.data);
37
+ break;
38
+ }
39
+ if (result.autoFilledFieldNames.length === 0) {
40
+ return of(failureAction);
41
+ }
42
+ const applyAction = target === 'setup'
43
+ ? applyKycDocumentAutofillForSetup({
44
+ companyId,
45
+ officerType,
46
+ fileId,
47
+ values: result.values,
48
+ autoFilledFieldNames: result.autoFilledFieldNames,
49
+ })
50
+ : applyKycDocumentAutofillForOnboarding({
51
+ companyId,
52
+ officerType,
53
+ fileId,
54
+ values: result.values,
55
+ autoFilledFieldNames: result.autoFilledFieldNames,
56
+ });
57
+ return of(applyAction);
58
+ }), catchError(() => of(failureAction)));
59
+ }));
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Trigger actions for the KYC / KYB autofill epics.
3
+ *
4
+ * These actions don't mutate state — the epic listens for them, calls
5
+ * document-communication-agent's sync endpoint, and dispatches the appropriate
6
+ * `applyKyc/KybDocumentAutofillFor{Setup,Onboarding}` against the matching
7
+ * slice. Co-located with the rest of the commonSetup module because the entire
8
+ * autofill flow is auxiliary to the setup view; there is no separate state.
9
+ */
10
+ import { createAction } from '@reduxjs/toolkit';
11
+ export const parseUploadedKycDocument = createAction('commonSetup/parseUploadedKycDocument');
12
+ export const parseUploadedKybDocument = createAction('commonSetup/parseUploadedKybDocument');
13
+ export const parseUploadedKycDocumentFailure = createAction('commonSetup/parseUploadedKycDocumentFailure');
14
+ export const parseUploadedKybDocumentFailure = createAction('commonSetup/parseUploadedKybDocumentFailure');