@zeniai/client-epic-state 5.1.3-betaAS1 → 5.1.3-betaVR1

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 (40) hide show
  1. package/lib/commonPayloadTypes/commonPayload.d.ts +4 -25
  2. package/lib/esm/index.js +4 -8
  3. package/lib/esm/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +200 -0
  4. package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +96 -2
  5. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.js +3 -7
  6. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +34 -33
  7. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/submitIntlVerificationEpic.js +7 -2
  8. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +8 -55
  9. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +6 -5
  10. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +15 -39
  11. package/lib/index.d.ts +6 -11
  12. package/lib/index.js +41 -54
  13. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.d.ts +36 -1
  14. package/lib/view/expenseAutomationView/helpers/transactionCategorizationLocalDataHelper.js +205 -1
  15. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.d.ts +28 -2
  16. package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +96 -2
  17. package/lib/view/expenseAutomationView/types/transactionsViewState.d.ts +39 -0
  18. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.d.ts +3 -3
  19. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.js +2 -6
  20. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.d.ts +1 -2
  21. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +33 -32
  22. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/submitIntlVerificationEpic.js +7 -2
  23. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.d.ts +1 -24
  24. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +9 -59
  25. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +5 -4
  26. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +15 -39
  27. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationState.d.ts +1 -20
  28. package/package.json +2 -2
  29. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.js +0 -146
  30. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.js +0 -40
  31. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.js +0 -86
  32. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.js +0 -154
  33. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.d.ts +0 -4
  34. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.js +0 -150
  35. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.d.ts +0 -38
  36. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.js +0 -43
  37. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.d.ts +0 -27
  38. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.js +0 -96
  39. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.d.ts +0 -32
  40. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.js +0 -159
@@ -1,69 +1,19 @@
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;
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: toFieldValues(payload.field_values),
36
- isMultipleOptionsSupported: payload.is_multiple_options_supported,
37
- options: payload.options,
38
- requirements: payload.requirements,
39
- default: payload.default,
40
- subfields: payload.subfields != null
41
- ? Object.fromEntries(Object.entries(payload.subfields).map(([subfieldKey, subfield]) => [
42
- subfieldKey,
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
- draft.verificationFormFieldLabels = internationalWireFormPayload;
40
- draft.verificationFormFields = (0, internationalWireVerificationPayload_1.toVerificationFormFields)(internationalWireFormPayload);
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
- const { verificationFormFetchState, verificationFormFields, verificationFormLocalData, verificationFormSubmitState, } = state.internationalWireVerificationState;
30
- const fileIds = collectFileIdsFromLocalData(verificationFormLocalData);
31
- fileIds.forEach((fileId) => {
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
- 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);
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
- verificationFormFetchState,
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 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;
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-betaAS1",
3
+ "version": "5.1.3-betaVR1",
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",
@@ -117,7 +117,7 @@
117
117
  "find-dead-code": "ts-prune | grep -v '(used in module)'",
118
118
  "find-unused-exports": "ts-unused-exports ./tsconfig.json",
119
119
  "circular-dependency": "npx madge --circular --extensions ts ./src",
120
- "build": "concurrently --kill-others-on-fail --handle-input \"echo 'TypeScript build in progress...' && time tsc && echo 'ESM build...' && tsc -p tsconfig.esm.json\" \"echo 'Running tests and typecheck (incl. lint-modified-files)...' && pnpm test\" && rimraf \"lib/**/__mocks__\" \"lib/**/__testHelpers__\"",
120
+ "build": "concurrently --kill-others-on-fail --handle-input \"echo 'TypeScript build in progress...' && time tsc && echo 'ESM build...' && tsc -p tsconfig.esm.json\"",
121
121
  "only-build": "eslint . --ext .js,.jsx,.ts,.tsx && time tsc && tsc -p tsconfig.esm.json && rimraf \"lib/**/__mocks__\" \"lib/**/__testHelpers__\"",
122
122
  "only-build-dev": "eslint . --ext .js,.jsx,.ts,.tsx && time tsc -p tsconfig.dev.json && tsc -p tsconfig.esm.dev.json && rimraf \"lib/**/__mocks__\" \"lib/**/__testHelpers__\"",
123
123
  "format": "prettier --write --ignore-unknown \"src/**/*\" && pnpm lint",
@@ -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
- };