@zeniai/client-epic-state 5.1.68-beta0RR → 5.1.68-betaDI0

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 (44) hide show
  1. package/lib/commonPayloadTypes/commonPayload.d.ts +4 -25
  2. package/lib/esm/index.js +3 -8
  3. package/lib/esm/view/notificationPreferencesView/notificationPreferencesViewPayload.js +7 -2
  4. package/lib/esm/view/notificationPreferencesView/notificationPreferencesViewReducer.js +47 -2
  5. package/lib/esm/view/notificationPreferencesView/notificationPreferencesViewSelector.js +9 -0
  6. package/lib/esm/view/notificationPreferencesView/notificationPreferencesViewState.js +1 -0
  7. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.js +3 -7
  8. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +34 -56
  9. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/submitIntlVerificationEpic.js +7 -2
  10. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +8 -55
  11. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +7 -23
  12. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +15 -39
  13. package/lib/index.d.ts +4 -10
  14. package/lib/index.js +15 -32
  15. package/lib/view/notificationPreferencesView/notificationPreferencesViewPayload.d.ts +1 -0
  16. package/lib/view/notificationPreferencesView/notificationPreferencesViewPayload.js +7 -2
  17. package/lib/view/notificationPreferencesView/notificationPreferencesViewReducer.d.ts +6 -1
  18. package/lib/view/notificationPreferencesView/notificationPreferencesViewReducer.js +48 -3
  19. package/lib/view/notificationPreferencesView/notificationPreferencesViewSelector.js +9 -0
  20. package/lib/view/notificationPreferencesView/notificationPreferencesViewState.d.ts +1 -0
  21. package/lib/view/notificationPreferencesView/notificationPreferencesViewState.js +1 -0
  22. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.d.ts +3 -3
  23. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.js +2 -6
  24. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.d.ts +1 -2
  25. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +33 -55
  26. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/submitIntlVerificationEpic.js +7 -2
  27. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.d.ts +1 -24
  28. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +9 -59
  29. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +6 -22
  30. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +15 -39
  31. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationState.d.ts +1 -20
  32. package/package.json +1 -1
  33. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.js +0 -164
  34. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.js +0 -45
  35. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.js +0 -105
  36. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.js +0 -189
  37. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.d.ts +0 -4
  38. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.js +0 -168
  39. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.d.ts +0 -43
  40. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.js +0 -48
  41. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.d.ts +0 -29
  42. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.js +0 -115
  43. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.d.ts +0 -32
  44. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.js +0 -194
