@zeniai/client-epic-state 5.0.90-betaAS5 → 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/internationalWireVerificationLocalDataHelpers.js +25 -1
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +16 -0
- package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +13 -1
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.d.ts +2 -0
- package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.js +26 -1
- 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/internationalWireVerificationSelector.js +13 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
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 &&
|
|
@@ -61,6 +61,30 @@ export const appendIntlWirePersonToLocalData = (localData, keyPrefix, person) =>
|
|
|
61
61
|
appendIntlWireFileOptionsToLocalData(localData, `${keyPrefix}_${InternationalWireVerificationSubfieldNames.proofOfAddress}`, toIntlWireFileOptionArray(person.proof_of_address));
|
|
62
62
|
}
|
|
63
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
|
+
};
|
|
64
88
|
export const getStakeHolderOwnerIndicesFromLocalData = (localData) => {
|
|
65
89
|
const indices = new Set();
|
|
66
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) => {
|
|
@@ -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) => {
|
|
@@ -28,9 +31,18 @@ export const getIntlWireVerificationView = (state) => {
|
|
|
28
31
|
});
|
|
29
32
|
const userFiles = fileIds.length > 0 ? getFilesByFileIds(state.fileState, fileIds) : [];
|
|
30
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);
|
|
31
43
|
return {
|
|
32
44
|
verificationFormFetchState,
|
|
33
|
-
verificationFormFields,
|
|
45
|
+
verificationFormFields: visibleVerificationFormFields,
|
|
34
46
|
verificationFormLocalData,
|
|
35
47
|
verificationFormSubmitState,
|
|
36
48
|
deleteFileStatusById,
|
|
@@ -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' &&
|
|
@@ -69,6 +69,31 @@ const appendIntlWirePersonToLocalData = (localData, keyPrefix, person) => {
|
|
|
69
69
|
}
|
|
70
70
|
};
|
|
71
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;
|
|
72
97
|
const getStakeHolderOwnerIndicesFromLocalData = (localData) => {
|
|
73
98
|
const indices = new Set();
|
|
74
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) => {
|
|
@@ -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) => {
|
|
@@ -31,9 +34,18 @@ const getIntlWireVerificationView = (state) => {
|
|
|
31
34
|
});
|
|
32
35
|
const userFiles = fileIds.length > 0 ? (0, fileSelector_1.getFilesByFileIds)(state.fileState, fileIds) : [];
|
|
33
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);
|
|
34
46
|
return {
|
|
35
47
|
verificationFormFetchState,
|
|
36
|
-
verificationFormFields,
|
|
48
|
+
verificationFormFields: visibleVerificationFormFields,
|
|
37
49
|
verificationFormLocalData,
|
|
38
50
|
verificationFormSubmitState,
|
|
39
51
|
deleteFileStatusById,
|
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",
|