@zeniai/client-epic-state 5.1.3 → 5.1.4-beta1ND
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.
- package/lib/entity/company/companyPayload.d.ts +4 -0
- package/lib/entity/company/companyPayload.js +6 -0
- package/lib/entity/company/companyStateTypes.d.ts +7 -0
- package/lib/entity/paymentAccount/paymentAccountSelector.d.ts +1 -0
- package/lib/entity/paymentAccount/paymentAccountSelector.js +9 -0
- package/lib/entity/tenant/epic/deleteConnectionEpic.d.ts +1 -1
- package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.d.ts +21 -0
- package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.js +54 -0
- package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.d.ts +1 -1
- package/lib/entity/tenant/epic/saveConnectorCredentialsEpic.d.ts +3 -3
- package/lib/entity/tenant/epic/saveOAuthConnectionEpic.d.ts +1 -1
- package/lib/entity/tenant/tenantPayload.d.ts +1 -0
- package/lib/entity/tenant/tenantReducer.d.ts +38 -25
- package/lib/entity/tenant/tenantReducer.js +65 -5
- package/lib/entity/tenant/tenantState.d.ts +1 -0
- package/lib/epic.d.ts +6 -1
- package/lib/epic.js +7 -1
- package/lib/esm/entity/company/companyPayload.js +6 -0
- package/lib/esm/entity/paymentAccount/paymentAccountSelector.js +8 -0
- package/lib/esm/entity/tenant/epic/initEmailConnectOAuthEpic.js +50 -0
- package/lib/esm/entity/tenant/tenantReducer.js +63 -3
- package/lib/esm/epic.js +7 -1
- package/lib/esm/index.js +9 -6
- package/lib/esm/view/fileView/epic/deleteFileEpic.js +2 -2
- package/lib/esm/view/fileView/epic/deleteFileListEpic.js +2 -2
- package/lib/esm/view/fileView/epic/updateFileNameEpic.js +2 -2
- package/lib/esm/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +40 -0
- package/lib/esm/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.js +29 -0
- package/lib/esm/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +40 -0
- package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewReducer.js +218 -50
- package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewSelector.js +12 -2
- package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewState.js +12 -0
- package/lib/esm/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowPayload.js +2 -2
- package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +58 -0
- package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +77 -0
- package/lib/esm/view/spendManagement/commonSetup/kycKybAutofillActions.js +14 -0
- package/lib/esm/view/spendManagement/commonSetup/kycKybParseMapper.js +207 -0
- package/lib/esm/view/spendManagement/commonSetup/setupViewReducer.js +106 -52
- package/lib/esm/view/spendManagement/commonSetup/setupViewSelector.js +6 -1
- package/lib/esm/view/spendManagement/commonSetup/types/kycKybAutofill.js +41 -0
- package/lib/index.d.ts +13 -9
- package/lib/index.js +55 -35
- package/lib/view/fileView/epic/deleteFileEpic.js +1 -1
- package/lib/view/fileView/epic/deleteFileListEpic.js +1 -1
- package/lib/view/fileView/epic/updateFileNameEpic.js +1 -1
- package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.d.ts +7 -0
- package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +44 -0
- package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.d.ts +8 -0
- package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.js +33 -0
- package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.d.ts +9 -0
- package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +44 -0
- package/lib/view/onboardingView/customerView/onboardingCustomerViewPayload.d.ts +3 -0
- package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.d.ts +41 -4
- package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.js +220 -51
- package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.d.ts +5 -1
- package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.js +15 -2
- package/lib/view/onboardingView/customerView/onboardingCustomerViewState.d.ts +40 -0
- package/lib/view/onboardingView/customerView/onboardingCustomerViewState.js +13 -1
- package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowPayload.d.ts +1 -1
- package/lib/view/spendManagement/cashManagement/autoSweepFlow/autoSweepFlowPayload.js +2 -2
- package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.d.ts +28 -0
- package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +62 -0
- package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.d.ts +9 -0
- package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +81 -0
- package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.d.ts +24 -0
- package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.js +17 -0
- package/lib/view/spendManagement/commonSetup/kycKybParseMapper.d.ts +29 -0
- package/lib/view/spendManagement/commonSetup/kycKybParseMapper.js +215 -0
- package/lib/view/spendManagement/commonSetup/setupViewReducer.d.ts +28 -2
- package/lib/view/spendManagement/commonSetup/setupViewReducer.js +107 -53
- package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +7 -2
- package/lib/view/spendManagement/commonSetup/setupViewSelector.js +6 -1
- package/lib/view/spendManagement/commonSetup/setupViewState.d.ts +19 -0
- package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.d.ts +154 -0
- package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.js +46 -0
- 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
|
-
|
|
19
|
+
companyOfficerUpdateStatus: (() => {
|
|
20
|
+
const emptyOfficerSlot = {
|
|
21
|
+
autoFilledFields: [],
|
|
17
22
|
localData: undefined,
|
|
18
23
|
sendOtpStatus: initialStatus,
|
|
19
24
|
otpverificationStatus: initialStatus,
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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,82 @@ 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
|
+
draft.parsingDocumentFileIds = draft.parsingDocumentFileIds ?? [];
|
|
736
|
+
if (!draft.parsingDocumentFileIds.includes(fileId)) {
|
|
737
|
+
draft.parsingDocumentFileIds.push(fileId);
|
|
738
|
+
}
|
|
739
|
+
};
|
|
740
|
+
const removeParsingFileId = (draft, fileId) => {
|
|
741
|
+
draft.parsingDocumentFileIds = (draft.parsingDocumentFileIds ?? []).filter((id) => id !== fileId);
|
|
742
|
+
};
|
|
743
|
+
builder.addCase(parseUploadedKycDocument, (draft, action) => {
|
|
744
|
+
if (action.payload.target === 'onboarding') {
|
|
745
|
+
addParsingFileId(draft, action.payload.fileId);
|
|
746
|
+
}
|
|
747
|
+
});
|
|
748
|
+
builder.addCase(parseUploadedKybDocument, (draft, action) => {
|
|
749
|
+
if (action.payload.target === 'onboarding') {
|
|
750
|
+
addParsingFileId(draft, action.payload.fileId);
|
|
751
|
+
}
|
|
752
|
+
});
|
|
753
|
+
builder.addCase(parseUploadedKycDocumentFailure, (draft, action) => {
|
|
754
|
+
if (action.payload.target === 'onboarding') {
|
|
755
|
+
removeParsingFileId(draft, action.payload.fileId);
|
|
756
|
+
}
|
|
757
|
+
});
|
|
758
|
+
builder.addCase(parseUploadedKybDocumentFailure, (draft, action) => {
|
|
759
|
+
if (action.payload.target === 'onboarding') {
|
|
760
|
+
removeParsingFileId(draft, action.payload.fileId);
|
|
761
|
+
}
|
|
762
|
+
});
|
|
595
763
|
},
|
|
596
764
|
});
|
|
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;
|
|
765
|
+
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
766
|
export default onboardingCustomerView.reducer;
|
|
@@ -8,10 +8,10 @@ import { getUserRoleByUserIds } from '../../../entity/userRole/userRoleSelector'
|
|
|
8
8
|
import { getCompanyConfig } from '../../companyConfigView/companyConfigSelector';
|
|
9
9
|
import { getCompanyView } from '../../companyView/selectorHelpers/getCompanyView';
|
|
10
10
|
import { getCompanyAndIdentityDetails, } from '../../spendManagement/commonSetup/setupViewSelector';
|
|
11
|
-
import { ALL_ONBOARDING_STEPS, ALL_ZENI_USER_ONBOARDING_STEPS, REQUIRED_ONBOARDING_STEPS, ZENI_USER_REQUIRED_ONBOARDING_STEPS, toOnboardingStepType, } from './onboardingCustomerViewState';
|
|
11
|
+
import { ALL_ONBOARDING_STEPS, ALL_ZENI_USER_ONBOARDING_STEPS, REQUIRED_ONBOARDING_STEPS, ZENI_USER_REQUIRED_ONBOARDING_STEPS, emptyAiAgentsActivationSubview, 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,11 @@ export const getProductSettingsString = (productSettings) => {
|
|
|
323
325
|
.map((key) => productKeyMap[key])
|
|
324
326
|
.join(',');
|
|
325
327
|
};
|
|
328
|
+
const fromActivationView = (state) =>
|
|
329
|
+
// Fall back to the empty subview so state hydrated from an older persisted
|
|
330
|
+
// version (before aiAgentsActivation existed) doesn't crash on .phases/.counts.
|
|
331
|
+
state.onboardingCustomerViewState.aiAgentsActivation ??
|
|
332
|
+
emptyAiAgentsActivationSubview;
|
|
333
|
+
export const getAiAgentsActivationSubview = (state) => fromActivationView(state);
|
|
334
|
+
export const getAiAgentsActivationPhases = (state) => fromActivationView(state).phases;
|
|
335
|
+
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
|
+
};
|
|
@@ -20,8 +20,8 @@ export const toAutoSweepFlowStatePatch = (payload) => {
|
|
|
20
20
|
return {
|
|
21
21
|
bufferAmount: toAmount(payload.minimum_buffer_usd, currencyCode ?? 'USD', currencySymbol ?? '$'),
|
|
22
22
|
frequency: toAutoSweepFrequency(payload.frequency) ?? 'weekly',
|
|
23
|
-
nextTransferDate: payload.
|
|
24
|
-
? date(payload.
|
|
23
|
+
nextTransferDate: payload.next_run_date != null && payload.next_run_date !== ''
|
|
24
|
+
? date(payload.next_run_date)
|
|
25
25
|
: undefined,
|
|
26
26
|
primaryFundingAccountId: payload.source_bank_account.deposit_account_id ?? undefined,
|
|
27
27
|
settingsId: payload.cash_management_settings_id ?? undefined,
|
|
@@ -0,0 +1,58 @@
|
|
|
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
|
+
// Sync API returns a batch envelope: `data.files[0].extracted_data`
|
|
26
|
+
// is the parser payload; `data` itself is the request-level wrapper.
|
|
27
|
+
const extracted = response.data.files?.[0]?.extracted_data;
|
|
28
|
+
if (extracted == null) {
|
|
29
|
+
return of(failureAction);
|
|
30
|
+
}
|
|
31
|
+
let result;
|
|
32
|
+
switch (documentType) {
|
|
33
|
+
case 'certificate_of_incorporation':
|
|
34
|
+
result = mapCoiToCompanyDetails(extracted);
|
|
35
|
+
break;
|
|
36
|
+
case 'tax_ein':
|
|
37
|
+
result = mapTaxEinToCompanyDetails(extracted);
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
if (result.autoFilledFieldNames.length === 0) {
|
|
41
|
+
return of(failureAction);
|
|
42
|
+
}
|
|
43
|
+
const applyAction = target === 'setup'
|
|
44
|
+
? applyKybDocumentAutofillForSetup({
|
|
45
|
+
companyId,
|
|
46
|
+
fileId,
|
|
47
|
+
values: result.values,
|
|
48
|
+
autoFilledFieldNames: result.autoFilledFieldNames,
|
|
49
|
+
})
|
|
50
|
+
: applyKybDocumentAutofillForOnboarding({
|
|
51
|
+
companyId,
|
|
52
|
+
fileId,
|
|
53
|
+
values: result.values,
|
|
54
|
+
autoFilledFieldNames: result.autoFilledFieldNames,
|
|
55
|
+
});
|
|
56
|
+
return of(applyAction);
|
|
57
|
+
}), catchError(() => of(failureAction)));
|
|
58
|
+
}));
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { from, of } from 'rxjs';
|
|
2
|
+
import { catchError, filter, mergeMap } from 'rxjs/operators';
|
|
3
|
+
import { isSuccessResponse } from '../../../../../responsePayload';
|
|
4
|
+
import { newAddressInLocalStore } from '../../../../addressView/addressViewReducer';
|
|
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
|
+
// Sync API returns a batch envelope: `data.files[0].extracted_data`
|
|
27
|
+
// is the parser payload; `data` itself is the request-level wrapper
|
|
28
|
+
// ({request_id, status, files, metadata, ...}). Drill in before
|
|
29
|
+
// dispatching to the mapper.
|
|
30
|
+
const extracted = response.data.files?.[0]?.extracted_data;
|
|
31
|
+
if (extracted == null) {
|
|
32
|
+
return of(failureAction);
|
|
33
|
+
}
|
|
34
|
+
let result;
|
|
35
|
+
switch (documentType) {
|
|
36
|
+
case 'passport':
|
|
37
|
+
result = mapPassportToOfficer(extracted);
|
|
38
|
+
break;
|
|
39
|
+
case 'driving_license':
|
|
40
|
+
result = mapDrivingLicenseToOfficer(extracted);
|
|
41
|
+
break;
|
|
42
|
+
case 'social_security_card':
|
|
43
|
+
result = mapSsnCardToOfficer(extracted);
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
if (result.autoFilledFieldNames.length === 0) {
|
|
47
|
+
return of(failureAction);
|
|
48
|
+
}
|
|
49
|
+
const applyAction = target === 'setup'
|
|
50
|
+
? applyKycDocumentAutofillForSetup({
|
|
51
|
+
companyId,
|
|
52
|
+
officerType,
|
|
53
|
+
fileId,
|
|
54
|
+
values: result.values,
|
|
55
|
+
autoFilledFieldNames: result.autoFilledFieldNames,
|
|
56
|
+
})
|
|
57
|
+
: applyKycDocumentAutofillForOnboarding({
|
|
58
|
+
companyId,
|
|
59
|
+
officerType,
|
|
60
|
+
fileId,
|
|
61
|
+
values: result.values,
|
|
62
|
+
autoFilledFieldNames: result.autoFilledFieldNames,
|
|
63
|
+
});
|
|
64
|
+
const actions = [applyAction];
|
|
65
|
+
// Driving licenses also carry the home address, which lives in the
|
|
66
|
+
// addressView slice (keyed `officer_<n>_address`). Seed it so the
|
|
67
|
+
// section's address field + ✦ badge pick it up.
|
|
68
|
+
if (result.address != null) {
|
|
69
|
+
const addressType = `${officerType.toLowerCase()}_address`;
|
|
70
|
+
actions.push(newAddressInLocalStore({
|
|
71
|
+
addressType,
|
|
72
|
+
addressToCreate: result.address,
|
|
73
|
+
}));
|
|
74
|
+
}
|
|
75
|
+
return from(actions);
|
|
76
|
+
}), catchError(() => of(failureAction)));
|
|
77
|
+
}));
|
|
@@ -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');
|