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

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 (47) 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/epics/saveNotificationPreferencesEpic.js +4 -2
  4. package/lib/esm/view/notificationPreferencesView/notificationPreferencesViewPayload.js +7 -2
  5. package/lib/esm/view/notificationPreferencesView/notificationPreferencesViewReducer.js +47 -2
  6. package/lib/esm/view/notificationPreferencesView/notificationPreferencesViewSelector.js +9 -0
  7. package/lib/esm/view/notificationPreferencesView/notificationPreferencesViewState.js +1 -0
  8. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.js +3 -7
  9. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +34 -56
  10. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/epics/submitIntlVerificationEpic.js +7 -2
  11. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +8 -55
  12. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +7 -23
  13. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +15 -39
  14. package/lib/index.d.ts +4 -10
  15. package/lib/index.js +15 -32
  16. package/lib/view/notificationPreferencesView/epics/saveNotificationPreferencesEpic.d.ts +5 -2
  17. package/lib/view/notificationPreferencesView/epics/saveNotificationPreferencesEpic.js +3 -1
  18. package/lib/view/notificationPreferencesView/notificationPreferencesViewPayload.d.ts +1 -0
  19. package/lib/view/notificationPreferencesView/notificationPreferencesViewPayload.js +7 -2
  20. package/lib/view/notificationPreferencesView/notificationPreferencesViewReducer.d.ts +6 -1
  21. package/lib/view/notificationPreferencesView/notificationPreferencesViewReducer.js +48 -3
  22. package/lib/view/notificationPreferencesView/notificationPreferencesViewSelector.js +9 -0
  23. package/lib/view/notificationPreferencesView/notificationPreferencesViewState.d.ts +1 -0
  24. package/lib/view/notificationPreferencesView/notificationPreferencesViewState.js +1 -0
  25. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.d.ts +3 -3
  26. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/fetchIntlVerificationFormEpic.js +2 -6
  27. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.d.ts +1 -2
  28. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/initializeIntlVerificationFormEpic.js +33 -55
  29. package/lib/view/spendManagement/billPay/internationalWireVerification/epics/submitIntlVerificationEpic.js +7 -2
  30. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.d.ts +1 -24
  31. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationPayload.js +9 -59
  32. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationReducer.js +6 -22
  33. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSelector.js +15 -39
  34. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationState.d.ts +1 -20
  35. package/package.json +1 -1
  36. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.js +0 -164
  37. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.js +0 -45
  38. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.js +0 -105
  39. package/lib/esm/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.js +0 -189
  40. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.d.ts +0 -4
  41. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireOnboardingDetailsToLocalData.js +0 -168
  42. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.d.ts +0 -43
  43. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationFieldConstants.js +0 -48
  44. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.d.ts +0 -29
  45. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationLocalDataHelpers.js +0 -115
  46. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.d.ts +0 -32
  47. package/lib/view/spendManagement/billPay/internationalWireVerification/internationalWireVerificationSubmitPayload.js +0 -194
@@ -3,63 +3,41 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initializeIntlVerificationFormEpic = void 0;
4
4
  const rxjs_1 = require("rxjs");
5
5
  const operators_1 = require("rxjs/operators");
6
- const tenantSelector_1 = require("../../../../../entity/tenant/tenantSelector");
7
- const billPaySetupViewReducer_1 = require("../../billPaySetupView/billPaySetupViewReducer");
8
- const internationalWireVerificationFieldConstants_1 = require("../internationalWireVerificationFieldConstants");
9
- const internationalWireOnboardingDetailsToLocalData_1 = require("../internationalWireOnboardingDetailsToLocalData");
10
6
  const internationalWireVerificationReducer_1 = require("../internationalWireVerificationReducer");
