@zeniai/client-epic-state 5.0.90-betaAS4 → 5.0.90-betaAS6
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/esm/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.js +7 -3
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +33 -7
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.js +40 -2
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +16 -0
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +3 -0
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +20 -7
- package/lib/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.d.ts +3 -3
- package/lib/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.js +6 -2
- package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.d.ts +2 -1
- package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +32 -6
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.d.ts +2 -0
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.js +41 -2
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.d.ts +2 -1
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +18 -1
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +3 -0
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +20 -7
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationState.d.ts +2 -0
- package/package.json +1 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { from, of } from 'rxjs';
|
|
2
2
|
import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
|
|
3
3
|
import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
|
|
4
|
-
import {
|
|
5
|
-
|
|
4
|
+
import { toVerificationFormLocalDataFromOnboardingDetails } from '../internationalWireOnboardingDetailsToLocalData';
|
|
5
|
+
import { fetchInternationalVerificationForm, updateInternationalVerificationForm, updateVerificationFormFailure, updateVerificationFormLocalData, } from '../internationalWireVerificationReducer';
|
|
6
|
+
export const fetchIntlVerificationFormEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchInternationalVerificationForm.match), switchMap((action) => {
|
|
6
7
|
const query = {
|
|
7
8
|
region: 'US',
|
|
8
9
|
legal_type: 'BUSINESS',
|
|
@@ -11,11 +12,14 @@ export const fetchIntlVerificationFormEpic = (actions$, _state$, zeniAPI) => act
|
|
|
11
12
|
.getJSON(`${zeniAPI.apiEndPoints.payMicroServiceBaseUrl}/1.0/international-wire/onboarding-fields?query=${encodeURIComponent(JSON.stringify(query))}`)
|
|
12
13
|
.pipe(mergeMap((response) => {
|
|
13
14
|
if (isSuccessResponse(response) && response.data != null) {
|
|
15
|
+
const onboardingDataFromCompanyInfo = state$.value.companyState.companiesById[action.payload.companyId]
|
|
16
|
+
?.companyBillPayInfo?.internationalWireOnboardingDetails;
|
|
17
|
+
const localData = toVerificationFormLocalDataFromOnboardingDetails(onboardingDataFromCompanyInfo, response.data.labels);
|
|
14
18
|
return from([
|
|
15
19
|
updateInternationalVerificationForm({
|
|
16
20
|
internationalWireFormPayload: response.data.labels,
|
|
17
21
|
}),
|
|
18
|
-
|
|
22
|
+
updateVerificationFormLocalData(localData),
|
|
19
23
|
]);
|
|
20
24
|
}
|
|
21
25
|
else {
|
|
@@ -1,12 +1,38 @@
|
|
|
1
|
-
import { from } from 'rxjs';
|
|
1
|
+
import { empty, from } from 'rxjs';
|
|
2
2
|
import { filter, mergeMap } from 'rxjs/operators';
|
|
3
|
+
import { getCurrentTenant } from '../../../../../entity/tenant/tenantSelector';
|
|
4
|
+
import { fetchBillPaySetupViewSuccess } from '../../billPaySetupView/billPaySetupViewReducer';
|
|
3
5
|
import { toVerificationFormLocalDataFromOnboardingDetails } from '../internationalWireOnboardingDetailsToLocalData';
|
|
4
6
|
import { initializeIntlVerificationForm, updateVerificationFormLocalData, } from '../internationalWireVerificationReducer';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
const hasSavedPersonSubfieldData = (localData) => Object.keys(localData).some((key) => /^stake_holder_\d+_/.test(key) ||
|
|
8
|
+
(key.startsWith('controlling_person_') && key !== 'controlling_person'));
|
|
9
|
+
export const initializeIntlVerificationFormEpic = (actions$, state$) => actions$.pipe(filter((action) => initializeIntlVerificationForm.match(action) ||
|
|
10
|
+
fetchBillPaySetupViewSuccess.match(action)), mergeMap((action) => {
|
|
7
11
|
const state = state$.value;
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
const formFieldLabels = state.internationalWireVerificationState.verificationFormFieldLabels;
|
|
13
|
+
if (Object.keys(formFieldLabels).length === 0) {
|
|
14
|
+
return empty();
|
|
15
|
+
}
|
|
16
|
+
const companyId = initializeIntlVerificationForm.match(action) ?
|
|
17
|
+
action.payload.companyId
|
|
18
|
+
: getCurrentTenant(state)?.companyId;
|
|
19
|
+
if (companyId == null) {
|
|
20
|
+
return empty();
|
|
21
|
+
}
|
|
22
|
+
const onboardingDataFromCompanyInfo = state.companyState.companiesById[companyId]?.companyBillPayInfo
|
|
23
|
+
?.internationalWireOnboardingDetails;
|
|
24
|
+
const localDataFromCompany = toVerificationFormLocalDataFromOnboardingDetails(onboardingDataFromCompanyInfo, formFieldLabels);
|
|
25
|
+
const existingLocalData = state.internationalWireVerificationState.verificationFormLocalData;
|
|
26
|
+
if (fetchBillPaySetupViewSuccess.match(action)) {
|
|
27
|
+
if (!hasSavedPersonSubfieldData(localDataFromCompany) ||
|
|
28
|
+
hasSavedPersonSubfieldData(existingLocalData)) {
|
|
29
|
+
return empty();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return from([
|
|
33
|
+
updateVerificationFormLocalData({
|
|
34
|
+
...existingLocalData,
|
|
35
|
+
...localDataFromCompany,
|
|
36
|
+
}),
|
|
37
|
+
]);
|
|
12
38
|
}));
|
|
@@ -1,10 +1,24 @@
|
|
|
1
|
-
import { InternationalWireVerificationSubfieldNames } from './internationalWireVerificationFieldConstants';
|
|
1
|
+
import { InternationalWireVerificationFormFieldNames, InternationalWireVerificationSubfieldNames, } from './internationalWireVerificationFieldConstants';
|
|
2
2
|
import { IntlWireVerificationLocalDataSuffix } from './internationalWireVerificationSubmitPayload';
|
|
3
3
|
export const isIntlWireFileOptionLike = (value) => typeof value === 'object' &&
|
|
4
4
|
value != null &&
|
|
5
5
|
'file_id' in value &&
|
|
6
6
|
typeof value.file_id === 'string';
|
|
7
|
-
export const isIntlWirePersonLike = (value) =>
|
|
7
|
+
export const isIntlWirePersonLike = (value) => {
|
|
8
|
+
if (typeof value !== 'object' || value == null || Array.isArray(value)) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
const person = value;
|
|
12
|
+
return (person.name != null ||
|
|
13
|
+
person.email != null ||
|
|
14
|
+
person.nationality != null ||
|
|
15
|
+
person.company_role != null ||
|
|
16
|
+
person.ssn != null ||
|
|
17
|
+
person.date_of_birth != null ||
|
|
18
|
+
person.ownership_percentage != null ||
|
|
19
|
+
person.proof_of_identity != null ||
|
|
20
|
+
person.proof_of_address != null);
|
|
21
|
+
};
|
|
8
22
|
export const toIntlWireFileOptionArray = (items) => items.filter(isIntlWireFileOptionLike);
|
|
9
23
|
export const appendIntlWireFileOptionsToLocalData = (localData, baseKey, fileOptions) => {
|
|
10
24
|
const [front, back] = fileOptions;
|
|
@@ -47,6 +61,30 @@ export const appendIntlWirePersonToLocalData = (localData, keyPrefix, person) =>
|
|
|
47
61
|
appendIntlWireFileOptionsToLocalData(localData, `${keyPrefix}_${InternationalWireVerificationSubfieldNames.proofOfAddress}`, toIntlWireFileOptionArray(person.proof_of_address));
|
|
48
62
|
}
|
|
49
63
|
};
|
|
64
|
+
const hasLocalDataValue = (value) => {
|
|
65
|
+
if (value == null) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
if (typeof value === 'string') {
|
|
69
|
+
return value !== '';
|
|
70
|
+
}
|
|
71
|
+
if (typeof value === 'number') {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
if (Array.isArray(value)) {
|
|
75
|
+
return value.length > 0;
|
|
76
|
+
}
|
|
77
|
+
return true;
|
|
78
|
+
};
|
|
79
|
+
export const hasBooleanWithSubfieldsFieldValueInLocalData = (fieldName, localData) => {
|
|
80
|
+
if (hasLocalDataValue(localData[fieldName])) {
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
if (fieldName === InternationalWireVerificationFormFieldNames.stakeHolder) {
|
|
84
|
+
return Object.entries(localData).some(([key, value]) => /^stake_holder_\d+_/.test(key) && hasLocalDataValue(value));
|
|
85
|
+
}
|
|
86
|
+
return Object.entries(localData).some(([key, value]) => key.startsWith(`${fieldName}_`) && hasLocalDataValue(value));
|
|
87
|
+
};
|
|
50
88
|
export const getStakeHolderOwnerIndicesFromLocalData = (localData) => {
|
|
51
89
|
const indices = new Set();
|
|
52
90
|
Object.keys(localData).forEach((key) => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { InternationalWireVerificationFormFieldNames } from './internationalWireVerificationFieldConstants';
|
|
2
|
+
import { hasBooleanWithSubfieldsFieldValueInLocalData } from './internationalWireVerificationLocalDataHelpers';
|
|
2
3
|
export const InternationalWireVerificationFormOrder = [
|
|
3
4
|
InternationalWireVerificationFormFieldNames.certificateOfGoodStanding,
|
|
4
5
|
InternationalWireVerificationFormFieldNames.businessOwnership,
|
|
@@ -40,6 +41,21 @@ export const toDynamicFormField = (key, payload) => ({
|
|
|
40
41
|
]))
|
|
41
42
|
: undefined,
|
|
42
43
|
});
|
|
44
|
+
const readonlyHideableVerificationFormFieldNames = new Set([
|
|
45
|
+
InternationalWireVerificationFormFieldNames.stakeHolder,
|
|
46
|
+
InternationalWireVerificationFormFieldNames.controllingPerson,
|
|
47
|
+
]);
|
|
48
|
+
export const filterVerificationFormFieldsForReadonlyView = (fields, localData, isReadonly) => {
|
|
49
|
+
if (!isReadonly) {
|
|
50
|
+
return fields;
|
|
51
|
+
}
|
|
52
|
+
return fields.filter((field) => {
|
|
53
|
+
if (!readonlyHideableVerificationFormFieldNames.has(field.name)) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
return hasBooleanWithSubfieldsFieldValueInLocalData(field.name, localData);
|
|
57
|
+
});
|
|
58
|
+
};
|
|
43
59
|
export const sortVerificationFormFields = (fields) => {
|
|
44
60
|
const orderIndex = new Map(InternationalWireVerificationFormOrder.map((name, index) => [name, index]));
|
|
45
61
|
return fields.slice().sort((a, b) => {
|
|
@@ -4,6 +4,7 @@ export const initialState = {
|
|
|
4
4
|
verificationFormFetchState: {
|
|
5
5
|
fetchState: 'Not-Started',
|
|
6
6
|
},
|
|
7
|
+
verificationFormFieldLabels: {},
|
|
7
8
|
verificationFormFields: [],
|
|
8
9
|
verificationFormLocalData: {},
|
|
9
10
|
verificationFormSubmitState: {
|
|
@@ -31,6 +32,7 @@ const internationalWireVerification = createSlice({
|
|
|
31
32
|
},
|
|
32
33
|
updateInternationalVerificationForm(draft, action) {
|
|
33
34
|
const { internationalWireFormPayload } = action.payload;
|
|
35
|
+
draft.verificationFormFieldLabels = internationalWireFormPayload;
|
|
34
36
|
draft.verificationFormFields = toVerificationFormFields(internationalWireFormPayload);
|
|
35
37
|
draft.verificationFormFetchState.fetchState = 'Completed';
|
|
36
38
|
},
|
|
@@ -41,6 +43,7 @@ const internationalWireVerification = createSlice({
|
|
|
41
43
|
},
|
|
42
44
|
updateVerificationFormLocalData(draft, action) {
|
|
43
45
|
draft.verificationFormLocalData = {
|
|
46
|
+
...draft.verificationFormLocalData,
|
|
44
47
|
...action.payload,
|
|
45
48
|
};
|
|
46
49
|
},
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { getCompanyByCompanyId } from '../../../../entity/company/companySelector';
|
|
1
2
|
import { getFilesByFileIds } from '../../../../entity/file/fileSelector';
|
|
3
|
+
import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
|
|
2
4
|
import { getFileDeleteStatusById, getFileUpdateNameStatusById, } from '../../../fileView/fileViewSelector';
|
|
5
|
+
import { filterVerificationFormFieldsForReadonlyView } from './internationalWireVerificationPayload';
|
|
3
6
|
const collectFileIdsFromLocalData = (localData) => {
|
|
4
7
|
const fileIds = new Set();
|
|
5
8
|
Object.values(localData).forEach((value) => {
|
|
@@ -20,18 +23,28 @@ const collectFileIdsFromLocalData = (localData) => {
|
|
|
20
23
|
export const getIntlWireVerificationView = (state) => {
|
|
21
24
|
const deleteFileStatusById = {};
|
|
22
25
|
const updateFileStatusById = {};
|
|
23
|
-
const
|
|
26
|
+
const { verificationFormFetchState, verificationFormFields, verificationFormLocalData, verificationFormSubmitState, } = state.internationalWireVerificationState;
|
|
27
|
+
const fileIds = collectFileIdsFromLocalData(verificationFormLocalData);
|
|
24
28
|
fileIds.forEach((fileId) => {
|
|
25
29
|
deleteFileStatusById[fileId] = getFileDeleteStatusById(state, fileId);
|
|
26
30
|
updateFileStatusById[fileId] = getFileUpdateNameStatusById(state, fileId);
|
|
27
31
|
});
|
|
28
|
-
const userFiles = fileIds.length > 0
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
.
|
|
32
|
+
const userFiles = fileIds.length > 0 ? getFilesByFileIds(state.fileState, fileIds) : [];
|
|
33
|
+
const fetchState = verificationFormFetchState.fetchState;
|
|
34
|
+
const currentTenant = getCurrentTenant(state);
|
|
35
|
+
const company = currentTenant?.companyId != null
|
|
36
|
+
? getCompanyByCompanyId(state.companyState, currentTenant.companyId)
|
|
37
|
+
?.company
|
|
38
|
+
: undefined;
|
|
39
|
+
const onboardingStatusCode = company?.companyBillPayInfo?.internationalWireOnboardingStatus?.code;
|
|
40
|
+
const isReadonly = onboardingStatusCode != null &&
|
|
41
|
+
onboardingStatusCode !== 'onboarding_status_not_started';
|
|
42
|
+
const visibleVerificationFormFields = filterVerificationFormFieldsForReadonlyView(verificationFormFields, verificationFormLocalData, isReadonly);
|
|
33
43
|
return {
|
|
34
|
-
|
|
44
|
+
verificationFormFetchState,
|
|
45
|
+
verificationFormFields: visibleVerificationFormFields,
|
|
46
|
+
verificationFormLocalData,
|
|
47
|
+
verificationFormSubmitState,
|
|
35
48
|
deleteFileStatusById,
|
|
36
49
|
updateFileStatusById,
|
|
37
50
|
userFiles,
|
|
@@ -2,6 +2,6 @@ import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { RootState } from '../../../../../reducer';
|
|
4
4
|
import { ZeniAPI } from '../../../../../zeniAPI';
|
|
5
|
-
import { fetchInternationalVerificationForm,
|
|
6
|
-
export type ActionType = ReturnType<typeof fetchInternationalVerificationForm> | ReturnType<typeof updateInternationalVerificationForm> | ReturnType<typeof updateVerificationFormFailure> | ReturnType<typeof
|
|
7
|
-
export declare const fetchIntlVerificationFormEpic: (actions$: ActionsObservable<ActionType>,
|
|
5
|
+
import { fetchInternationalVerificationForm, updateInternationalVerificationForm, updateVerificationFormFailure, updateVerificationFormLocalData } from '../internationalWireVerificationReducer';
|
|
6
|
+
export type ActionType = ReturnType<typeof fetchInternationalVerificationForm> | ReturnType<typeof updateInternationalVerificationForm> | ReturnType<typeof updateVerificationFormFailure> | ReturnType<typeof updateVerificationFormLocalData>;
|
|
7
|
+
export declare const fetchIntlVerificationFormEpic: (actions$: ActionsObservable<ActionType>, state$: StateObservable<RootState>, zeniAPI: ZeniAPI) => Observable<ActionType>;
|
|
@@ -4,8 +4,9 @@ exports.fetchIntlVerificationFormEpic = void 0;
|
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const operators_1 = require("rxjs/operators");
|
|
6
6
|
const responsePayload_1 = require("../../../../../responsePayload");
|
|
7
|
+
const internationalWireOnboardingDetailsToLocalData_1 = require("../internationalWireOnboardingDetailsToLocalData");
|
|
7
8
|
const internationalWireVerificationReducer_1 = require("../internationalWireVerificationReducer");
|
|
8
|
-
const fetchIntlVerificationFormEpic = (actions$,
|
|
9
|
+
const fetchIntlVerificationFormEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(internationalWireVerificationReducer_1.fetchInternationalVerificationForm.match), (0, operators_1.switchMap)((action) => {
|
|
9
10
|
const query = {
|
|
10
11
|
region: 'US',
|
|
11
12
|
legal_type: 'BUSINESS',
|
|
@@ -14,11 +15,14 @@ const fetchIntlVerificationFormEpic = (actions$, _state$, zeniAPI) => actions$.p
|
|
|
14
15
|
.getJSON(`${zeniAPI.apiEndPoints.payMicroServiceBaseUrl}/1.0/international-wire/onboarding-fields?query=${encodeURIComponent(JSON.stringify(query))}`)
|
|
15
16
|
.pipe((0, operators_1.mergeMap)((response) => {
|
|
16
17
|
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
18
|
+
const onboardingDataFromCompanyInfo = state$.value.companyState.companiesById[action.payload.companyId]
|
|
19
|
+
?.companyBillPayInfo?.internationalWireOnboardingDetails;
|
|
20
|
+
const localData = (0, internationalWireOnboardingDetailsToLocalData_1.toVerificationFormLocalDataFromOnboardingDetails)(onboardingDataFromCompanyInfo, response.data.labels);
|
|
17
21
|
return (0, rxjs_1.from)([
|
|
18
22
|
(0, internationalWireVerificationReducer_1.updateInternationalVerificationForm)({
|
|
19
23
|
internationalWireFormPayload: response.data.labels,
|
|
20
24
|
}),
|
|
21
|
-
(0, internationalWireVerificationReducer_1.
|
|
25
|
+
(0, internationalWireVerificationReducer_1.updateVerificationFormLocalData)(localData),
|
|
22
26
|
]);
|
|
23
27
|
}
|
|
24
28
|
else {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ActionsObservable, StateObservable } from 'redux-observable';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
3
|
import { RootState } from '../../../../../reducer';
|
|
4
|
+
import { fetchBillPaySetupViewSuccess } from '../../billPaySetupView/billPaySetupViewReducer';
|
|
4
5
|
import { initializeIntlVerificationForm, updateVerificationFormLocalData } from '../internationalWireVerificationReducer';
|
|
5
6
|
export type ActionType = ReturnType<typeof updateVerificationFormLocalData> | ReturnType<typeof initializeIntlVerificationForm>;
|
|
6
|
-
export declare const initializeIntlVerificationFormEpic: (actions$: ActionsObservable<ActionType
|
|
7
|
+
export declare const initializeIntlVerificationFormEpic: (actions$: ActionsObservable<ActionType | ReturnType<typeof fetchBillPaySetupViewSuccess>>, state$: StateObservable<RootState>) => Observable<ActionType>;
|
|
@@ -3,14 +3,40 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.initializeIntlVerificationFormEpic = void 0;
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const tenantSelector_1 = require("../../../../../entity/tenant/tenantSelector");
|
|
7
|
+
const billPaySetupViewReducer_1 = require("../../billPaySetupView/billPaySetupViewReducer");
|
|
6
8
|
const internationalWireOnboardingDetailsToLocalData_1 = require("../internationalWireOnboardingDetailsToLocalData");
|
|
7
9
|
const internationalWireVerificationReducer_1 = require("../internationalWireVerificationReducer");
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
+
const hasSavedPersonSubfieldData = (localData) => Object.keys(localData).some((key) => /^stake_holder_\d+_/.test(key) ||
|
|
11
|
+
(key.startsWith('controlling_person_') && key !== 'controlling_person'));
|
|
12
|
+
const initializeIntlVerificationFormEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)((action) => internationalWireVerificationReducer_1.initializeIntlVerificationForm.match(action) ||
|
|
13
|
+
billPaySetupViewReducer_1.fetchBillPaySetupViewSuccess.match(action)), (0, operators_1.mergeMap)((action) => {
|
|
10
14
|
const state = state$.value;
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
const formFieldLabels = state.internationalWireVerificationState.verificationFormFieldLabels;
|
|
16
|
+
if (Object.keys(formFieldLabels).length === 0) {
|
|
17
|
+
return (0, rxjs_1.empty)();
|
|
18
|
+
}
|
|
19
|
+
const companyId = internationalWireVerificationReducer_1.initializeIntlVerificationForm.match(action) ?
|
|
20
|
+
action.payload.companyId
|
|
21
|
+
: (0, tenantSelector_1.getCurrentTenant)(state)?.companyId;
|
|
22
|
+
if (companyId == null) {
|
|
23
|
+
return (0, rxjs_1.empty)();
|
|
24
|
+
}
|
|
25
|
+
const onboardingDataFromCompanyInfo = state.companyState.companiesById[companyId]?.companyBillPayInfo
|
|
26
|
+
?.internationalWireOnboardingDetails;
|
|
27
|
+
const localDataFromCompany = (0, internationalWireOnboardingDetailsToLocalData_1.toVerificationFormLocalDataFromOnboardingDetails)(onboardingDataFromCompanyInfo, formFieldLabels);
|
|
28
|
+
const existingLocalData = state.internationalWireVerificationState.verificationFormLocalData;
|
|
29
|
+
if (billPaySetupViewReducer_1.fetchBillPaySetupViewSuccess.match(action)) {
|
|
30
|
+
if (!hasSavedPersonSubfieldData(localDataFromCompany) ||
|
|
31
|
+
hasSavedPersonSubfieldData(existingLocalData)) {
|
|
32
|
+
return (0, rxjs_1.empty)();
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return (0, rxjs_1.from)([
|
|
36
|
+
(0, internationalWireVerificationReducer_1.updateVerificationFormLocalData)({
|
|
37
|
+
...existingLocalData,
|
|
38
|
+
...localDataFromCompany,
|
|
39
|
+
}),
|
|
40
|
+
]);
|
|
15
41
|
}));
|
|
16
42
|
exports.initializeIntlVerificationFormEpic = initializeIntlVerificationFormEpic;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { InternationalWireVerificationBooleanWithSubfieldsFieldName } from './internationalWireVerificationFieldConstants';
|
|
1
2
|
import { VerificationFormLocalData } from './internationalWireVerificationState';
|
|
2
3
|
export type IntlWireFileOptionLike = {
|
|
3
4
|
file_id: string;
|
|
@@ -23,4 +24,5 @@ export declare const isIntlWirePersonLike: (value: unknown) => value is IntlWire
|
|
|
23
24
|
export declare const toIntlWireFileOptionArray: (items: unknown[]) => IntlWireFileOptionLike[];
|
|
24
25
|
export declare const appendIntlWireFileOptionsToLocalData: (localData: VerificationFormLocalData, baseKey: string, fileOptions: IntlWireFileOptionLike[]) => void;
|
|
25
26
|
export declare const appendIntlWirePersonToLocalData: (localData: VerificationFormLocalData, keyPrefix: string, person: IntlWirePersonLike) => void;
|
|
27
|
+
export declare const hasBooleanWithSubfieldsFieldValueInLocalData: (fieldName: InternationalWireVerificationBooleanWithSubfieldsFieldName, localData: VerificationFormLocalData) => boolean;
|
|
26
28
|
export declare const getStakeHolderOwnerIndicesFromLocalData: (localData: VerificationFormLocalData) => number[];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getStakeHolderOwnerIndicesFromLocalData = exports.appendIntlWirePersonToLocalData = exports.appendIntlWireFileOptionsToLocalData = exports.toIntlWireFileOptionArray = exports.isIntlWirePersonLike = exports.isIntlWireFileOptionLike = void 0;
|
|
3
|
+
exports.getStakeHolderOwnerIndicesFromLocalData = exports.hasBooleanWithSubfieldsFieldValueInLocalData = exports.appendIntlWirePersonToLocalData = exports.appendIntlWireFileOptionsToLocalData = exports.toIntlWireFileOptionArray = exports.isIntlWirePersonLike = exports.isIntlWireFileOptionLike = void 0;
|
|
4
4
|
const internationalWireVerificationFieldConstants_1 = require("./internationalWireVerificationFieldConstants");
|
|
5
5
|
const internationalWireVerificationSubmitPayload_1 = require("./internationalWireVerificationSubmitPayload");
|
|
6
6
|
const isIntlWireFileOptionLike = (value) => typeof value === 'object' &&
|
|
@@ -8,7 +8,21 @@ const isIntlWireFileOptionLike = (value) => typeof value === 'object' &&
|
|
|
8
8
|
'file_id' in value &&
|
|
9
9
|
typeof value.file_id === 'string';
|
|
10
10
|
exports.isIntlWireFileOptionLike = isIntlWireFileOptionLike;
|
|
11
|
-
const isIntlWirePersonLike = (value) =>
|
|
11
|
+
const isIntlWirePersonLike = (value) => {
|
|
12
|
+
if (typeof value !== 'object' || value == null || Array.isArray(value)) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
const person = value;
|
|
16
|
+
return (person.name != null ||
|
|
17
|
+
person.email != null ||
|
|
18
|
+
person.nationality != null ||
|
|
19
|
+
person.company_role != null ||
|
|
20
|
+
person.ssn != null ||
|
|
21
|
+
person.date_of_birth != null ||
|
|
22
|
+
person.ownership_percentage != null ||
|
|
23
|
+
person.proof_of_identity != null ||
|
|
24
|
+
person.proof_of_address != null);
|
|
25
|
+
};
|
|
12
26
|
exports.isIntlWirePersonLike = isIntlWirePersonLike;
|
|
13
27
|
const toIntlWireFileOptionArray = (items) => items.filter(exports.isIntlWireFileOptionLike);
|
|
14
28
|
exports.toIntlWireFileOptionArray = toIntlWireFileOptionArray;
|
|
@@ -55,6 +69,31 @@ const appendIntlWirePersonToLocalData = (localData, keyPrefix, person) => {
|
|
|
55
69
|
}
|
|
56
70
|
};
|
|
57
71
|
exports.appendIntlWirePersonToLocalData = appendIntlWirePersonToLocalData;
|
|
72
|
+
const hasLocalDataValue = (value) => {
|
|
73
|
+
if (value == null) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
if (typeof value === 'string') {
|
|
77
|
+
return value !== '';
|
|
78
|
+
}
|
|
79
|
+
if (typeof value === 'number') {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
if (Array.isArray(value)) {
|
|
83
|
+
return value.length > 0;
|
|
84
|
+
}
|
|
85
|
+
return true;
|
|
86
|
+
};
|
|
87
|
+
const hasBooleanWithSubfieldsFieldValueInLocalData = (fieldName, localData) => {
|
|
88
|
+
if (hasLocalDataValue(localData[fieldName])) {
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
if (fieldName === internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.stakeHolder) {
|
|
92
|
+
return Object.entries(localData).some(([key, value]) => /^stake_holder_\d+_/.test(key) && hasLocalDataValue(value));
|
|
93
|
+
}
|
|
94
|
+
return Object.entries(localData).some(([key, value]) => key.startsWith(`${fieldName}_`) && hasLocalDataValue(value));
|
|
95
|
+
};
|
|
96
|
+
exports.hasBooleanWithSubfieldsFieldValueInLocalData = hasBooleanWithSubfieldsFieldValueInLocalData;
|
|
58
97
|
const getStakeHolderOwnerIndicesFromLocalData = (localData) => {
|
|
59
98
|
const indices = new Set();
|
|
60
99
|
Object.keys(localData).forEach((key) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AllowedValueWithCode } from '../../../../commonStateTypes/allowedValue';
|
|
2
2
|
import { ZeniAPIResponse } from '../../../../responsePayload';
|
|
3
|
-
import { VerificationFormField } from './internationalWireVerificationState';
|
|
3
|
+
import { VerificationFormField, VerificationFormLocalData } from './internationalWireVerificationState';
|
|
4
4
|
export declare const InternationalWireVerificationFormOrder: readonly ["certificate_of_good_standing", "business_ownership", "company_proof_of_address", "company_officer_proof_of_address", "company_registration_date", "annual_turnover", "expected_transaction_volume", "employee_count", "intended_use_of_account", "transaction_countries", "stake_holder", "controlling_person"];
|
|
5
5
|
export interface FieldOptionPayload {
|
|
6
6
|
label: string;
|
|
@@ -32,6 +32,7 @@ export interface FieldPayload {
|
|
|
32
32
|
subfields?: Record<string, SubFieldPayload>;
|
|
33
33
|
}
|
|
34
34
|
export declare const toDynamicFormField: (key: string, payload: FieldPayload) => VerificationFormField;
|
|
35
|
+
export declare const filterVerificationFormFieldsForReadonlyView: (fields: VerificationFormField[], localData: VerificationFormLocalData, isReadonly: boolean) => VerificationFormField[];
|
|
35
36
|
export declare const sortVerificationFormFields: (fields: VerificationFormField[]) => VerificationFormField[];
|
|
36
37
|
export declare const toVerificationFormFields: (internationalWireFormPayload: Record<string, FieldPayload>) => VerificationFormField[];
|
|
37
38
|
export type IntlVerificationFormResponse = ZeniAPIResponse<IntlVerificationFormPayload>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toVerificationFormFields = exports.sortVerificationFormFields = exports.toDynamicFormField = exports.InternationalWireVerificationFormOrder = void 0;
|
|
3
|
+
exports.toVerificationFormFields = exports.sortVerificationFormFields = exports.filterVerificationFormFieldsForReadonlyView = exports.toDynamicFormField = exports.InternationalWireVerificationFormOrder = void 0;
|
|
4
4
|
const internationalWireVerificationFieldConstants_1 = require("./internationalWireVerificationFieldConstants");
|
|
5
|
+
const internationalWireVerificationLocalDataHelpers_1 = require("./internationalWireVerificationLocalDataHelpers");
|
|
5
6
|
exports.InternationalWireVerificationFormOrder = [
|
|
6
7
|
internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.certificateOfGoodStanding,
|
|
7
8
|
internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.businessOwnership,
|
|
@@ -44,6 +45,22 @@ const toDynamicFormField = (key, payload) => ({
|
|
|
44
45
|
: undefined,
|
|
45
46
|
});
|
|
46
47
|
exports.toDynamicFormField = toDynamicFormField;
|
|
48
|
+
const readonlyHideableVerificationFormFieldNames = new Set([
|
|
49
|
+
internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.stakeHolder,
|
|
50
|
+
internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.controllingPerson,
|
|
51
|
+
]);
|
|
52
|
+
const filterVerificationFormFieldsForReadonlyView = (fields, localData, isReadonly) => {
|
|
53
|
+
if (!isReadonly) {
|
|
54
|
+
return fields;
|
|
55
|
+
}
|
|
56
|
+
return fields.filter((field) => {
|
|
57
|
+
if (!readonlyHideableVerificationFormFieldNames.has(field.name)) {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
return (0, internationalWireVerificationLocalDataHelpers_1.hasBooleanWithSubfieldsFieldValueInLocalData)(field.name, localData);
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
exports.filterVerificationFormFieldsForReadonlyView = filterVerificationFormFieldsForReadonlyView;
|
|
47
64
|
const sortVerificationFormFields = (fields) => {
|
|
48
65
|
const orderIndex = new Map(exports.InternationalWireVerificationFormOrder.map((name, index) => [name, index]));
|
|
49
66
|
return fields.slice().sort((a, b) => {
|
|
@@ -8,6 +8,7 @@ exports.initialState = {
|
|
|
8
8
|
verificationFormFetchState: {
|
|
9
9
|
fetchState: 'Not-Started',
|
|
10
10
|
},
|
|
11
|
+
verificationFormFieldLabels: {},
|
|
11
12
|
verificationFormFields: [],
|
|
12
13
|
verificationFormLocalData: {},
|
|
13
14
|
verificationFormSubmitState: {
|
|
@@ -35,6 +36,7 @@ const internationalWireVerification = (0, toolkit_1.createSlice)({
|
|
|
35
36
|
},
|
|
36
37
|
updateInternationalVerificationForm(draft, action) {
|
|
37
38
|
const { internationalWireFormPayload } = action.payload;
|
|
39
|
+
draft.verificationFormFieldLabels = internationalWireFormPayload;
|
|
38
40
|
draft.verificationFormFields = (0, internationalWireVerificationPayload_1.toVerificationFormFields)(internationalWireFormPayload);
|
|
39
41
|
draft.verificationFormFetchState.fetchState = 'Completed';
|
|
40
42
|
},
|
|
@@ -45,6 +47,7 @@ const internationalWireVerification = (0, toolkit_1.createSlice)({
|
|
|
45
47
|
},
|
|
46
48
|
updateVerificationFormLocalData(draft, action) {
|
|
47
49
|
draft.verificationFormLocalData = {
|
|
50
|
+
...draft.verificationFormLocalData,
|
|
48
51
|
...action.payload,
|
|
49
52
|
};
|
|
50
53
|
},
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getIntlWireVerificationView = void 0;
|
|
4
|
+
const companySelector_1 = require("../../../../entity/company/companySelector");
|
|
4
5
|
const fileSelector_1 = require("../../../../entity/file/fileSelector");
|
|
6
|
+
const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
|
|
5
7
|
const fileViewSelector_1 = require("../../../fileView/fileViewSelector");
|
|
8
|
+
const internationalWireVerificationPayload_1 = require("./internationalWireVerificationPayload");
|
|
6
9
|
const collectFileIdsFromLocalData = (localData) => {
|
|
7
10
|
const fileIds = new Set();
|
|
8
11
|
Object.values(localData).forEach((value) => {
|
|
@@ -23,18 +26,28 @@ const collectFileIdsFromLocalData = (localData) => {
|
|
|
23
26
|
const getIntlWireVerificationView = (state) => {
|
|
24
27
|
const deleteFileStatusById = {};
|
|
25
28
|
const updateFileStatusById = {};
|
|
26
|
-
const
|
|
29
|
+
const { verificationFormFetchState, verificationFormFields, verificationFormLocalData, verificationFormSubmitState, } = state.internationalWireVerificationState;
|
|
30
|
+
const fileIds = collectFileIdsFromLocalData(verificationFormLocalData);
|
|
27
31
|
fileIds.forEach((fileId) => {
|
|
28
32
|
deleteFileStatusById[fileId] = (0, fileViewSelector_1.getFileDeleteStatusById)(state, fileId);
|
|
29
33
|
updateFileStatusById[fileId] = (0, fileViewSelector_1.getFileUpdateNameStatusById)(state, fileId);
|
|
30
34
|
});
|
|
31
|
-
const userFiles = fileIds.length > 0
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
.
|
|
35
|
+
const userFiles = fileIds.length > 0 ? (0, fileSelector_1.getFilesByFileIds)(state.fileState, fileIds) : [];
|
|
36
|
+
const fetchState = verificationFormFetchState.fetchState;
|
|
37
|
+
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state);
|
|
38
|
+
const company = currentTenant?.companyId != null
|
|
39
|
+
? (0, companySelector_1.getCompanyByCompanyId)(state.companyState, currentTenant.companyId)
|
|
40
|
+
?.company
|
|
41
|
+
: undefined;
|
|
42
|
+
const onboardingStatusCode = company?.companyBillPayInfo?.internationalWireOnboardingStatus?.code;
|
|
43
|
+
const isReadonly = onboardingStatusCode != null &&
|
|
44
|
+
onboardingStatusCode !== 'onboarding_status_not_started';
|
|
45
|
+
const visibleVerificationFormFields = (0, internationalWireVerificationPayload_1.filterVerificationFormFieldsForReadonlyView)(verificationFormFields, verificationFormLocalData, isReadonly);
|
|
36
46
|
return {
|
|
37
|
-
|
|
47
|
+
verificationFormFetchState,
|
|
48
|
+
verificationFormFields: visibleVerificationFormFields,
|
|
49
|
+
verificationFormLocalData,
|
|
50
|
+
verificationFormSubmitState,
|
|
38
51
|
deleteFileStatusById,
|
|
39
52
|
updateFileStatusById,
|
|
40
53
|
userFiles,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { FetchStateAndError } from '../../../../commonStateTypes/common';
|
|
2
|
+
import { FieldPayload } from './internationalWireVerificationPayload';
|
|
2
3
|
export interface InternationalWireVerificationState {
|
|
3
4
|
verificationFormFetchState: FetchStateAndError;
|
|
5
|
+
verificationFormFieldLabels: Record<string, FieldPayload>;
|
|
4
6
|
verificationFormFields: VerificationFormField[];
|
|
5
7
|
verificationFormLocalData: VerificationFormLocalData;
|
|
6
8
|
verificationFormSubmitState: FetchStateAndError;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.0.90-
|
|
3
|
+
"version": "5.0.90-betaAS6",
|
|
4
4
|
"description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib/esm/index.js",
|