@zeniai/client-epic-state 5.1.3-betaAS1 → 5.1.3
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/commonPayloadTypes/commonPayload.d.ts +4 -25
- package/lib/esm/index.js +1 -6
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.js +3 -7
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +34 -33
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/submitIntlVerificationEpic.js +7 -2
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +8 -55
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +6 -5
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +15 -39
- package/lib/index.d.ts +2 -8
- package/lib/index.js +7 -25
- package/lib/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.d.ts +3 -3
- package/lib/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.js +2 -6
- package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.d.ts +1 -2
- package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +33 -32
- package/lib/view/spendManagement/billPay/internationalWireVerification/epics/submitIntlVerificationEpic.js +7 -2
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.d.ts +1 -24
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +9 -59
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +5 -4
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +15 -39
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationState.d.ts +1 -20
- package/package.json +1 -1
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.js +0 -146
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.js +0 -40
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.js +0 -86
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.js +0 -154
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.d.ts +0 -4
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.js +0 -150
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.d.ts +0 -38
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.js +0 -43
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.d.ts +0 -27
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.js +0 -96
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.d.ts +0 -32
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.js +0 -159
|
@@ -3,40 +3,41 @@ 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");
|
|
8
|
-
const internationalWireOnboardingDetailsToLocalData_1 = require("../internationalWireOnboardingDetailsToLocalData");
|
|
9
6
|
const internationalWireVerificationReducer_1 = require("../internationalWireVerificationReducer");
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
billPaySetupViewReducer_1.fetchBillPaySetupViewSuccess.match(action)), (0, operators_1.mergeMap)((action) => {
|
|
7
|
+
const initializeIntlVerificationFormEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(internationalWireVerificationReducer_1.initializeIntlVerificationForm.match), (0, operators_1.mergeMap)((action) => {
|
|
8
|
+
const { companyId, internationalWireFormPayload } = action.payload;
|
|
9
|
+
const actions = [];
|
|
14
10
|
const state = state$.value;
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
11
|
+
const onboardingDataFromCompanyInfo = state.companyState.companiesById[companyId].companyBillPayInfo
|
|
12
|
+
.internationalWireOnboardingDetails;
|
|
13
|
+
const localData = {};
|
|
14
|
+
Object.keys(internationalWireFormPayload).forEach((formFieldKey) => {
|
|
15
|
+
const values = onboardingDataFromCompanyInfo != null
|
|
16
|
+
? onboardingDataFromCompanyInfo[formFieldKey]?.values
|
|
17
|
+
: undefined;
|
|
18
|
+
if (values != null) {
|
|
19
|
+
localData[formFieldKey] =
|
|
20
|
+
internationalWireFormPayload[formFieldKey].type === 'enum'
|
|
21
|
+
? internationalWireFormPayload[formFieldKey]
|
|
22
|
+
.is_multiple_values_allowed === false
|
|
23
|
+
? typeof values[0] === 'object' && 'code' in values[0]
|
|
24
|
+
? values[0].code
|
|
25
|
+
: ''
|
|
26
|
+
: values.map((value) => typeof value === 'object' && 'code' in value
|
|
27
|
+
? value.code
|
|
28
|
+
: '')
|
|
29
|
+
: values[0];
|
|
33
30
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
else {
|
|
32
|
+
localData[formFieldKey] =
|
|
33
|
+
internationalWireFormPayload[formFieldKey].type === 'enum' &&
|
|
34
|
+
internationalWireFormPayload[formFieldKey]
|
|
35
|
+
.is_multiple_values_allowed === true
|
|
36
|
+
? []
|
|
37
|
+
: '';
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
actions.push((0, internationalWireVerificationReducer_1.updateVerificationFormLocalData)(localData));
|
|
41
|
+
return (0, rxjs_1.from)(actions);
|
|
41
42
|
}));
|
|
42
43
|
exports.initializeIntlVerificationFormEpic = initializeIntlVerificationFormEpic;
|
|
@@ -6,7 +6,6 @@ const operators_1 = require("rxjs/operators");
|
|
|
6
6
|
const companyReducer_1 = require("../../../../../entity/company/companyReducer");
|
|
7
7
|
const snackbarReducer_1 = require("../../../../../entity/snackbar/snackbarReducer");
|
|
8
8
|
const responsePayload_1 = require("../../../../../responsePayload");
|
|
9
|
-
const internationalWireVerificationSubmitPayload_1 = require("../internationalWireVerificationSubmitPayload");
|
|
10
9
|
const internationalWireVerificationReducer_1 = require("../internationalWireVerificationReducer");
|
|
11
10
|
const submitIntlVerificationEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(internationalWireVerificationReducer_1.submitInternationalVerificationForm.match), (0, operators_1.switchMap)((action) => {
|
|
12
11
|
const { internationalWireVerificationState } = state$.value;
|
|
@@ -14,7 +13,7 @@ const submitIntlVerificationEpic = (actions$, state$, zeniAPI) => actions$.pipe(
|
|
|
14
13
|
const localData = internationalWireVerificationState.verificationFormLocalData;
|
|
15
14
|
if (localData != null) {
|
|
16
15
|
return zeniAPI
|
|
17
|
-
.postAndGetJSON(`${zeniAPI.apiEndPoints.payMicroServiceBaseUrl}/1.0/international-wire/onboarding`, (
|
|
16
|
+
.postAndGetJSON(`${zeniAPI.apiEndPoints.payMicroServiceBaseUrl}/1.0/international-wire/onboarding`, toIntlWireVerificationPayload(localData))
|
|
18
17
|
.pipe((0, operators_1.mergeMap)((response) => {
|
|
19
18
|
const actions = [];
|
|
20
19
|
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
@@ -59,3 +58,9 @@ const submitIntlVerificationEpic = (actions$, state$, zeniAPI) => actions$.pipe(
|
|
|
59
58
|
}
|
|
60
59
|
}));
|
|
61
60
|
exports.submitIntlVerificationEpic = submitIntlVerificationEpic;
|
|
61
|
+
const toIntlWireVerificationPayload = (localData) => {
|
|
62
|
+
return {
|
|
63
|
+
is_applicant_declaration: true,
|
|
64
|
+
form_details: localData,
|
|
65
|
+
};
|
|
66
|
+
};
|
|
@@ -1,40 +1,17 @@
|
|
|
1
1
|
import { AllowedValueWithCode } from '../../../../commonStateTypes/allowedValue';
|
|
2
2
|
import { ZeniAPIResponse } from '../../../../responsePayload';
|
|
3
|
-
import { VerificationFormField
|
|
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
|
-
export interface FieldOptionPayload {
|
|
6
|
-
label: string;
|
|
7
|
-
}
|
|
8
|
-
export interface SubFieldPayload {
|
|
9
|
-
label: string;
|
|
10
|
-
type: string;
|
|
11
|
-
field_hint_text?: string;
|
|
12
|
-
field_values?: {
|
|
13
|
-
code: string;
|
|
14
|
-
description: string;
|
|
15
|
-
}[];
|
|
16
|
-
is_multiple_options_supported?: boolean;
|
|
17
|
-
options?: Record<string, FieldOptionPayload>;
|
|
18
|
-
}
|
|
3
|
+
import { VerificationFormField } from './internationalWireVerificationState';
|
|
19
4
|
export interface FieldPayload {
|
|
20
5
|
label: string;
|
|
21
6
|
type: string;
|
|
22
|
-
default?: boolean;
|
|
23
7
|
field_hint_text?: string;
|
|
24
8
|
field_values?: {
|
|
25
9
|
code: string;
|
|
26
10
|
description: string;
|
|
27
11
|
}[];
|
|
28
|
-
is_multiple_options_supported?: boolean;
|
|
29
12
|
is_multiple_values_allowed?: boolean;
|
|
30
|
-
options?: Record<string, FieldOptionPayload>;
|
|
31
|
-
requirements?: string[];
|
|
32
|
-
subfields?: Record<string, SubFieldPayload>;
|
|
33
13
|
}
|
|
34
14
|
export declare const toDynamicFormField: (key: string, payload: FieldPayload) => VerificationFormField;
|
|
35
|
-
export declare const filterVerificationFormFieldsForReadonlyView: (fields: VerificationFormField[], localData: VerificationFormLocalData, isReadonly: boolean) => VerificationFormField[];
|
|
36
|
-
export declare const sortVerificationFormFields: (fields: VerificationFormField[]) => VerificationFormField[];
|
|
37
|
-
export declare const toVerificationFormFields: (internationalWireFormPayload: Record<string, FieldPayload>) => VerificationFormField[];
|
|
38
15
|
export type IntlVerificationFormResponse = ZeniAPIResponse<IntlVerificationFormPayload>;
|
|
39
16
|
export interface IntlVerificationFormPayload {
|
|
40
17
|
create_time: string;
|
|
@@ -1,69 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const internationalWireVerificationFieldConstants_1 = require("./internationalWireVerificationFieldConstants");
|
|
5
|
-
const internationalWireVerificationLocalDataHelpers_1 = require("./internationalWireVerificationLocalDataHelpers");
|
|
6
|
-
exports.InternationalWireVerificationFormOrder = [
|
|
7
|
-
internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.certificateOfGoodStanding,
|
|
8
|
-
internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.businessOwnership,
|
|
9
|
-
internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.companyProofOfAddress,
|
|
10
|
-
internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.companyOfficerProofOfAddress,
|
|
11
|
-
internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.companyRegistrationDate,
|
|
12
|
-
internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.annualTurnover,
|
|
13
|
-
internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.expectedTransactionVolume,
|
|
14
|
-
internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.employeeCount,
|
|
15
|
-
internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.intendedUseOfAccount,
|
|
16
|
-
internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.transactionCountries,
|
|
17
|
-
internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.stakeHolder,
|
|
18
|
-
internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.controllingPerson,
|
|
19
|
-
];
|
|
20
|
-
const toFieldValues = (fieldValues) => fieldValues?.map(({ code, description }) => ({ code, description })) ?? [];
|
|
21
|
-
const toSubField = (subfield) => ({
|
|
22
|
-
label: subfield.label,
|
|
23
|
-
placeholder: subfield.field_hint_text ?? '',
|
|
24
|
-
type: subfield.type,
|
|
25
|
-
fieldValues: toFieldValues(subfield.field_values),
|
|
26
|
-
isMultipleOptionsSupported: subfield.is_multiple_options_supported,
|
|
27
|
-
options: subfield.options,
|
|
28
|
-
});
|
|
3
|
+
exports.toDynamicFormField = void 0;
|
|
29
4
|
const toDynamicFormField = (key, payload) => ({
|
|
30
5
|
name: key,
|
|
31
6
|
label: payload.label,
|
|
32
7
|
placeholder: payload.field_hint_text ?? '',
|
|
33
8
|
isMultipleValuesAllowed: payload.is_multiple_values_allowed ?? false,
|
|
34
9
|
type: payload.type,
|
|
35
|
-
fieldValues:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
toSubField(subfield),
|
|
44
|
-
]))
|
|
45
|
-
: undefined,
|
|
10
|
+
fieldValues: payload.field_values != null && payload.field_values.length > 0
|
|
11
|
+
? payload.field_values.map((fieldValue) => {
|
|
12
|
+
return {
|
|
13
|
+
code: fieldValue.code,
|
|
14
|
+
description: fieldValue.description,
|
|
15
|
+
};
|
|
16
|
+
})
|
|
17
|
+
: [],
|
|
46
18
|
});
|
|
47
19
|
exports.toDynamicFormField = toDynamicFormField;
|
|
48
|
-
const readonlyHideableVerificationFormFieldNames = new Set(internationalWireVerificationFieldConstants_1.InternationalWireVerificationReadonlyHideableFieldNames);
|
|
49
|
-
const filterVerificationFormFieldsForReadonlyView = (fields, localData, isReadonly) => {
|
|
50
|
-
if (!isReadonly || (0, internationalWireVerificationLocalDataHelpers_1.hasBusinessOwnershipValueInLocalData)(localData)) {
|
|
51
|
-
return fields;
|
|
52
|
-
}
|
|
53
|
-
return fields.filter((field) => !readonlyHideableVerificationFormFieldNames.has(field.name));
|
|
54
|
-
};
|
|
55
|
-
exports.filterVerificationFormFieldsForReadonlyView = filterVerificationFormFieldsForReadonlyView;
|
|
56
|
-
const sortVerificationFormFields = (fields) => {
|
|
57
|
-
const orderIndex = new Map(exports.InternationalWireVerificationFormOrder.map((name, index) => [name, index]));
|
|
58
|
-
return fields.slice().sort((a, b) => {
|
|
59
|
-
const aIndex = orderIndex.get(a.name) ?? exports.InternationalWireVerificationFormOrder.length;
|
|
60
|
-
const bIndex = orderIndex.get(b.name) ?? exports.InternationalWireVerificationFormOrder.length;
|
|
61
|
-
if (aIndex !== bIndex) {
|
|
62
|
-
return aIndex - bIndex;
|
|
63
|
-
}
|
|
64
|
-
return a.name.localeCompare(b.name);
|
|
65
|
-
});
|
|
66
|
-
};
|
|
67
|
-
exports.sortVerificationFormFields = sortVerificationFormFields;
|
|
68
|
-
const toVerificationFormFields = (internationalWireFormPayload) => (0, exports.sortVerificationFormFields)(Object.keys(internationalWireFormPayload).map((key) => (0, exports.toDynamicFormField)(key, internationalWireFormPayload[key])));
|
|
69
|
-
exports.toVerificationFormFields = toVerificationFormFields;
|
|
@@ -8,7 +8,6 @@ exports.initialState = {
|
|
|
8
8
|
verificationFormFetchState: {
|
|
9
9
|
fetchState: 'Not-Started',
|
|
10
10
|
},
|
|
11
|
-
verificationFormFieldLabels: {},
|
|
12
11
|
verificationFormFields: [],
|
|
13
12
|
verificationFormLocalData: {},
|
|
14
13
|
verificationFormSubmitState: {
|
|
@@ -36,8 +35,11 @@ const internationalWireVerification = (0, toolkit_1.createSlice)({
|
|
|
36
35
|
},
|
|
37
36
|
updateInternationalVerificationForm(draft, action) {
|
|
38
37
|
const { internationalWireFormPayload } = action.payload;
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
const verificationFormFields = [];
|
|
39
|
+
Object.keys(internationalWireFormPayload).forEach((key) => {
|
|
40
|
+
verificationFormFields.push((0, internationalWireVerificationPayload_1.toDynamicFormField)(key, internationalWireFormPayload[key]));
|
|
41
|
+
});
|
|
42
|
+
draft.verificationFormFields = verificationFormFields;
|
|
41
43
|
draft.verificationFormFetchState.fetchState = 'Completed';
|
|
42
44
|
},
|
|
43
45
|
updateVerificationFormFailure(draft, action) {
|
|
@@ -47,7 +49,6 @@ const internationalWireVerification = (0, toolkit_1.createSlice)({
|
|
|
47
49
|
},
|
|
48
50
|
updateVerificationFormLocalData(draft, action) {
|
|
49
51
|
draft.verificationFormLocalData = {
|
|
50
|
-
...draft.verificationFormLocalData,
|
|
51
52
|
...action.payload,
|
|
52
53
|
};
|
|
53
54
|
},
|
|
@@ -1,53 +1,29 @@
|
|
|
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");
|
|
5
4
|
const fileSelector_1 = require("../../../../entity/file/fileSelector");
|
|
6
|
-
const tenantSelector_1 = require("../../../../entity/tenant/tenantSelector");
|
|
7
5
|
const fileViewSelector_1 = require("../../../fileView/fileViewSelector");
|
|
8
|
-
const internationalWireVerificationPayload_1 = require("./internationalWireVerificationPayload");
|
|
9
|
-
const collectFileIdsFromLocalData = (localData) => {
|
|
10
|
-
const fileIds = new Set();
|
|
11
|
-
Object.values(localData).forEach((value) => {
|
|
12
|
-
if (typeof value === 'string' && value.startsWith('file_')) {
|
|
13
|
-
fileIds.add(value);
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
if (Array.isArray(value)) {
|
|
17
|
-
value.forEach((item) => {
|
|
18
|
-
if (typeof item === 'string' && item.startsWith('file_')) {
|
|
19
|
-
fileIds.add(item);
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
return Array.from(fileIds);
|
|
25
|
-
};
|
|
26
6
|
const getIntlWireVerificationView = (state) => {
|
|
27
7
|
const deleteFileStatusById = {};
|
|
28
8
|
const updateFileStatusById = {};
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
9
|
+
// field with type = file
|
|
10
|
+
const fileField = state.internationalWireVerificationState.verificationFormFields.find((field) => field.type === 'file');
|
|
11
|
+
let fileId;
|
|
12
|
+
if (fileField != null) {
|
|
13
|
+
fileId = state.internationalWireVerificationState.verificationFormLocalData[fileField.name];
|
|
14
|
+
}
|
|
15
|
+
if (fileId != null) {
|
|
32
16
|
deleteFileStatusById[fileId] = (0, fileViewSelector_1.getFileDeleteStatusById)(state, fileId);
|
|
33
17
|
updateFileStatusById[fileId] = (0, fileViewSelector_1.getFileUpdateNameStatusById)(state, fileId);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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);
|
|
18
|
+
}
|
|
19
|
+
let userFiles = [];
|
|
20
|
+
if (fileId != null) {
|
|
21
|
+
userFiles = (0, fileSelector_1.getFilesByFileIds)(state.fileState, [fileId]);
|
|
22
|
+
}
|
|
23
|
+
const fetchState = state.internationalWireVerificationState.verificationFormFetchState
|
|
24
|
+
.fetchState;
|
|
46
25
|
return {
|
|
47
|
-
|
|
48
|
-
verificationFormFields: visibleVerificationFormFields,
|
|
49
|
-
verificationFormLocalData,
|
|
50
|
-
verificationFormSubmitState,
|
|
26
|
+
...state.internationalWireVerificationState,
|
|
51
27
|
deleteFileStatusById,
|
|
52
28
|
updateFileStatusById,
|
|
53
29
|
userFiles,
|
|
@@ -1,29 +1,15 @@
|
|
|
1
1
|
import { FetchStateAndError } from '../../../../commonStateTypes/common';
|
|
2
|
-
import { FieldPayload } from './internationalWireVerificationPayload';
|
|
3
2
|
export interface InternationalWireVerificationState {
|
|
4
3
|
verificationFormFetchState: FetchStateAndError;
|
|
5
|
-
verificationFormFieldLabels: Record<string, FieldPayload>;
|
|
6
4
|
verificationFormFields: VerificationFormField[];
|
|
7
5
|
verificationFormLocalData: VerificationFormLocalData;
|
|
8
6
|
verificationFormSubmitState: FetchStateAndError;
|
|
9
7
|
}
|
|
10
|
-
export type
|
|
11
|
-
export type VerificationFormLocalData = Record<string, VerificationFormLocalDataValue>;
|
|
8
|
+
export type VerificationFormLocalData = Record<string, string | string[]>;
|
|
12
9
|
export interface FieldValueType {
|
|
13
10
|
code: string;
|
|
14
11
|
description: string;
|
|
15
12
|
}
|
|
16
|
-
export interface VerificationFormFieldOption {
|
|
17
|
-
label: string;
|
|
18
|
-
}
|
|
19
|
-
export interface VerificationFormSubField {
|
|
20
|
-
fieldValues: FieldValueType[];
|
|
21
|
-
label: string;
|
|
22
|
-
placeholder: string;
|
|
23
|
-
type: string;
|
|
24
|
-
isMultipleOptionsSupported?: boolean;
|
|
25
|
-
options?: Record<string, VerificationFormFieldOption>;
|
|
26
|
-
}
|
|
27
13
|
export interface VerificationFormField {
|
|
28
14
|
fieldValues: FieldValueType[];
|
|
29
15
|
isMultipleValuesAllowed: boolean;
|
|
@@ -31,9 +17,4 @@ export interface VerificationFormField {
|
|
|
31
17
|
name: string;
|
|
32
18
|
placeholder: string;
|
|
33
19
|
type: string;
|
|
34
|
-
default?: boolean;
|
|
35
|
-
isMultipleOptionsSupported?: boolean;
|
|
36
|
-
options?: Record<string, VerificationFormFieldOption>;
|
|
37
|
-
requirements?: string[];
|
|
38
|
-
subfields?: Record<string, VerificationFormSubField>;
|
|
39
20
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.1.3
|
|
3
|
+
"version": "5.1.3",
|
|
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",
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import { InternationalWireVerificationBooleanWithSubfieldsFieldNames, InternationalWireVerificationFormFieldNames, } from './internationalWireVerificationFieldConstants';
|
|
2
|
-
import { appendIntlWireFileOptionsToLocalData, appendIntlWirePersonToLocalData, isIntlWireFileOptionLike, isIntlWirePersonLike, toIntlWireFileOptionArray, } from './internationalWireVerificationLocalDataHelpers';
|
|
3
|
-
const MULTI_OPTION_FILE_FIELD_NAMES = new Set([
|
|
4
|
-
InternationalWireVerificationFormFieldNames.businessOwnership,
|
|
5
|
-
InternationalWireVerificationFormFieldNames.companyProofOfAddress,
|
|
6
|
-
InternationalWireVerificationFormFieldNames.companyOfficerProofOfAddress,
|
|
7
|
-
]);
|
|
8
|
-
const toValuesArray = (values) => {
|
|
9
|
-
if (values == null) {
|
|
10
|
-
return [];
|
|
11
|
-
}
|
|
12
|
-
if (Array.isArray(values)) {
|
|
13
|
-
return values;
|
|
14
|
-
}
|
|
15
|
-
return [values];
|
|
16
|
-
};
|
|
17
|
-
const getCodeFromValue = (value) => {
|
|
18
|
-
if (typeof value === 'string') {
|
|
19
|
-
return value;
|
|
20
|
-
}
|
|
21
|
-
if (typeof value === 'object' &&
|
|
22
|
-
value != null &&
|
|
23
|
-
'code' in value &&
|
|
24
|
-
typeof value.code === 'string') {
|
|
25
|
-
return value.code;
|
|
26
|
-
}
|
|
27
|
-
return '';
|
|
28
|
-
};
|
|
29
|
-
const setEmptyFieldDefault = (localData, fieldKey, fieldPayload) => {
|
|
30
|
-
if (fieldPayload.type === 'enum') {
|
|
31
|
-
localData[fieldKey] =
|
|
32
|
-
fieldPayload.is_multiple_values_allowed === true ? [] : '';
|
|
33
|
-
return;
|
|
34
|
-
}
|
|
35
|
-
if (fieldPayload.type === 'boolean_with_subfields') {
|
|
36
|
-
if (fieldKey ===
|
|
37
|
-
InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder) {
|
|
38
|
-
localData[fieldKey] = 'false';
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
if (fieldKey ===
|
|
42
|
-
InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson) {
|
|
43
|
-
localData[fieldKey] = fieldPayload.default === true ? 'true' : 'false';
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
const parseEnumValues = (localData, fieldKey, fieldPayload, values) => {
|
|
48
|
-
if (fieldPayload.is_multiple_values_allowed === true) {
|
|
49
|
-
localData[fieldKey] = values
|
|
50
|
-
.map(getCodeFromValue)
|
|
51
|
-
.filter((code) => code.length > 0);
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
localData[fieldKey] = getCodeFromValue(values[0]);
|
|
55
|
-
};
|
|
56
|
-
const parseFileValues = (localData, fieldKey, fieldPayload, values) => {
|
|
57
|
-
if (values.length > 0 &&
|
|
58
|
-
(isIntlWireFileOptionLike(values[0]) ||
|
|
59
|
-
MULTI_OPTION_FILE_FIELD_NAMES.has(fieldKey))) {
|
|
60
|
-
const fileOptions = toIntlWireFileOptionArray(values);
|
|
61
|
-
if (fileOptions.length > 0) {
|
|
62
|
-
appendIntlWireFileOptionsToLocalData(localData, fieldKey, fileOptions);
|
|
63
|
-
}
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
const fileIds = values.filter((value) => typeof value === 'string' && value.length > 0);
|
|
67
|
-
if (fieldPayload.is_multiple_values_allowed === true) {
|
|
68
|
-
localData[fieldKey] = fileIds;
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
localData[fieldKey] = fileIds[0] ?? '';
|
|
72
|
-
};
|
|
73
|
-
const parseBooleanWithSubfieldsValues = (localData, fieldKey, fieldPayload, rawValues) => {
|
|
74
|
-
if (fieldKey ===
|
|
75
|
-
InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson) {
|
|
76
|
-
if (isIntlWirePersonLike(rawValues)) {
|
|
77
|
-
localData[fieldKey] = 'false';
|
|
78
|
-
appendIntlWirePersonToLocalData(localData, fieldKey, rawValues);
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
const values = toValuesArray(rawValues);
|
|
82
|
-
if (values.length > 0 && isIntlWirePersonLike(values[0])) {
|
|
83
|
-
localData[fieldKey] = 'false';
|
|
84
|
-
appendIntlWirePersonToLocalData(localData, fieldKey, values[0]);
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
const selection = getCodeFromValue(values[0]);
|
|
88
|
-
localData[fieldKey] =
|
|
89
|
-
selection.length > 0
|
|
90
|
-
? selection
|
|
91
|
-
: fieldPayload.default === true
|
|
92
|
-
? 'true'
|
|
93
|
-
: 'false';
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
if (fieldKey ===
|
|
97
|
-
InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder) {
|
|
98
|
-
const values = toValuesArray(rawValues);
|
|
99
|
-
if (values.length > 0 && isIntlWirePersonLike(values[0])) {
|
|
100
|
-
localData[fieldKey] = 'true';
|
|
101
|
-
values.forEach((person, ownerIndex) => {
|
|
102
|
-
if (isIntlWirePersonLike(person)) {
|
|
103
|
-
appendIntlWirePersonToLocalData(localData, `${fieldKey}_${ownerIndex}`, person);
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
const selection = getCodeFromValue(values[0]);
|
|
109
|
-
localData[fieldKey] = selection.length > 0 ? selection : 'false';
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
export const toVerificationFormLocalDataFromOnboardingDetails = (onboardingDetails, internationalWireFormPayload) => {
|
|
113
|
-
const localData = {};
|
|
114
|
-
Object.keys(internationalWireFormPayload).forEach((fieldKey) => {
|
|
115
|
-
const fieldPayload = internationalWireFormPayload[fieldKey];
|
|
116
|
-
const rawValues = onboardingDetails?.[fieldKey]?.values;
|
|
117
|
-
if (rawValues == null) {
|
|
118
|
-
setEmptyFieldDefault(localData, fieldKey, fieldPayload);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
if (fieldPayload.type === 'boolean_with_subfields') {
|
|
122
|
-
parseBooleanWithSubfieldsValues(localData, fieldKey, fieldPayload, rawValues);
|
|
123
|
-
return;
|
|
124
|
-
}
|
|
125
|
-
const values = toValuesArray(rawValues);
|
|
126
|
-
if (values.length === 0) {
|
|
127
|
-
setEmptyFieldDefault(localData, fieldKey, fieldPayload);
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
switch (fieldPayload.type) {
|
|
131
|
-
case 'enum':
|
|
132
|
-
parseEnumValues(localData, fieldKey, fieldPayload, values);
|
|
133
|
-
break;
|
|
134
|
-
case 'file':
|
|
135
|
-
parseFileValues(localData, fieldKey, fieldPayload, values);
|
|
136
|
-
break;
|
|
137
|
-
case 'date':
|
|
138
|
-
localData[fieldKey] = getCodeFromValue(values[0]);
|
|
139
|
-
break;
|
|
140
|
-
default:
|
|
141
|
-
localData[fieldKey] = getCodeFromValue(values[0]);
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
});
|
|
145
|
-
return localData;
|
|
146
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export const InternationalWireVerificationFormFieldNames = {
|
|
2
|
-
certificateOfGoodStanding: 'certificate_of_good_standing',
|
|
3
|
-
businessOwnership: 'business_ownership',
|
|
4
|
-
companyProofOfAddress: 'company_proof_of_address',
|
|
5
|
-
companyOfficerProofOfAddress: 'company_officer_proof_of_address',
|
|
6
|
-
companyRegistrationDate: 'company_registration_date',
|
|
7
|
-
annualTurnover: 'annual_turnover',
|
|
8
|
-
expectedTransactionVolume: 'expected_transaction_volume',
|
|
9
|
-
employeeCount: 'employee_count',
|
|
10
|
-
intendedUseOfAccount: 'intended_use_of_account',
|
|
11
|
-
transactionCountries: 'transaction_countries',
|
|
12
|
-
stakeHolder: 'stake_holder',
|
|
13
|
-
controllingPerson: 'controlling_person',
|
|
14
|
-
};
|
|
15
|
-
export const InternationalWireVerificationStakeHolderFieldName = InternationalWireVerificationFormFieldNames.stakeHolder;
|
|
16
|
-
export const InternationalWireVerificationControllingPersonFieldName = InternationalWireVerificationFormFieldNames.controllingPerson;
|
|
17
|
-
export const InternationalWireVerificationBooleanWithSubfieldsFieldNames = {
|
|
18
|
-
stakeHolder: InternationalWireVerificationStakeHolderFieldName,
|
|
19
|
-
controllingPerson: InternationalWireVerificationControllingPersonFieldName,
|
|
20
|
-
};
|
|
21
|
-
export const InternationalWireVerificationBooleanWithSubfieldsFieldNameList = Object.values(InternationalWireVerificationBooleanWithSubfieldsFieldNames);
|
|
22
|
-
export const InternationalWireVerificationSubfieldNames = {
|
|
23
|
-
companyRole: 'company_role',
|
|
24
|
-
dateOfBirth: 'date_of_birth',
|
|
25
|
-
name: 'name',
|
|
26
|
-
email: 'email',
|
|
27
|
-
nationality: 'nationality',
|
|
28
|
-
ownershipPercentage: 'ownership_percentage',
|
|
29
|
-
proofOfIdentity: 'proof_of_identity',
|
|
30
|
-
proofOfAddress: 'proof_of_address',
|
|
31
|
-
ssn: 'ssn',
|
|
32
|
-
};
|
|
33
|
-
export const InternationalWireVerificationReadonlyHideableFieldNames = [
|
|
34
|
-
InternationalWireVerificationFormFieldNames.stakeHolder,
|
|
35
|
-
InternationalWireVerificationFormFieldNames.controllingPerson,
|
|
36
|
-
InternationalWireVerificationFormFieldNames.businessOwnership,
|
|
37
|
-
InternationalWireVerificationFormFieldNames.companyProofOfAddress,
|
|
38
|
-
InternationalWireVerificationFormFieldNames.companyOfficerProofOfAddress,
|
|
39
|
-
];
|
|
40
|
-
export const InternationalWireVerificationReadonlyVisibilityGateFieldName = InternationalWireVerificationFormFieldNames.businessOwnership;
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { InternationalWireVerificationFormFieldNames, InternationalWireVerificationSubfieldNames, } from './internationalWireVerificationFieldConstants';
|
|
2
|
-
import { IntlWireVerificationLocalDataSuffix } from './internationalWireVerificationSubmitPayload';
|
|
3
|
-
export const isIntlWireFileOptionLike = (value) => typeof value === 'object' &&
|
|
4
|
-
value != null &&
|
|
5
|
-
'file_id' in value &&
|
|
6
|
-
typeof value.file_id === 'string';
|
|
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
|
-
};
|
|
22
|
-
export const toIntlWireFileOptionArray = (items) => items.filter(isIntlWireFileOptionLike);
|
|
23
|
-
export const appendIntlWireFileOptionsToLocalData = (localData, baseKey, fileOptions) => {
|
|
24
|
-
const [front, back] = fileOptions;
|
|
25
|
-
if (front?.file_id != null && front.file_id !== '') {
|
|
26
|
-
localData[baseKey] = front.file_id;
|
|
27
|
-
if (front.option != null && front.option !== '') {
|
|
28
|
-
localData[`${baseKey}${IntlWireVerificationLocalDataSuffix.documentOption}`] = front.option;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
if (back?.file_id != null && back.file_id !== '') {
|
|
32
|
-
localData[`${baseKey}${IntlWireVerificationLocalDataSuffix.documentBack}`] =
|
|
33
|
-
back.file_id;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
export const appendIntlWirePersonToLocalData = (localData, keyPrefix, person) => {
|
|
37
|
-
const nameBaseKey = `${keyPrefix}_${InternationalWireVerificationSubfieldNames.name}`;
|
|
38
|
-
if (person.name?.first_name != null) {
|
|
39
|
-
localData[`${nameBaseKey}${IntlWireVerificationLocalDataSuffix.nameFirst}`] = person.name.first_name;
|
|
40
|
-
}
|
|
41
|
-
if (person.name?.last_name != null) {
|
|
42
|
-
localData[`${nameBaseKey}${IntlWireVerificationLocalDataSuffix.nameLast}`] = person.name.last_name;
|
|
43
|
-
}
|
|
44
|
-
const assignStringField = (subfieldName, fieldValue) => {
|
|
45
|
-
if (fieldValue != null && fieldValue !== '') {
|
|
46
|
-
localData[`${keyPrefix}_${subfieldName}`] = fieldValue;
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
assignStringField(InternationalWireVerificationSubfieldNames.nationality, person.nationality);
|
|
50
|
-
assignStringField(InternationalWireVerificationSubfieldNames.email, person.email);
|
|
51
|
-
assignStringField(InternationalWireVerificationSubfieldNames.companyRole, person.company_role);
|
|
52
|
-
assignStringField(InternationalWireVerificationSubfieldNames.ssn, person.ssn);
|
|
53
|
-
assignStringField(InternationalWireVerificationSubfieldNames.dateOfBirth, person.date_of_birth);
|
|
54
|
-
if (person.ownership_percentage != null) {
|
|
55
|
-
localData[`${keyPrefix}_${InternationalWireVerificationSubfieldNames.ownershipPercentage}`] = person.ownership_percentage;
|
|
56
|
-
}
|
|
57
|
-
if (person.proof_of_identity != null) {
|
|
58
|
-
appendIntlWireFileOptionsToLocalData(localData, `${keyPrefix}_${InternationalWireVerificationSubfieldNames.proofOfIdentity}`, toIntlWireFileOptionArray(person.proof_of_identity));
|
|
59
|
-
}
|
|
60
|
-
if (person.proof_of_address != null) {
|
|
61
|
-
appendIntlWireFileOptionsToLocalData(localData, `${keyPrefix}_${InternationalWireVerificationSubfieldNames.proofOfAddress}`, toIntlWireFileOptionArray(person.proof_of_address));
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
export const getStakeHolderOwnerIndicesFromLocalData = (localData) => {
|
|
65
|
-
const indices = new Set();
|
|
66
|
-
Object.keys(localData).forEach((key) => {
|
|
67
|
-
const match = key.match(/^stake_holder_(\d+)_/);
|
|
68
|
-
if (match != null) {
|
|
69
|
-
indices.add(Number.parseInt(match[1], 10));
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
return Array.from(indices).sort((a, b) => a - b);
|
|
73
|
-
};
|
|
74
|
-
export const hasBusinessOwnershipValueInLocalData = (localData) => {
|
|
75
|
-
const baseKey = InternationalWireVerificationFormFieldNames.businessOwnership;
|
|
76
|
-
const frontFileId = localData[baseKey];
|
|
77
|
-
if (typeof frontFileId === 'string' && frontFileId !== '') {
|
|
78
|
-
return true;
|
|
79
|
-
}
|
|
80
|
-
const backFileId = localData[`${baseKey}${IntlWireVerificationLocalDataSuffix.documentBack}`];
|
|
81
|
-
if (typeof backFileId === 'string' && backFileId !== '') {
|
|
82
|
-
return true;
|
|
83
|
-
}
|
|
84
|
-
const documentOption = localData[`${baseKey}${IntlWireVerificationLocalDataSuffix.documentOption}`];
|
|
85
|
-
return typeof documentOption === 'string' && documentOption !== '';
|
|
86
|
-
};
|