11
- const hasSavedPersonSubfieldData = (localData) =>
12
- // Person subfield keys follow `<field_name>_<index?>_<subfield>`
13
- // e.g. `stake_holder_0_email`, `controlling_person_email`.
14
- Object.keys(localData).some((key) => new RegExp(`^${internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder}_\\d+_`).test(key) ||
15
- key.startsWith(`${internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson}_`));
16
- const getPersonScopedLocalData = (localData) => Object.fromEntries(Object.entries(localData).filter(([key]) => {
17
- if (key === internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder ||
18
- key ===
19
- internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson) {
20
- return true;
21
- }
22
- return (key.startsWith(`${internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.stakeHolder}_`) ||
23
- key.startsWith(`${internationalWireVerificationFieldConstants_1.InternationalWireVerificationBooleanWithSubfieldsFieldNames.controllingPerson}_`));
24
- }));
25
- const initializeIntlVerificationFormEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)((action) => internationalWireVerificationReducer_1.initializeIntlVerificationForm.match(action) ||
26
- billPaySetupViewReducer_1.fetchBillPaySetupViewSuccess.match(action)), (0, operators_1.mergeMap)((action) => {
7
+ const initializeIntlVerificationFormEpic = (actions$, state$) => actions$.pipe((0, operators_1.filter)(internationalWireVerificationReducer_1.initializeIntlVerificationForm.match), (0, operators_1.mergeMap)((action) => {
8
+ const { companyId, internationalWireFormPayload } = action.payload;
9
+ const actions = [];
27
10
  const state = state$.value;
28
- const formFieldLabelsFromState = state.internationalWireVerificationState.verificationFormFieldLabels;
29
- const formFieldLabels = internationalWireVerificationReducer_1.initializeIntlVerificationForm.match(action) &&
30
- Object.keys(formFieldLabelsFromState).length === 0
31
- ? action.payload.internationalWireFormPayload
32
- : formFieldLabelsFromState;
33
- if (Object.keys(formFieldLabels).length === 0) {
34
- return rxjs_1.EMPTY;
35
- }
36
- const companyId = internationalWireVerificationReducer_1.initializeIntlVerificationForm.match(action) ?
37
- action.payload.companyId
38
- : (0, tenantSelector_1.getCurrentTenant)(state)?.companyId;
39
- if (companyId == null) {
40
- return rxjs_1.EMPTY;
41
- }
42
- const onboardingDataFromCompanyInfo = state.companyState.companiesById[companyId]?.companyBillPayInfo
43
- ?.internationalWireOnboardingDetails;
44
- const localDataFromCompany = (0, internationalWireOnboardingDetailsToLocalData_1.toVerificationFormLocalDataFromOnboardingDetails)(onboardingDataFromCompanyInfo, formFieldLabels);
45
- const existingLocalData = state.internationalWireVerificationState.verificationFormLocalData;
46
- if (billPaySetupViewReducer_1.fetchBillPaySetupViewSuccess.match(action)) {
47
- if (!hasSavedPersonSubfieldData(localDataFromCompany) ||
48
- hasSavedPersonSubfieldData(existingLocalData)) {
49
- return rxjs_1.EMPTY;
11
+ const onboardingDataFromCompanyInfo = state.companyState.companiesById[companyId].companyBillPayInfo
12
+ .internationalWireOnboardingDetails;
13
+ const localData = {};
14
+ Object.keys(internationalWireFormPayload).forEach((formFieldKey) => {
15
+ const values = onboardingDataFromCompanyInfo != null
16
+ ? onboardingDataFromCompanyInfo[formFieldKey]?.values
17
+ : undefined;
18
+ if (values != null) {
19
+ localData[formFieldKey] =
20
+ internationalWireFormPayload[formFieldKey].type === 'enum'
21
+ ? internationalWireFormPayload[formFieldKey]
22
+ .is_multiple_values_allowed === false
23
+ ? typeof values[0] === 'object' && 'code' in values[0]
24
+ ? values[0].code
25
+ : ''
26
+ : values.map((value) => typeof value === 'object' && 'code' in value
27
+ ? value.code
28
+ : '')
29
+ : values[0];
30
+ }
31
+ else {
32
+ localData[formFieldKey] =
33
+ internationalWireFormPayload[formFieldKey].type === 'enum' &&
34
+ internationalWireFormPayload[formFieldKey]
35
+ .is_multiple_values_allowed === true
36
+ ? []
37
+ : '';
50
38
  }
51
- return (0, rxjs_1.from)([
52
- (0, internationalWireVerificationReducer_1.updateVerificationFormLocalData)({
53
- ...existingLocalData,
54
- ...getPersonScopedLocalData(localDataFromCompany),
55
- }),
56
- ]);
57
- }
58
- return (0, rxjs_1.from)([
59
- (0, internationalWireVerificationReducer_1.updateVerificationFormLocalData)({
60
- ...existingLocalData,
61
- ...localDataFromCompany,
62
- }),
63
- ]);
39
+ });
40
+ actions.push((0, internationalWireVerificationReducer_1.updateVerificationFormLocalData)(localData));
41
+ return (0, rxjs_1.from)(actions);
64
42
  }));
65
43
  exports.initializeIntlVerificationFormEpic = initializeIntlVerificationFormEpic;
@@ -6,7 +6,6 @@ const operators_1 = require("rxjs/operators");
6
6
  const companyReducer_1 = require("../../../../../entity/company/companyReducer");
7
7
  const snackbarReducer_1 = require("../../../../../entity/snackbar/snackbarReducer");
8
8
  const responsePayload_1 = require("../../../../../responsePayload");
9
- const internationalWireVerificationSubmitPayload_1 = require("../internationalWireVerificationSubmitPayload");
10
9
  const internationalWireVerificationReducer_1 = require("../internationalWireVerificationReducer");
11
10
  const submitIntlVerificationEpic = (actions$, state$, zeniAPI) => actions$.pipe((0, operators_1.filter)(internationalWireVerificationReducer_1.submitInternationalVerificationForm.match), (0, operators_1.switchMap)((action) => {
12
11
  const { internationalWireVerificationState } = state$.value;
@@ -14,7 +13,7 @@ const submitIntlVerificationEpic = (actions$, state$, zeniAPI) => actions$.pipe(
14
13
  const localData = internationalWireVerificationState.verificationFormLocalData;
15
14
  if (localData != null) {
16
15
  return zeniAPI
17
- .postAndGetJSON(`${zeniAPI.apiEndPoints.payMicroServiceBaseUrl}/1.0/international-wire/onboarding`, (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-betaDI1",
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;