@@ -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`, (0, internationalWireVerificationSubmitPayload_1.toIntlWireVerificationSubmitPayload)(localData))
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, VerificationFormLocalData } from './internationalWireVerificationState';
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.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 orderIndex = new Map(exports.InternationalWireVerificationFormOrder.map((name, index) => [name, index]));
21
- const toFieldValues = (fieldValues) => fieldValues?.map(({ code, description }) => ({ code, description })) ?? [];
22
- const toSubField = (subfield) => ({
23
- label: subfield.label,
24
- placeholder: subfield.field_hint_text ?? '',
25
- type: subfield.type,
26
- fieldValues: toFieldValues(subfield.field_values),
27
- isMultipleOptionsSupported: subfield.is_multiple_options_supported,
28
- options: subfield.options,
29
- });
3
+ exports.toDynamicFormField = void 0;
30
4
  const toDynamicFormField = (key, payload) => ({
31
5
  name: key,
32
6
  label: payload.label,
33
7
  placeholder: payload.field_hint_text ?? '',
34
8
  isMultipleValuesAllowed: payload.is_multiple_values_allowed ?? false,
35
9
  type: payload.type,
36
- fieldValues: toFieldValues(payload.field_values),
37
- isMultipleOptionsSupported: payload.is_multiple_options_supported,
38
- options: payload.options,
39
- requirements: payload.requirements,
40
- default: payload.default,
41
- subfields: payload.subfields != null
42
- ? Object.fromEntries(Object.entries(payload.subfields).map(([subfieldKey, subfield]) => [
43
- subfieldKey,
44
- toSubField(subfield),
45
- ]))
46
- : 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
+ : [],
47
18
  });
48
19
  exports.toDynamicFormField = toDynamicFormField;
49
- const readonlyHideableVerificationFormFieldNames = new Set(internationalWireVerificationFieldConstants_1.InternationalWireVerificationReadonlyHideableFieldNames);
50
- const filterVerificationFormFieldsForReadonlyView = (fields, localData, isReadonly) => {
51
- if (!isReadonly || (0, internationalWireVerificationLocalDataHelpers_1.hasBusinessOwnershipValueInLocalData)(localData)) {
52
- return fields;
53
- }
54
- return fields.filter((field) => !readonlyHideableVerificationFormFieldNames.has(field.name));
55
- };
56
- exports.filterVerificationFormFieldsForReadonlyView = filterVerificationFormFieldsForReadonlyView;
57
- const sortVerificationFormFields = (fields) => {
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;
@@ -4,12 +4,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.clearInternationalVerificationView = exports.initializeIntlVerificationForm = exports.updateVerificationFormSubmissionStatus = exports.submitInternationalVerificationForm = exports.updateVerificationFormLocalData = exports.updateVerificationFormFailure = exports.updateInternationalVerificationForm = exports.fetchInternationalVerificationForm = exports.initialState = void 0;
5
5
  const toolkit_1 = require("@reduxjs/toolkit");
6
6
  const internationalWireVerificationPayload_1 = require("./internationalWireVerificationPayload");
7
- const internationalWireVerificationFieldConstants_1 = require("./internationalWireVerificationFieldConstants");
8
7
  exports.initialState = {
9
8
  verificationFormFetchState: {
10
9
  fetchState: 'Not-Started',
11
10
  },
12
- verificationFormFieldLabels: {},
13
11
  verificationFormFields: [],
14
12
  verificationFormLocalData: {},
15
13
  verificationFormSubmitState: {
@@ -37,8 +35,11 @@ const internationalWireVerification = (0, toolkit_1.createSlice)({
37
35
  },
38
36
  updateInternationalVerificationForm(draft, action) {
39
37
  const { internationalWireFormPayload } = action.payload;
40
- draft.verificationFormFieldLabels = internationalWireFormPayload;
41
- 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;
42
43
  draft.verificationFormFetchState.fetchState = 'Completed';
43
44
  },
44
45
  updateVerificationFormFailure(draft, action) {
@@ -47,26 +48,9 @@ const internationalWireVerification = (0, toolkit_1.createSlice)({
47
48
  draft.verificationFormFetchState.error = error;
48
49
  },
49
50
  updateVerificationFormLocalData(draft, action) {
50
- const mergedLocalData = {
51
- ...draft.verificationFormLocalData,
51
+ draft.verificationFormLocalData = {
52
52
  ...action.payload,
53
53
  };
54
- if (action.payload[internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder] === 'false') {
55
- Object.keys(mergedLocalData).forEach((key) => {
56
- if (key.startsWith(`${internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder}_`)) {
57
- delete mergedLocalData[key];
58
- }
59
- });
60
- }
61
- if (action.payload[internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames
62
- .controllingPerson] === 'true') {
63
- Object.keys(mergedLocalData).forEach((key) => {
64
- if (key.startsWith(`${internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson}_`)) {
65
- delete mergedLocalData[key];
66
- }
67
- });
68
- }
69
- draft.verificationFormLocalData = mergedLocalData;
70
54
  },
71
55
  submitInternationalVerificationForm: {
72
56
  reducer(draft) {
@@ -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.68-beta0RR",
3
+ "version": "5.1.68-betaDI0",
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,164 +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 === 'file') {
31
- localData[fieldKey] =
32
- fieldPayload.is_multiple_values_allowed === true ? [] : '';
33
- return;
34
- }
35
- if (fieldPayload.type === 'date') {
36
- localData[fieldKey] = '';
37
- return;
38
- }
39
- if (fieldPayload.type === 'enum') {
40
- localData[fieldKey] =
41
- fieldPayload.is_multiple_values_allowed === true ? [] : '';
42
- return;
43
- }
44
- if (fieldPayload.type === 'boolean_with_subfields') {
45
- if (fieldKey ===
46
- InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder) {
47
- localData[fieldKey] = 'false';
48
- return;
49
- }
50
- if (fieldKey ===
51
- InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson) {
52
- localData[fieldKey] = fieldPayload.default === true ? 'true' : 'false';
53
- }
54
- }
55
- };
56
- const parseEnumValues = (localData, fieldKey, fieldPayload, values) => {
57
- if (fieldPayload.is_multiple_values_allowed === true) {
58
- localData[fieldKey] = values
59
- .map(getCodeFromValue)
60
- .filter((code) => code.length > 0);
61
- return;
62
- }
63
- localData[fieldKey] = getCodeFromValue(values[0]);
64
- };
65
- const parseFileValues = (localData, fieldKey, fieldPayload, values) => {
66
- if (values.length > 0 && isIntlWireFileOptionLike(values[0])) {
67
- const fileOptions = toIntlWireFileOptionArray(values);
68
- if (fileOptions.length > 0) {
69
- appendIntlWireFileOptionsToLocalData(localData, fieldKey, fileOptions, {
70
- includeBack: !MULTI_OPTION_FILE_FIELD_NAMES.has(fieldKey),
71
- });
72
- }
73
- return;
74
- }
75
- if (values.length > 0 && MULTI_OPTION_FILE_FIELD_NAMES.has(fieldKey)) {
76
- const fileOptions = toIntlWireFileOptionArray(values);
77
- if (fileOptions.length > 0) {
78
- appendIntlWireFileOptionsToLocalData(localData, fieldKey, fileOptions, {
79
- includeBack: false,
80
- });
81
- return;
82
- }
83
- }
84
- const fileIds = values.filter((value) => typeof value === 'string' && value.length > 0);
85
- if (fieldPayload.is_multiple_values_allowed === true) {
86
- localData[fieldKey] = fileIds;
87
- return;
88
- }
89
- localData[fieldKey] = fileIds[0] ?? '';
90
- };
91
- const parseBooleanWithSubfieldsValues = (localData, fieldKey, fieldPayload, rawValues) => {
92
- if (fieldKey ===
93
- InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson) {
94
- if (isIntlWirePersonLike(rawValues)) {
95
- localData[fieldKey] = 'false';
96
- appendIntlWirePersonToLocalData(localData, fieldKey, rawValues);
97
- return;
98
- }
99
- const values = toValuesArray(rawValues);
100
- if (values.length > 0 && isIntlWirePersonLike(values[0])) {
101
- localData[fieldKey] = 'false';
102
- appendIntlWirePersonToLocalData(localData, fieldKey, values[0]);
103
- return;
104
- }
105
- const selection = getCodeFromValue(values[0]);
106
- localData[fieldKey] =
107
- selection.length > 0
108
- ? selection
109
- : fieldPayload.default === true
110
- ? 'true'
111
- : 'false';
112
- return;
113
- }
114
- if (fieldKey ===
115
- InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder) {
116
- const values = toValuesArray(rawValues);
117
- if (values.length > 0 && isIntlWirePersonLike(values[0])) {
118
- localData[fieldKey] = 'true';
119
- values.forEach((person, ownerIndex) => {
120
- if (isIntlWirePersonLike(person)) {
121
- appendIntlWirePersonToLocalData(localData, `${fieldKey}_${ownerIndex}`, person);
122
- }
123
- });
124
- return;
125
- }
126
- const selection = getCodeFromValue(values[0]);
127
- localData[fieldKey] = selection.length > 0 ? selection : 'false';
128
- }
129
- };
130
- export const toVerificationFormLocalDataFromOnboardingDetails = (onboardingDetails, internationalWireFormPayload) => {
131
- const localData = {};
132
- Object.keys(internationalWireFormPayload).forEach((fieldKey) => {
133
- const fieldPayload = internationalWireFormPayload[fieldKey];
134
- const rawValues = onboardingDetails?.[fieldKey]?.values;
135
- if (rawValues == null) {
136
- setEmptyFieldDefault(localData, fieldKey, fieldPayload);
137
- return;
138
- }
139
- if (fieldPayload.type === 'boolean_with_subfields') {
140
- parseBooleanWithSubfieldsValues(localData, fieldKey, fieldPayload, rawValues);
141
- return;
142
- }
143
- const values = toValuesArray(rawValues);
144
- if (values.length === 0) {
145
- setEmptyFieldDefault(localData, fieldKey, fieldPayload);
146
- return;
147
- }
148
- switch (fieldPayload.type) {
149
- case 'enum':
150
- parseEnumValues(localData, fieldKey, fieldPayload, values);
151
- break;
152
- case 'file':
153
- parseFileValues(localData, fieldKey, fieldPayload, values);
154
- break;
155
- case 'date':
156
- localData[fieldKey] = getCodeFromValue(values[0]);
157
- break;
158
- default:
159
- localData[fieldKey] = getCodeFromValue(values[0]);
160
- break;
161
- }
162
- });
163
- return localData;
164
- };
@@ -1,45 +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
- /**
41
- * Readonly visibility gate:
42
- * legacy onboarding submissions only have older fields saved.
43
- * Newer fields are shown in readonly mode only when this field has data.
44
- */
45
- export const InternationalWireVerificationReadonlyVisibilityGateFieldName = InternationalWireVerificationFormFieldNames.businessOwnership;
@@ -1,105 +0,0 @@
1
- import { InternationalWireVerificationFormFieldNames, InternationalWireVerificationReadonlyVisibilityGateFieldName, 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, options) => {
24
- const includeBack = options?.includeBack ?? true;
25
- const [front, back] = fileOptions;
26
- if (front?.file_id != null && front.file_id !== '') {
27
- localData[baseKey] = front.file_id;
28
- if (front.option != null && front.option !== '') {
29
- localData[`${baseKey}${IntlWireVerificationLocalDataSuffix.documentOption}`] = front.option;
30
- }
31
- }
32
- const backKey = `${baseKey}${IntlWireVerificationLocalDataSuffix.documentBack}`;
33
- if (includeBack && back?.file_id != null && back.file_id !== '') {
34
- localData[backKey] = back.file_id;
35
- }
36
- else {
37
- // Clear any stale back-file id so a shallow merge does not retain a proof
38
- // document that is no longer present on the re-applied record.
39
- delete localData[backKey];
40
- }
41
- };
42
- export const appendIntlWirePersonToLocalData = (localData, keyPrefix, person) => {
43
- const nameBaseKey = `${keyPrefix}_${InternationalWireVerificationSubfieldNames.name}`;
44
- if (person.name?.first_name != null) {
45
- localData[`${nameBaseKey}${IntlWireVerificationLocalDataSuffix.nameFirst}`] = person.name.first_name;
46
- }
47
- if (person.name?.last_name != null) {
48
- localData[`${nameBaseKey}${IntlWireVerificationLocalDataSuffix.nameLast}`] = person.name.last_name;
49
- }
50
- const assignStringField = (subfieldName, fieldValue) => {
51
- if (fieldValue != null && fieldValue !== '') {
52
- localData[`${keyPrefix}_${subfieldName}`] = fieldValue;
53
- }
54
- };
55
- assignStringField(InternationalWireVerificationSubfieldNames.nationality, person.nationality);
56
- assignStringField(InternationalWireVerificationSubfieldNames.email, person.email);
57
- assignStringField(InternationalWireVerificationSubfieldNames.companyRole, person.company_role);
58
- assignStringField(InternationalWireVerificationSubfieldNames.ssn, person.ssn);
59
- assignStringField(InternationalWireVerificationSubfieldNames.dateOfBirth, person.date_of_birth);
60
- if (person.ownership_percentage != null) {
61
- localData[`${keyPrefix}_${InternationalWireVerificationSubfieldNames.ownershipPercentage}`] = person.ownership_percentage;
62
- }
63
- if (person.proof_of_identity != null) {
64
- appendIntlWireFileOptionsToLocalData(localData, `${keyPrefix}_${InternationalWireVerificationSubfieldNames.proofOfIdentity}`, toIntlWireFileOptionArray(person.proof_of_identity));
65
- }
66
- if (person.proof_of_address != null) {
67
- appendIntlWireFileOptionsToLocalData(localData, `${keyPrefix}_${InternationalWireVerificationSubfieldNames.proofOfAddress}`, toIntlWireFileOptionArray(person.proof_of_address));
68
- }
69
- };
70
- export const getStakeHolderOwnerIndicesFromLocalData = (localData) => {
71
- const stakeHolderPrefix = `${InternationalWireVerificationFormFieldNames.stakeHolder}_`;
72
- const stakeHolderIndexedPattern = new RegExp(`^${stakeHolderPrefix}(\\d+)_`);
73
- const stakeHolderBooleanSelectionPattern = new RegExp(`^${InternationalWireVerificationFormFieldNames.stakeHolder}_(true|false)$`);
74
- const indices = new Set();
75
- Object.keys(localData).forEach((key) => {
76
- const match = key.match(stakeHolderIndexedPattern);
77
- if (match != null) {
78
- indices.add(Number.parseInt(match[1], 10));
79
- }
80
- });
81
- if (indices.size === 0) {
82
- const hasUnindexedStakeHolderData = Object.keys(localData).some((key) => key.startsWith(stakeHolderPrefix) &&
83
- !stakeHolderBooleanSelectionPattern.test(key));
84
- if (hasUnindexedStakeHolderData) {
85
- indices.add(0);
86
- }
87
- }
88
- return Array.from(indices).sort((a, b) => a - b);
89
- };
90
- export const hasBusinessOwnershipValueInLocalData = (localData, gateFieldName = InternationalWireVerificationReadonlyVisibilityGateFieldName) => {
91
- const baseKey = gateFieldName ?? InternationalWireVerificationFormFieldNames.businessOwnership;
92
- const frontFileId = localData[baseKey];
93
- if (typeof frontFileId === 'string' && frontFileId !== '') {
94
- return true;
95
- }
96
- if (Array.isArray(frontFileId)) {
97
- return frontFileId.some((fileId) => typeof fileId === 'string' && fileId !== '');
98
- }
99
- const backFileId = localData[`${baseKey}${IntlWireVerificationLocalDataSuffix.documentBack}`];
100
- if (typeof backFileId === 'string' && backFileId !== '') {
101
- return true;
102
- }
103
- const documentOption = localData[`${baseKey}${IntlWireVerificationLocalDataSuffix.documentOption}`];
104
- return typeof documentOption === 'string' && documentOption !== '';
105
- };