@zeniai/client-epic-state 5.0.90-betaAS10 → 5.0.90-betaAS2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/lib/commonPayloadTypes/commonPayload.d.ts +4 -25
  2. package/lib/esm/index.js +1 -4
  3. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.js +3 -7
  4. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +41 -33
  5. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/submitIntlVerificationEpic.js +7 -2
  6. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.js +0 -8
  7. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +1 -9
  8. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +0 -3
  9. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +7 -20
  10. package/lib/index.d.ts +1 -4
  11. package/lib/index.js +7 -15
  12. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.d.ts +3 -3
  13. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.js +2 -6
  14. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.d.ts +1 -2
  15. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +40 -32
  16. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/submitIntlVerificationEpic.js +7 -2
  17. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.d.ts +0 -3
  18. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.js +1 -9
  19. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.d.ts +1 -2
  20. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +1 -10
  21. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +0 -3
  22. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +7 -20
  23. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationState.d.ts +1 -4
  24. package/package.json +1 -1
  25. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.js +0 -146
  26. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.js +0 -86
  27. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.js +0 -154
  28. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.d.ts +0 -4
  29. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.js +0 -150
  30. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.d.ts +0 -27
  31. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.js +0 -96
  32. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.d.ts +0 -32
  33. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.js +0 -159
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InternationalWireVerificationReadonlyVisibilityGateFieldName = exports.InternationalWireVerificationReadonlyHideableFieldNames = exports.InternationalWireVerificationSubfieldNames = exports.InternationalWireVerificationBooleanWithSubfieldsFieldNameList = exports.InternationalWireVerificationBooleanWithSubfieldsFieldNames = exports.InternationalWireVerificationControllingPersonFieldName = exports.InternationalWireVerificationStakeHolderFieldName = exports.InternationalWireVerificationFormFieldNames = void 0;
3
+ exports.InternationalWireVerificationSubfieldNames = exports.InternationalWireVerificationBooleanWithSubfieldsFieldNameList = exports.InternationalWireVerificationBooleanWithSubfieldsFieldNames = exports.InternationalWireVerificationControllingPersonFieldName = exports.InternationalWireVerificationStakeHolderFieldName = exports.InternationalWireVerificationFormFieldNames = void 0;
4
4
  exports.InternationalWireVerificationFormFieldNames = {
5
5
  certificateOfGoodStanding: 'certificate_of_good_standing',
6
6
  businessOwnership: 'business_ownership',
@@ -33,11 +33,3 @@ exports.InternationalWireVerificationSubfieldNames = {
33
33
  proofOfAddress: 'proof_of_address',
34
34
  ssn: 'ssn',
35
35
  };
36
- exports.InternationalWireVerificationReadonlyHideableFieldNames = [
37
- exports.InternationalWireVerificationFormFieldNames.stakeHolder,
38
- exports.InternationalWireVerificationFormFieldNames.controllingPerson,
39
- exports.InternationalWireVerificationFormFieldNames.businessOwnership,
40
- exports.InternationalWireVerificationFormFieldNames.companyProofOfAddress,
41
- exports.InternationalWireVerificationFormFieldNames.companyOfficerProofOfAddress,
42
- ];
43
- exports.InternationalWireVerificationReadonlyVisibilityGateFieldName = exports.InternationalWireVerificationFormFieldNames.businessOwnership;
@@ -1,6 +1,6 @@
1
1
  import { AllowedValueWithCode } from '../../../../commonStateTypes/allowedValue';
2
2
  import { ZeniAPIResponse } from '../../../../responsePayload';
3
- import { VerificationFormField, VerificationFormLocalData } from './internationalWireVerificationState';
3
+ import { VerificationFormField } 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,7 +32,6 @@ 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[];
36
35
  export declare const sortVerificationFormFields: (fields: VerificationFormField[]) => VerificationFormField[];
37
36
  export declare const toVerificationFormFields: (internationalWireFormPayload: Record<string, FieldPayload>) => VerificationFormField[];
38
37
  export type IntlVerificationFormResponse = ZeniAPIResponse<IntlVerificationFormPayload>;
@@ -1,8 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toVerificationFormFields = exports.sortVerificationFormFields = exports.filterVerificationFormFieldsForReadonlyView = exports.toDynamicFormField = exports.InternationalWireVerificationFormOrder = void 0;
3
+ exports.toVerificationFormFields = exports.sortVerificationFormFields = exports.toDynamicFormField = exports.InternationalWireVerificationFormOrder = void 0;
4
4
  const internationalWireVerificationFieldConstants_1 = require("./internationalWireVerificationFieldConstants");
5
- const internationalWireVerificationLocalDataHelpers_1 = require("./internationalWireVerificationLocalDataHelpers");
6
5
  exports.InternationalWireVerificationFormOrder = [
7
6
  internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.certificateOfGoodStanding,
8
7
  internationalWireVerificationFieldConstants_1.InternationalWireVerificationFormFieldNames.businessOwnership,
@@ -45,14 +44,6 @@ const toDynamicFormField = (key, payload) => ({
45
44
  : undefined,
46
45
  });
47
46
  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
47
  const sortVerificationFormFields = (fields) => {
57
48
  const orderIndex = new Map(exports.InternationalWireVerificationFormOrder.map((name, index) => [name, index]));
58
49
  return fields.slice().sort((a, b) => {
@@ -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,7 +35,6 @@ const internationalWireVerification = (0, toolkit_1.createSlice)({
36
35
  },
37
36
  updateInternationalVerificationForm(draft, action) {
38
37
  const { internationalWireFormPayload } = action.payload;
39
- draft.verificationFormFieldLabels = internationalWireFormPayload;
40
38
  draft.verificationFormFields = (0, internationalWireVerificationPayload_1.toVerificationFormFields)(internationalWireFormPayload);
41
39
  draft.verificationFormFetchState.fetchState = 'Completed';
42
40
  },
@@ -47,7 +45,6 @@ const internationalWireVerification = (0, toolkit_1.createSlice)({
47
45
  },
48
46
  updateVerificationFormLocalData(draft, action) {
49
47
  draft.verificationFormLocalData = {
50
- ...draft.verificationFormLocalData,
51
48
  ...action.payload,
52
49
  };
53
50
  },
@@ -1,11 +1,8 @@
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
6
  const collectFileIdsFromLocalData = (localData) => {
10
7
  const fileIds = new Set();
11
8
  Object.values(localData).forEach((value) => {
@@ -26,28 +23,18 @@ const collectFileIdsFromLocalData = (localData) => {
26
23
  const getIntlWireVerificationView = (state) => {
27
24
  const deleteFileStatusById = {};
28
25
  const updateFileStatusById = {};
29
- const { verificationFormFetchState, verificationFormFields, verificationFormLocalData, verificationFormSubmitState, } = state.internationalWireVerificationState;
30
- const fileIds = collectFileIdsFromLocalData(verificationFormLocalData);
26
+ const fileIds = collectFileIdsFromLocalData(state.internationalWireVerificationState.verificationFormLocalData);
31
27
  fileIds.forEach((fileId) => {
32
28
  deleteFileStatusById[fileId] = (0, fileViewSelector_1.getFileDeleteStatusById)(state, fileId);
33
29
  updateFileStatusById[fileId] = (0, fileViewSelector_1.getFileUpdateNameStatusById)(state, fileId);
34
30
  });
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);
31
+ const userFiles = fileIds.length > 0
32
+ ? (0, fileSelector_1.getFilesByFileIds)(state.fileState, fileIds)
33
+ : [];
34
+ const fetchState = state.internationalWireVerificationState.verificationFormFetchState
35
+ .fetchState;
46
36
  return {
47
- verificationFormFetchState,
48
- verificationFormFields: visibleVerificationFormFields,
49
- verificationFormLocalData,
50
- verificationFormSubmitState,
37
+ ...state.internationalWireVerificationState,
51
38
  deleteFileStatusById,
52
39
  updateFileStatusById,
53
40
  userFiles,
@@ -1,14 +1,11 @@
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 VerificationFormLocalDataValue = string | string[] | number;
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.0.90-betaAS10",
3
+ "version": "5.0.90-betaAS2",
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,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
- };
@@ -1,154 +0,0 @@
1
- import { InternationalWireVerificationBooleanWithSubfieldsFieldNames, InternationalWireVerificationFormFieldNames, InternationalWireVerificationSubfieldNames, } from './internationalWireVerificationFieldConstants';
2
- export const IntlWireVerificationLocalDataSuffix = {
3
- documentOption: '_option',
4
- documentBack: '_back',
5
- nameFirst: '_first_name',
6
- nameLast: '_last_name',
7
- };
8
- const MULTI_OPTION_FILE_FIELD_NAMES = new Set([
9
- InternationalWireVerificationFormFieldNames.businessOwnership,
10
- InternationalWireVerificationFormFieldNames.companyProofOfAddress,
11
- InternationalWireVerificationFormFieldNames.companyOfficerProofOfAddress,
12
- ]);
13
- const BOOLEAN_WITH_SUBFIELDS_FIELD_NAMES = new Set([
14
- InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder,
15
- InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson,
16
- ]);
17
- const FILE_SUBFIELD_NAMES = new Set([
18
- InternationalWireVerificationSubfieldNames.proofOfIdentity,
19
- InternationalWireVerificationSubfieldNames.proofOfAddress,
20
- ]);
21
- const isInternalLocalDataKey = (key) => key.endsWith(IntlWireVerificationLocalDataSuffix.documentOption) ||
22
- key.endsWith(IntlWireVerificationLocalDataSuffix.documentBack) ||
23
- key.endsWith(IntlWireVerificationLocalDataSuffix.nameFirst) ||
24
- key.endsWith(IntlWireVerificationLocalDataSuffix.nameLast);
25
- const isPersonSubfieldKey = (key) => key.startsWith(`${InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder}_`) ||
26
- key.startsWith(`${InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson}_`);
27
- const toFileOptionPayloads = (localData, baseKey) => {
28
- const option = localData[`${baseKey}${IntlWireVerificationLocalDataSuffix.documentOption}`];
29
- if (typeof option !== 'string' || option.length === 0) {
30
- return undefined;
31
- }
32
- const payloads = [];
33
- const frontFileId = localData[baseKey];
34
- if (typeof frontFileId === 'string' && frontFileId.length > 0) {
35
- payloads.push({ file_id: frontFileId, option });
36
- }
37
- const backFileId = localData[`${baseKey}${IntlWireVerificationLocalDataSuffix.documentBack}`];
38
- if (typeof backFileId === 'string' && backFileId.length > 0) {
39
- payloads.push({ file_id: backFileId, option });
40
- }
41
- return payloads.length > 0 ? payloads : undefined;
42
- };
43
- const buildPersonPayload = (localData, keyPrefix) => {
44
- const person = {};
45
- const nameBaseKey = `${keyPrefix}_${InternationalWireVerificationSubfieldNames.name}`;
46
- const firstName = localData[`${nameBaseKey}${IntlWireVerificationLocalDataSuffix.nameFirst}`];
47
- const lastName = localData[`${nameBaseKey}${IntlWireVerificationLocalDataSuffix.nameLast}`];
48
- if (typeof firstName === 'string' || typeof lastName === 'string') {
49
- person.name = {
50
- first_name: typeof firstName === 'string' ? firstName : '',
51
- last_name: typeof lastName === 'string' ? lastName : '',
52
- };
53
- }
54
- const assignStringField = (subfieldName, assign) => {
55
- const value = localData[`${keyPrefix}_${subfieldName}`];
56
- if (typeof value === 'string' && value.length > 0) {
57
- assign(value);
58
- }
59
- };
60
- assignStringField(InternationalWireVerificationSubfieldNames.nationality, (value) => {
61
- person.nationality = value;
62
- });
63
- assignStringField(InternationalWireVerificationSubfieldNames.email, (value) => {
64
- person.email = value;
65
- });
66
- assignStringField(InternationalWireVerificationSubfieldNames.companyRole, (value) => {
67
- person.company_role = value;
68
- });
69
- assignStringField(InternationalWireVerificationSubfieldNames.ssn, (value) => {
70
- person.ssn = value;
71
- });
72
- assignStringField(InternationalWireVerificationSubfieldNames.dateOfBirth, (value) => {
73
- person.date_of_birth = value;
74
- });
75
- const ownershipValue = localData[`${keyPrefix}_${InternationalWireVerificationSubfieldNames.ownershipPercentage}`];
76
- if (ownershipValue != null && ownershipValue !== '') {
77
- person.ownership_percentage = Number(ownershipValue);
78
- }
79
- FILE_SUBFIELD_NAMES.forEach((subfieldName) => {
80
- const filePayloads = toFileOptionPayloads(localData, `${keyPrefix}_${subfieldName}`);
81
- if (filePayloads != null) {
82
- if (subfieldName ===
83
- InternationalWireVerificationSubfieldNames.proofOfIdentity) {
84
- person.proof_of_identity = filePayloads;
85
- }
86
- else {
87
- person.proof_of_address = filePayloads;
88
- }
89
- }
90
- });
91
- return person;
92
- };
93
- const getStakeHolderOwnerIndices = (localData) => {
94
- const stakeHolderPrefix = `${InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder}_`;
95
- const indices = new Set();
96
- Object.keys(localData).forEach((key) => {
97
- const match = key.match(/^stake_holder_(\d+)_/);
98
- if (match != null) {
99
- indices.add(Number.parseInt(match[1], 10));
100
- }
101
- });
102
- if (indices.size === 0) {
103
- const hasUnindexedStakeHolderData = Object.keys(localData).some((key) => key.startsWith(stakeHolderPrefix) &&
104
- !/^stake_holder_(true|false)$/.test(key));
105
- if (hasUnindexedStakeHolderData) {
106
- indices.add(0);
107
- }
108
- }
109
- return Array.from(indices).sort((a, b) => a - b);
110
- };
111
- const hasPersonPayloadData = (person) => Object.keys(person).length > 0;
112
- export const toIntlWireVerificationFormDetails = (localData) => {
113
- const formDetails = {};
114
- Object.entries(localData).forEach(([key, value]) => {
115
- if (BOOLEAN_WITH_SUBFIELDS_FIELD_NAMES.has(key) ||
116
- isInternalLocalDataKey(key) ||
117
- isPersonSubfieldKey(key)) {
118
- return;
119
- }
120
- if (MULTI_OPTION_FILE_FIELD_NAMES.has(key)) {
121
- const filePayloads = toFileOptionPayloads(localData, key);
122
- if (filePayloads != null) {
123
- formDetails[key] = filePayloads;
124
- }
125
- return;
126
- }
127
- if (value == null || value === '') {
128
- return;
129
- }
130
- formDetails[key] = value;
131
- });
132
- const stakeHolderSelection = localData[InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder];
133
- if (stakeHolderSelection === 'true') {
134
- formDetails[InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder] = getStakeHolderOwnerIndices(localData)
135
- .map((ownerIndex) => buildPersonPayload(localData, `${InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder}_${ownerIndex}`))
136
- .filter(hasPersonPayloadData);
137
- }
138
- else if (stakeHolderSelection === 'false') {
139
- formDetails[InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder] = [];
140
- }
141
- const controllingPersonSelection = localData[InternationalWireVerificationBooleanWithSubfieldsFieldNames
142
- .controllingPerson];
143
- if (controllingPersonSelection === 'false') {
144
- const controllingPerson = buildPersonPayload(localData, InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson);
145
- if (hasPersonPayloadData(controllingPerson)) {
146
- formDetails[InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson] = controllingPerson;
147
- }
148
- }
149
- return formDetails;
150
- };
151
- export const toIntlWireVerificationSubmitPayload = (localData) => ({
152
- is_applicant_declaration: true,
153
- form_details: toIntlWireVerificationFormDetails(localData),
154
- });
@@ -1,4 +0,0 @@
1
- import { LabelValueCodesPayload } from '../../../../commonPayloadTypes/commonPayload';
2
- import { FieldPayload } from './internationalWireVerificationPayload';
3
- import { VerificationFormLocalData } from './internationalWireVerificationState';
4
- export declare const toVerificationFormLocalDataFromOnboardingDetails: (onboardingDetails: Record<string, LabelValueCodesPayload> | undefined, internationalWireFormPayload: Record<string, FieldPayload>) => VerificationFormLocalData;