@zeniai/client-epic-state 5.0.91 → 5.0.92-beta0ND

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 (100) hide show
  1. package/lib/commonStateTypes/animations.d.ts +1 -1
  2. package/lib/commonStateTypes/animations.js +1 -0
  3. package/lib/entity/company/companyPayload.d.ts +4 -0
  4. package/lib/entity/company/companyPayload.js +4 -0
  5. package/lib/entity/company/companyStateTypes.d.ts +4 -0
  6. package/lib/entity/paymentAccount/paymentAccountSelector.d.ts +1 -0
  7. package/lib/entity/paymentAccount/paymentAccountSelector.js +4 -0
  8. package/lib/entity/task/taskPayload.d.ts +3 -1
  9. package/lib/entity/task/taskPayload.js +2 -0
  10. package/lib/entity/task/taskState.d.ts +2 -0
  11. package/lib/entity/tenant/epic/deleteConnectionEpic.d.ts +1 -1
  12. package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.d.ts +21 -0
  13. package/lib/entity/tenant/epic/initEmailConnectOAuthEpic.js +54 -0
  14. package/lib/entity/tenant/epic/saveAPIKeyConnectionEpic.d.ts +1 -1
  15. package/lib/entity/tenant/epic/saveConnectorCredentialsEpic.d.ts +3 -3
  16. package/lib/entity/tenant/epic/saveOAuthConnectionEpic.d.ts +1 -1
  17. package/lib/entity/tenant/tenantPayload.d.ts +1 -0
  18. package/lib/entity/tenant/tenantReducer.d.ts +38 -25
  19. package/lib/entity/tenant/tenantReducer.js +65 -5
  20. package/lib/entity/tenant/tenantState.d.ts +1 -0
  21. package/lib/epic.d.ts +10 -3
  22. package/lib/epic.js +11 -3
  23. package/lib/esm/commonStateTypes/animations.js +1 -0
  24. package/lib/esm/entity/company/companyPayload.js +4 -0
  25. package/lib/esm/entity/paymentAccount/paymentAccountSelector.js +3 -0
  26. package/lib/esm/entity/task/taskPayload.js +2 -0
  27. package/lib/esm/entity/tenant/epic/initEmailConnectOAuthEpic.js +50 -0
  28. package/lib/esm/entity/tenant/tenantReducer.js +63 -3
  29. package/lib/esm/epic.js +11 -3
  30. package/lib/esm/index.js +12 -9
  31. package/lib/esm/view/companyTaskManagerView/companyTaskManagerViewReducer.js +39 -11
  32. package/lib/esm/view/companyTaskManagerView/companyTaskManagerViewSelector.js +14 -4
  33. package/lib/esm/view/companyTaskManagerView/epics/fetchCockpitContextEpic.js +38 -0
  34. package/lib/esm/view/companyTaskManagerView/epics/fetchCompanyTaskManagerViewEpic.js +37 -28
  35. package/lib/esm/view/companyTaskManagerView/epics/updateCompanyTaskManagerViewFiltersEpic.js +16 -0
  36. package/lib/esm/view/companyView/epic/fetchAllCockpitViewsEpic.js +2 -2
  37. package/lib/esm/view/fileView/epic/deleteFileEpic.js +2 -2
  38. package/lib/esm/view/fileView/epic/deleteFileListEpic.js +2 -2
  39. package/lib/esm/view/fileView/epic/updateFileNameEpic.js +2 -2
  40. package/lib/esm/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +42 -0
  41. package/lib/esm/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.js +29 -0
  42. package/lib/esm/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +40 -0
  43. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewReducer.js +217 -50
  44. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewSelector.js +7 -1
  45. package/lib/esm/view/onboardingView/customerView/onboardingCustomerViewState.js +12 -0
  46. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +52 -0
  47. package/lib/esm/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +59 -0
  48. package/lib/esm/view/spendManagement/commonSetup/kycKybAutofillActions.js +14 -0
  49. package/lib/esm/view/spendManagement/commonSetup/kycKybParseMapper.js +205 -0
  50. package/lib/esm/view/spendManagement/commonSetup/setupViewReducer.js +105 -52
  51. package/lib/esm/view/spendManagement/commonSetup/setupViewSelector.js +6 -1
  52. package/lib/esm/view/spendManagement/commonSetup/types/kycKybAutofill.js +28 -0
  53. package/lib/index.d.ts +17 -12
  54. package/lib/index.js +53 -31
  55. package/lib/view/companyTaskManagerView/companyTaskManagerViewPayload.d.ts +19 -11
  56. package/lib/view/companyTaskManagerView/companyTaskManagerViewReducer.d.ts +10 -4
  57. package/lib/view/companyTaskManagerView/companyTaskManagerViewReducer.js +40 -12
  58. package/lib/view/companyTaskManagerView/companyTaskManagerViewSelector.d.ts +2 -0
  59. package/lib/view/companyTaskManagerView/companyTaskManagerViewSelector.js +13 -3
  60. package/lib/view/companyTaskManagerView/companyTaskManagerViewState.d.ts +11 -3
  61. package/lib/view/companyTaskManagerView/epics/fetchCockpitContextEpic.d.ts +10 -0
  62. package/lib/view/companyTaskManagerView/epics/fetchCockpitContextEpic.js +42 -0
  63. package/lib/view/companyTaskManagerView/epics/fetchCompanyTaskManagerViewEpic.d.ts +1 -3
  64. package/lib/view/companyTaskManagerView/epics/fetchCompanyTaskManagerViewEpic.js +37 -28
  65. package/lib/view/companyTaskManagerView/epics/updateCompanyTaskManagerViewFiltersEpic.d.ts +6 -0
  66. package/lib/view/companyTaskManagerView/epics/updateCompanyTaskManagerViewFiltersEpic.js +20 -0
  67. package/lib/view/companyView/epic/fetchAllCockpitViewsEpic.js +2 -2
  68. package/lib/view/companyView/types/cockpitTypes.d.ts +2 -1
  69. package/lib/view/fileView/epic/deleteFileEpic.js +1 -1
  70. package/lib/view/fileView/epic/deleteFileListEpic.js +1 -1
  71. package/lib/view/fileView/epic/updateFileNameEpic.js +1 -1
  72. package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.d.ts +7 -0
  73. package/lib/view/onboardingView/customerView/epic/aiAgentsActivation/fetchAiAgentsActivationStatusEpic.js +46 -0
  74. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.d.ts +8 -0
  75. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiActivationViewedEpic.js +33 -0
  76. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.d.ts +9 -0
  77. package/lib/view/onboardingView/customerView/epic/customerDetails/acknowledgeOnboardingAiFinanceTeamEpic.js +44 -0
  78. package/lib/view/onboardingView/customerView/onboardingCustomerViewPayload.d.ts +3 -0
  79. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.d.ts +41 -4
  80. package/lib/view/onboardingView/customerView/onboardingCustomerViewReducer.js +219 -51
  81. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.d.ts +5 -1
  82. package/lib/view/onboardingView/customerView/onboardingCustomerViewSelector.js +11 -2
  83. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.d.ts +40 -0
  84. package/lib/view/onboardingView/customerView/onboardingCustomerViewState.js +13 -1
  85. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.d.ts +28 -0
  86. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKybDocumentEpic.js +56 -0
  87. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.d.ts +30 -0
  88. package/lib/view/spendManagement/commonSetup/epic/setup/parseUploadedKycDocumentEpic.js +63 -0
  89. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.d.ts +33 -0
  90. package/lib/view/spendManagement/commonSetup/kycKybAutofillActions.js +17 -0
  91. package/lib/view/spendManagement/commonSetup/kycKybParseMapper.d.ts +24 -0
  92. package/lib/view/spendManagement/commonSetup/kycKybParseMapper.js +213 -0
  93. package/lib/view/spendManagement/commonSetup/setupViewReducer.d.ts +28 -2
  94. package/lib/view/spendManagement/commonSetup/setupViewReducer.js +106 -53
  95. package/lib/view/spendManagement/commonSetup/setupViewSelector.d.ts +7 -2
  96. package/lib/view/spendManagement/commonSetup/setupViewSelector.js +6 -1
  97. package/lib/view/spendManagement/commonSetup/setupViewState.d.ts +19 -0
  98. package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.d.ts +125 -0
  99. package/lib/view/spendManagement/commonSetup/types/kycKybAutofill.js +32 -0
  100. package/package.json +1 -1
@@ -1,51 +1,35 @@
1
1
  import { from } from 'rxjs';
2
2
  import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
3
3
  import { getSortOrder } from '../../../commonPayloadTypes/sortOrderPayload';
4
- import { updateCompanies } from '../../../entity/company/companyReducer';
5
4
  import { updateTags } from '../../../entity/tag/tagReducer';
6
5
  import { updateTasks } from '../../../entity/task/taskReducer';
7
- import { updateAllUsers } from '../../../entity/user/userReducer';
8
6
  import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
9
7
  import { fetchCompanyTaskManagerView, updateCompanyTaskManagerViewOnFailure, updateCompanyTaskManagerViewOnSuccess, } from '../companyTaskManagerViewReducer';
10
- const toSortKeyPayload = (sortKey) => {
11
- switch (sortKey) {
12
- case 'taskName':
13
- return 'name';
14
- case 'dueDate':
15
- return 'due_date';
16
- case 'createdBy':
17
- return 'created_by';
18
- case 'name':
19
- return 'company_name';
20
- default:
21
- return sortKey;
22
- }
23
- };
8
+ const DEFAULT_PAGE_SIZE = 100;
24
9
  export const fetchCompanyTaskManagerViewEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchCompanyTaskManagerView.match), switchMap((action) => {
25
- const { pageToken, sortKey, sortOrder, searchString } = action.payload;
10
+ const { from: fromOffset, searchString, sortKey, sortOrder, filters, } = action.payload;
26
11
  const queryValue = {
27
- page_token: pageToken,
12
+ size: DEFAULT_PAGE_SIZE,
13
+ from: fromOffset,
14
+ global_search: searchString ?? '',
28
15
  sort_by: toSortKeyPayload(sortKey),
29
16
  sort_order: getSortOrder(sortOrder),
30
- search_text: searchString ?? '',
31
- view: 'cockpit_task_manager_view',
17
+ filter_join: filters?.categoryCombinationOperator === 'AND' ? 'and' : 'or',
18
+ ...(filters?.categories != null && filters.categories.length > 0
19
+ ? { filter_by: toFilterByPayload(filters) }
20
+ : {}),
32
21
  };
33
22
  return zeniAPI
34
- .getJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels/tasks?query=${encodeURIComponent(JSON.stringify(queryValue))}`)
23
+ .getJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels/tasks-es?query=${encodeURIComponent(JSON.stringify(queryValue))}`)
35
24
  .pipe(mergeMap((response) => {
36
25
  if (isSuccessResponse(response) && response.data != null) {
37
- const tasksList = response.data.tasks;
26
+ const tasksList = response.data.aggregations.group_by_company_name.buckets.flatMap((bucket) => bucket.tasks);
38
27
  const actions = [
39
28
  updateCompanyTaskManagerViewOnSuccess({
40
29
  data: response.data,
41
30
  }),
42
31
  updateTasks(tasksList),
43
- updateCompanies({
44
- payload: response.data.companies,
45
- schema: {},
46
- }),
47
- updateTags(tasksList.map((task) => task.tags).flat()),
48
- updateAllUsers({ users: response.data.users }),
32
+ updateTags(tasksList.flatMap((task) => task.tags)),
49
33
  ];
50
34
  return from(actions);
51
35
  }
@@ -62,3 +46,28 @@ export const fetchCompanyTaskManagerViewEpic = (actions$, _state$, zeniAPI) => a
62
46
  return from(actions);
63
47
  }));
64
48
  }));
49
+ const toSortKeyPayload = (sortKey) => {
50
+ switch (sortKey) {
51
+ case 'taskName':
52
+ return 'name';
53
+ case 'dueDate':
54
+ return 'due_date';
55
+ case 'createdBy':
56
+ return 'created_by';
57
+ case 'name':
58
+ return 'company_name';
59
+ default:
60
+ return sortKey;
61
+ }
62
+ };
63
+ const toFilterByPayload = (filters) => {
64
+ if (filters.categories == null) {
65
+ return [];
66
+ }
67
+ return filters.categories.map((category) => ({
68
+ field: category.field ?? '',
69
+ operator: category.matchingOperator === 'equal' ? 'is' : 'is_not',
70
+ values: category.values.map((v) => String(v)),
71
+ join: category.valuesCombinationOperator === 'ALL' ? 'and' : 'or',
72
+ }));
73
+ };
@@ -0,0 +1,16 @@
1
+ import { EMPTY, of } from 'rxjs';
2
+ import { filter, switchMap } from 'rxjs/operators';
3
+ import { fetchCompanyTaskManagerView, updateCompanyTaskManagerViewFilters, } from '../companyTaskManagerViewReducer';
4
+ export const updateCompanyTaskManagerViewFiltersEpic = (actions$, state$) => actions$.pipe(filter(updateCompanyTaskManagerViewFilters.match), switchMap((action) => {
5
+ const filters = action.payload.filters;
6
+ const allCategoriesValid = filters?.categories == null
7
+ ? true
8
+ : filters?.categories?.every((category) => category.field != null &&
9
+ category.values != null &&
10
+ category.values.length > 0);
11
+ if (!allCategoriesValid) {
12
+ return EMPTY;
13
+ }
14
+ const { uiState } = state$.value.companyTaskManagerViewState;
15
+ return of(fetchCompanyTaskManagerView(0, uiState.sortKey, uiState.sortOrder, false, uiState.filterText, filters));
16
+ }));
@@ -21,7 +21,7 @@ export const fetchAllCockpitViewsEpic = (actions$, state$) => actions$.pipe(filt
21
21
  fetchReviewCompanyView(),
22
22
  fetchCompanyHealthMetricView(),
23
23
  fetchCompanyMetaData(),
24
- fetchCompanyTaskManagerView(null, 'dueDate', 'descending', false),
24
+ fetchCompanyTaskManagerView(0, 'dueDate', 'descending', false),
25
25
  fetchCompanyHealthMetricConfig(),
26
26
  ]);
27
27
  }
@@ -74,7 +74,7 @@ export const fetchAllCockpitViewsEpic = (actions$, state$) => actions$.pipe(filt
74
74
  }
75
75
  if (state.companyTaskManagerViewState.fetchState !== 'In-Progress' &&
76
76
  state.companyTaskManagerViewState.hasValidState() === false) {
77
- fetchActions.push(fetchCompanyTaskManagerView(null, 'dueDate', 'descending', false));
77
+ fetchActions.push(fetchCompanyTaskManagerView(0, 'dueDate', 'descending', false));
78
78
  }
79
79
  return from(fetchActions);
80
80
  }
@@ -1,9 +1,9 @@
1
1
  import { of } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
2
+ import { catchError, filter, mergeMap } from 'rxjs/operators';
3
3
  import { removeFiles } from '../../../entity/file/fileReducer';
4
4
  import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
5
5
  import { deleteFile, deleteFileFailure, deleteFileSuccess, } from '../fileViewReducer';
6
- export const deleteFileEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(deleteFile.match), switchMap((action) => {
6
+ export const deleteFileEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(deleteFile.match), mergeMap((action) => {
7
7
  /**
8
8
  * tenantId is required for deleting onboarding files.
9
9
  */
@@ -1,9 +1,9 @@
1
1
  import { of } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
2
+ import { catchError, filter, mergeMap } from 'rxjs/operators';
3
3
  import { removeFiles } from '../../../entity/file/fileReducer';
4
4
  import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
5
5
  import { deleteFileList, deleteFileListFailure, deleteFileListSuccess, } from '../fileViewReducer';
6
- export const deleteFileListEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(deleteFileList.match), switchMap((action) => {
6
+ export const deleteFileListEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(deleteFileList.match), mergeMap((action) => {
7
7
  const { fileIds } = action.payload;
8
8
  return zeniAPI
9
9
  .deleteAndGetJSON(`${zeniAPI.apiEndPoints.fileMicroServiceBaseUrl}/1.0/files?query=${encodeURIComponent(JSON.stringify({ file_ids: fileIds }))}`)
@@ -1,9 +1,9 @@
1
1
  import { of } from 'rxjs';
2
- import { catchError, filter, mergeMap, switchMap } from 'rxjs/operators';
2
+ import { catchError, filter, mergeMap } from 'rxjs/operators';
3
3
  import { updateFiles } from '../../../entity/file/fileReducer';
4
4
  import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
5
5
  import { updateFileName, updateFileNameFailure, updateFileNameSuccess, } from '../fileViewReducer';
6
- export const updateFileNameEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(updateFileName.match), switchMap((action) => {
6
+ export const updateFileNameEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(updateFileName.match), mergeMap((action) => {
7
7
  /**
8
8
  * tenantId is required for updating onboarding file names.
9
9
  */
@@ -0,0 +1,42 @@
1
+ import { of } from 'rxjs';
2
+ import { catchError, filter, mergeMap } from 'rxjs/operators';
3
+ import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
4
+ import { fetchAiAgentsActivationStatus, fetchAiAgentsActivationStatusFailure, fetchAiAgentsActivationStatusSuccess, } from '../../onboardingCustomerViewReducer';
5
+ const toPhaseStatus = (raw) => {
6
+ if (raw === 'idle' ||
7
+ raw === 'starting' ||
8
+ raw === 'building' ||
9
+ raw === 'ready') {
10
+ return raw;
11
+ }
12
+ return 'idle';
13
+ };
14
+ const toPhase = (row) => ({
15
+ key: row.key,
16
+ status: toPhaseStatus(row.status),
17
+ startedAt: row.started_at,
18
+ completedAt: row.completed_at,
19
+ });
20
+ const toCounts = (payload) => ({
21
+ customerCount: payload?.customer_count ?? 0,
22
+ glAccountCount: payload?.gl_account_count ?? 0,
23
+ targetTransactionCount: payload?.target_transaction_count ?? 0,
24
+ transactionCount: payload?.transaction_count ?? 0,
25
+ vendorCount: payload?.vendor_count ?? 0,
26
+ });
27
+ export const fetchAiAgentsActivationStatusEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(fetchAiAgentsActivationStatus.match), mergeMap(() => {
28
+ const url = `${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/ai-agents-activation/status`;
29
+ return zeniAPI
30
+ .getJSON(url)
31
+ .pipe(mergeMap((response) => {
32
+ if (isSuccessResponse(response) && response.data != null) {
33
+ const phases = (response.data.phases ?? []).map(toPhase);
34
+ return of(fetchAiAgentsActivationStatusSuccess({
35
+ phases,
36
+ counts: toCounts(response.data.counts),
37
+ }));
38
+ }
39
+ return of(fetchAiAgentsActivationStatusFailure(response.status));
40
+ }), catchError((error) => of(fetchAiAgentsActivationStatusFailure(createZeniAPIStatus('Unexpected Error', 'fetchAiAgentsActivationStatus errored out ' +
41
+ JSON.stringify(error))))));
42
+ }));
@@ -0,0 +1,29 @@
1
+ import { from, of } from 'rxjs';
2
+ import { catchError, filter, mergeMap } from 'rxjs/operators';
3
+ import { updateCompanies } from '../../../../../entity/company/companyReducer';
4
+ import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
5
+ import { acknowledgeOnboardingAiActivationViewed, acknowledgeOnboardingAiActivationViewedFailure, acknowledgeOnboardingAiActivationViewedSuccess, } from '../../onboardingCustomerViewReducer';
6
+ export const acknowledgeOnboardingAiActivationViewedEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(acknowledgeOnboardingAiActivationViewed.match), mergeMap((action) => {
7
+ const { companyId } = action.payload;
8
+ const payload = {
9
+ is_onboarding_ai_activation_viewed: true,
10
+ };
11
+ return zeniAPI
12
+ .putAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${companyId}`, payload)
13
+ .pipe(mergeMap((response) => {
14
+ if (isSuccessResponse(response) && response.data != null) {
15
+ const actions = [
16
+ updateCompanies({
17
+ payload: response.data.companies,
18
+ schema: {},
19
+ }),
20
+ acknowledgeOnboardingAiActivationViewedSuccess(),
21
+ ];
22
+ return from(actions);
23
+ }
24
+ return of(acknowledgeOnboardingAiActivationViewedFailure(response.status));
25
+ }),
26
+ // Best-effort — failure is silent; cascade just runs again next visit.
27
+ catchError((error) => of(acknowledgeOnboardingAiActivationViewedFailure(createZeniAPIStatus('Unexpected Error', 'Acknowledge - Onboarding AI Activation Viewed errored out' +
28
+ JSON.stringify(error))))));
29
+ }));
@@ -0,0 +1,40 @@
1
+ import { from, of } from 'rxjs';
2
+ import { catchError, filter, mergeMap } from 'rxjs/operators';
3
+ import { updateCompanies } from '../../../../../entity/company/companyReducer';
4
+ import { openSnackbar } from '../../../../../entity/snackbar/snackbarReducer';
5
+ import { createZeniAPIStatus, isSuccessResponse, } from '../../../../../responsePayload';
6
+ import { acknowledgeOnboardingAiFinanceTeam, acknowledgeOnboardingAiFinanceTeamFailure, acknowledgeOnboardingAiFinanceTeamSuccess, } from '../../onboardingCustomerViewReducer';
7
+ export const acknowledgeOnboardingAiFinanceTeamEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(acknowledgeOnboardingAiFinanceTeam.match), mergeMap((action) => {
8
+ const { companyId } = action.payload;
9
+ const payload = {
10
+ is_onboarding_ai_finance_team_acknowledged: true,
11
+ };
12
+ return zeniAPI
13
+ .putAndGetJSON(`${zeniAPI.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${companyId}`, payload)
14
+ .pipe(mergeMap((response) => {
15
+ if (isSuccessResponse(response) && response.data != null) {
16
+ const actions = [
17
+ updateCompanies({
18
+ payload: response.data.companies,
19
+ schema: {},
20
+ }),
21
+ acknowledgeOnboardingAiFinanceTeamSuccess(),
22
+ ];
23
+ return from(actions);
24
+ }
25
+ else {
26
+ return of(openSnackbar({
27
+ messageSection: 'onboarding_customer_view_complete',
28
+ messageText: 'failed',
29
+ type: 'error',
30
+ variables: [
31
+ {
32
+ variableName: '_api-error_',
33
+ variableValue: response.status.message,
34
+ },
35
+ ],
36
+ }), acknowledgeOnboardingAiFinanceTeamFailure(response.status));
37
+ }
38
+ }), catchError((error) => of(acknowledgeOnboardingAiFinanceTeamFailure(createZeniAPIStatus('Unexpected Error', 'Acknowledge - Onboarding AI Finance Team errored out' +
39
+ JSON.stringify(error))))));
40
+ }));
@@ -1,5 +1,7 @@
1
1
  import { createSlice } from '@reduxjs/toolkit';
2
2
  import { date } from '../../../zeniDayJS';
3
+ import { parseUploadedKybDocument, parseUploadedKybDocumentFailure, parseUploadedKycDocument, parseUploadedKycDocumentFailure, } from '../../spendManagement/commonSetup/kycKybAutofillActions';
4
+ import { emptyAiAgentsActivationSubview, } from './onboardingCustomerViewState';
3
5
  const initialStatus = {
4
6
  fetchState: 'Not-Started',
5
7
  error: undefined,
@@ -9,61 +11,31 @@ export const initialState = {
9
11
  saveStatus: initialStatus,
10
12
  dashboardLoadedStatus: initialStatus,
11
13
  currentStep: 'link_payment_account',
14
+ parsingDocumentFileIds: [],
12
15
  companyDetails: {
16
+ autoFilledFields: [],
13
17
  localData: undefined,
14
18
  },
15
- companyOfficerUpdateStatus: {
16
- Officer_1: {
19
+ companyOfficerUpdateStatus: (() => {
20
+ const emptyOfficerSlot = {
21
+ autoFilledFields: [],
17
22
  localData: undefined,
18
23
  sendOtpStatus: initialStatus,
19
24
  otpverificationStatus: initialStatus,
20
- },
21
- Officer_2: {
22
- localData: undefined,
23
- sendOtpStatus: initialStatus,
24
- otpverificationStatus: initialStatus,
25
- },
26
- Officer_3: {
27
- localData: undefined,
28
- sendOtpStatus: initialStatus,
29
- otpverificationStatus: initialStatus,
30
- },
31
- Officer_4: {
32
- localData: undefined,
33
- sendOtpStatus: initialStatus,
34
- otpverificationStatus: initialStatus,
35
- },
36
- Officer_5: {
37
- localData: undefined,
38
- sendOtpStatus: initialStatus,
39
- otpverificationStatus: initialStatus,
40
- },
41
- Officer_6: {
42
- localData: undefined,
43
- sendOtpStatus: initialStatus,
44
- otpverificationStatus: initialStatus,
45
- },
46
- Officer_7: {
47
- localData: undefined,
48
- sendOtpStatus: initialStatus,
49
- otpverificationStatus: initialStatus,
50
- },
51
- Officer_8: {
52
- localData: undefined,
53
- sendOtpStatus: initialStatus,
54
- otpverificationStatus: initialStatus,
55
- },
56
- Officer_9: {
57
- localData: undefined,
58
- sendOtpStatus: initialStatus,
59
- otpverificationStatus: initialStatus,
60
- },
61
- Officer_10: {
62
- localData: undefined,
63
- sendOtpStatus: initialStatus,
64
- otpverificationStatus: initialStatus,
65
- },
66
- },
25
+ };
26
+ return {
27
+ Officer_1: { ...emptyOfficerSlot },
28
+ Officer_2: { ...emptyOfficerSlot },
29
+ Officer_3: { ...emptyOfficerSlot },
30
+ Officer_4: { ...emptyOfficerSlot },
31
+ Officer_5: { ...emptyOfficerSlot },
32
+ Officer_6: { ...emptyOfficerSlot },
33
+ Officer_7: { ...emptyOfficerSlot },
34
+ Officer_8: { ...emptyOfficerSlot },
35
+ Officer_9: { ...emptyOfficerSlot },
36
+ Officer_10: { ...emptyOfficerSlot },
37
+ };
38
+ })(),
67
39
  primaryContactDetails: {},
68
40
  paymentAccountDetails: {
69
41
  fetchStatus: initialStatus,
@@ -91,6 +63,7 @@ export const initialState = {
91
63
  },
92
64
  fetchState: 'Not-Started',
93
65
  error: undefined,
66
+ aiAgentsActivation: { ...emptyAiAgentsActivationSubview },
94
67
  uiState: {
95
68
  isQBOPopupOpen: false,
96
69
  isCardPaymentPopupOpen: false,
@@ -180,6 +153,126 @@ const onboardingCustomerView = createSlice({
180
153
  };
181
154
  },
182
155
  },
156
+ acknowledgeOnboardingAiFinanceTeam: {
157
+ reducer(draft) {
158
+ draft.aiFinanceTeamAcknowledgementStatus = {
159
+ fetchState: 'In-Progress',
160
+ error: undefined,
161
+ };
162
+ },
163
+ prepare(companyId) {
164
+ return {
165
+ payload: { companyId },
166
+ };
167
+ },
168
+ },
169
+ acknowledgeOnboardingAiFinanceTeamSuccess(draft) {
170
+ draft.aiFinanceTeamAcknowledgementStatus = {
171
+ fetchState: 'Completed',
172
+ error: undefined,
173
+ };
174
+ },
175
+ acknowledgeOnboardingAiFinanceTeamFailure: {
176
+ reducer(draft, action) {
177
+ draft.aiFinanceTeamAcknowledgementStatus = {
178
+ fetchState: 'Error',
179
+ error: action.payload,
180
+ };
181
+ },
182
+ prepare(error) {
183
+ return {
184
+ payload: error,
185
+ };
186
+ },
187
+ },
188
+ acknowledgeOnboardingAiActivationViewed: {
189
+ reducer(draft) {
190
+ draft.aiActivationViewedAcknowledgementStatus = {
191
+ fetchState: 'In-Progress',
192
+ error: undefined,
193
+ };
194
+ },
195
+ prepare(companyId) {
196
+ return {
197
+ payload: { companyId },
198
+ };
199
+ },
200
+ },
201
+ acknowledgeOnboardingAiActivationViewedSuccess(draft) {
202
+ draft.aiActivationViewedAcknowledgementStatus = {
203
+ fetchState: 'Completed',
204
+ error: undefined,
205
+ };
206
+ },
207
+ acknowledgeOnboardingAiActivationViewedFailure: {
208
+ reducer(draft, action) {
209
+ draft.aiActivationViewedAcknowledgementStatus = {
210
+ fetchState: 'Error',
211
+ error: action.payload,
212
+ };
213
+ },
214
+ prepare(error) {
215
+ return {
216
+ payload: error,
217
+ };
218
+ },
219
+ },
220
+ fetchAiAgentsActivationStatus(draft) {
221
+ draft.aiAgentsActivation.fetchStatus = {
222
+ fetchState: 'In-Progress',
223
+ error: undefined,
224
+ };
225
+ },
226
+ fetchAiAgentsActivationStatusSuccess: {
227
+ reducer(draft, action) {
228
+ draft.aiAgentsActivation.fetchStatus = {
229
+ fetchState: 'Completed',
230
+ error: undefined,
231
+ };
232
+ draft.aiAgentsActivation.phases = action.payload.phases;
233
+ draft.aiAgentsActivation.counts = action.payload.counts;
234
+ },
235
+ prepare(payload) {
236
+ return { payload };
237
+ },
238
+ },
239
+ fetchAiAgentsActivationStatusFailure: {
240
+ reducer(draft, action) {
241
+ draft.aiAgentsActivation.fetchStatus = {
242
+ fetchState: 'Error',
243
+ error: action.payload,
244
+ };
245
+ },
246
+ prepare(error) {
247
+ return { payload: error };
248
+ },
249
+ },
250
+ aiAgentsActivationCountsUpdated: {
251
+ reducer(draft, action) {
252
+ draft.aiAgentsActivation.counts = {
253
+ ...draft.aiAgentsActivation.counts,
254
+ ...action.payload,
255
+ };
256
+ },
257
+ prepare(payload) {
258
+ return { payload };
259
+ },
260
+ },
261
+ aiAgentsActivationPhaseChanged: {
262
+ reducer(draft, action) {
263
+ const target = draft.aiAgentsActivation.phases;
264
+ const index = target.findIndex((phase) => phase.key === action.payload.key);
265
+ if (index === -1) {
266
+ target.push(action.payload);
267
+ }
268
+ else {
269
+ target[index] = { ...target[index], ...action.payload };
270
+ }
271
+ },
272
+ prepare(payload) {
273
+ return { payload };
274
+ },
275
+ },
183
276
  updateOnboardingCustomerViewDashboardLoaded: {
184
277
  reducer(draft) {
185
278
  draft.dashboardLoadedStatus = {
@@ -592,7 +685,81 @@ const onboardingCustomerView = createSlice({
592
685
  clearOnboardingCustomerView(draft) {
593
686
  Object.assign(draft, initialState);
594
687
  },
688
+ /** Merge AI-parsed officer fields into the officer's onboarding localData. */
689
+ applyKycDocumentAutofillForOnboarding: {
690
+ reducer(draft, action) {
691
+ const { officerType, values, autoFilledFieldNames, fileId } = action.payload;
692
+ const slot = draft.companyOfficerUpdateStatus[officerType];
693
+ slot.localData = Object.assign({}, slot.localData, values);
694
+ slot.autoFilledFields = Array.from(new Set([...slot.autoFilledFields, ...autoFilledFieldNames]));
695
+ draft.parsingDocumentFileIds = draft.parsingDocumentFileIds.filter((id) => id !== fileId);
696
+ },
697
+ prepare(payload) {
698
+ return { payload };
699
+ },
700
+ },
701
+ /** Merge AI-parsed company fields into companyDetails onboarding localData. */
702
+ applyKybDocumentAutofillForOnboarding: {
703
+ reducer(draft, action) {
704
+ const { values, autoFilledFieldNames, fileId } = action.payload;
705
+ draft.companyDetails.localData = Object.assign({}, draft.companyDetails.localData, values);
706
+ const prev = draft.companyDetails.autoFilledFields ?? [];
707
+ draft.companyDetails.autoFilledFields = Array.from(new Set([...prev, ...autoFilledFieldNames]));
708
+ draft.parsingDocumentFileIds = draft.parsingDocumentFileIds.filter((id) => id !== fileId);
709
+ },
710
+ prepare(payload) {
711
+ return { payload };
712
+ },
713
+ },
714
+ /** Wipe AI-autofill badges during onboarding. */
715
+ clearKycKybAutofillForOnboarding: {
716
+ reducer(draft, action) {
717
+ const { officerType } = action.payload;
718
+ if (officerType != null) {
719
+ draft.companyOfficerUpdateStatus[officerType].autoFilledFields = [];
720
+ }
721
+ else {
722
+ draft.companyDetails.autoFilledFields = [];
723
+ Object.keys(draft.companyOfficerUpdateStatus).forEach((key) => {
724
+ draft.companyOfficerUpdateStatus[key].autoFilledFields = [];
725
+ });
726
+ }
727
+ },
728
+ prepare(payload = {}) {
729
+ return { payload };
730
+ },
731
+ },
732
+ },
733
+ extraReducers: (builder) => {
734
+ const addParsingFileId = (draft, fileId) => {
735
+ if (!draft.parsingDocumentFileIds.includes(fileId)) {
736
+ draft.parsingDocumentFileIds.push(fileId);
737
+ }
738
+ };
739
+ const removeParsingFileId = (draft, fileId) => {
740
+ draft.parsingDocumentFileIds = draft.parsingDocumentFileIds.filter((id) => id !== fileId);
741
+ };
742
+ builder.addCase(parseUploadedKycDocument, (draft, action) => {
743
+ if (action.payload.target === 'onboarding') {
744
+ addParsingFileId(draft, action.payload.fileId);
745
+ }
746
+ });
747
+ builder.addCase(parseUploadedKybDocument, (draft, action) => {
748
+ if (action.payload.target === 'onboarding') {
749
+ addParsingFileId(draft, action.payload.fileId);
750
+ }
751
+ });
752
+ builder.addCase(parseUploadedKycDocumentFailure, (draft, action) => {
753
+ if (action.payload.target === 'onboarding') {
754
+ removeParsingFileId(draft, action.payload.fileId);
755
+ }
756
+ });
757
+ builder.addCase(parseUploadedKybDocumentFailure, (draft, action) => {
758
+ if (action.payload.target === 'onboarding') {
759
+ removeParsingFileId(draft, action.payload.fileId);
760
+ }
761
+ });
595
762
  },
596
763
  });
597
- export const { fetchOnboardingCustomerView, fetchOnboardingCustomerSetupView, fetchOnboardingCustomerSetupViewSuccess, fetchOnboardingCustomerSetupViewFailure, updateOnboardingCustomerViewCompleteStatus, updateOnboardingCustomerViewCompleteStatusSuccess, updateOnboardingCustomerViewCompleteStatusFailure, updateOnboardingCustomerViewDashboardLoaded, updateOnboardingCustomerViewDashboardLoadedSuccess, updateOnboardingCustomerViewDashboardLoadedFailure, updateOnboardingCustomerView, updateOnboardingCustomerViewSuccess, updateOnboardingCustomerViewFailure, updateOnboardingPaymentAccountStatus, updateOnboardingPaymentAccountStatusSuccess, updateOnboardingPaymentAccountStatusFailure, updateOnboardingPaymentAccountLoginStatus, updateOnboardingPaymentAccountLoginStatusSuccess, updateOnboardingPaymentAccountLoginStatusFailure, establishOnboardingPlaidConnection, establishOnboardingPlaidConnectionSuccess, establishOnboardingPlaidConnectionFailure, getOnboardingPlaidLinkToken, getOnboardingPlaidLinkTokenSuccess, getOnboardingPlaidLinkTokenFailure, updateCurrentStep, updateOnboardingCustomerViewAccountDetails, updateOnboardingCustomerViewLocalStoreData, saveOnboardingCustomerViewDataInLocalStore, saveOnboardingCompnayOfficerPhoneInLocalStore, updateOnboardingCustomerViewUIState, sendOnboardingOfficerOtp, sendOnboardingOfficerOtpSuccess, sendOnboardingOfficerOtpFailure, resendOnboardingOfficerOtp, verifyOnboardingOfficerOtp, verifyOnboardingOfficerOtpSuccess, verifyOnboardingOfficerOtpFailure, clearOnboardingCustomerViewDataInLocalStore, clearOnboardingCustomerView, } = onboardingCustomerView.actions;
764
+ export const { fetchOnboardingCustomerView, fetchOnboardingCustomerSetupView, fetchOnboardingCustomerSetupViewSuccess, fetchOnboardingCustomerSetupViewFailure, updateOnboardingCustomerViewCompleteStatus, updateOnboardingCustomerViewCompleteStatusSuccess, updateOnboardingCustomerViewCompleteStatusFailure, acknowledgeOnboardingAiFinanceTeam, acknowledgeOnboardingAiFinanceTeamSuccess, acknowledgeOnboardingAiFinanceTeamFailure, acknowledgeOnboardingAiActivationViewed, acknowledgeOnboardingAiActivationViewedSuccess, acknowledgeOnboardingAiActivationViewedFailure, fetchAiAgentsActivationStatus, fetchAiAgentsActivationStatusSuccess, fetchAiAgentsActivationStatusFailure, aiAgentsActivationCountsUpdated, aiAgentsActivationPhaseChanged, updateOnboardingCustomerViewDashboardLoaded, updateOnboardingCustomerViewDashboardLoadedSuccess, updateOnboardingCustomerViewDashboardLoadedFailure, updateOnboardingCustomerView, updateOnboardingCustomerViewSuccess, updateOnboardingCustomerViewFailure, updateOnboardingPaymentAccountStatus, updateOnboardingPaymentAccountStatusSuccess, updateOnboardingPaymentAccountStatusFailure, updateOnboardingPaymentAccountLoginStatus, updateOnboardingPaymentAccountLoginStatusSuccess, updateOnboardingPaymentAccountLoginStatusFailure, establishOnboardingPlaidConnection, establishOnboardingPlaidConnectionSuccess, establishOnboardingPlaidConnectionFailure, getOnboardingPlaidLinkToken, getOnboardingPlaidLinkTokenSuccess, getOnboardingPlaidLinkTokenFailure, updateCurrentStep, updateOnboardingCustomerViewAccountDetails, updateOnboardingCustomerViewLocalStoreData, saveOnboardingCustomerViewDataInLocalStore, saveOnboardingCompnayOfficerPhoneInLocalStore, updateOnboardingCustomerViewUIState, sendOnboardingOfficerOtp, sendOnboardingOfficerOtpSuccess, sendOnboardingOfficerOtpFailure, resendOnboardingOfficerOtp, verifyOnboardingOfficerOtp, verifyOnboardingOfficerOtpSuccess, verifyOnboardingOfficerOtpFailure, clearOnboardingCustomerViewDataInLocalStore, clearOnboardingCustomerView, applyKycDocumentAutofillForOnboarding, applyKybDocumentAutofillForOnboarding, clearKycKybAutofillForOnboarding, } = onboardingCustomerView.actions;
598
765
  export default onboardingCustomerView.reducer;
@@ -11,7 +11,7 @@ import { getCompanyAndIdentityDetails, } from '../../spendManagement/commonSetup
11
11
  import { ALL_ONBOARDING_STEPS, ALL_ZENI_USER_ONBOARDING_STEPS, REQUIRED_ONBOARDING_STEPS, ZENI_USER_REQUIRED_ONBOARDING_STEPS, toOnboardingStepType, } from './onboardingCustomerViewState';
12
12
  export function getOnboardingCustomerView(state, companyId) {
13
13
  const { fileState, paymentAccountState, onboardingCustomerViewState, userState, userRoleState, subscriptionPaymentAccountState, companyConfigState, cardPaymentViewState, countryListState, addressViewState, } = state;
14
- const { companyDetails, companyOfficerUpdateStatus, primaryContactDetails, subscriptionPaymentAccountIds, paymentAccountDetails, plaidConnectionDetails, updateStatus, saveStatus, currentStep, uiState, fetchState, error, } = onboardingCustomerViewState;
14
+ const { companyDetails, companyOfficerUpdateStatus, primaryContactDetails, subscriptionPaymentAccountIds, paymentAccountDetails, plaidConnectionDetails, parsingDocumentFileIds, updateStatus, saveStatus, currentStep, uiState, fetchState, error, } = onboardingCustomerViewState;
15
15
  const { paymentAccountIds } = paymentAccountDetails;
16
16
  let subscriptionPaymentAccount;
17
17
  let paymentAccount;
@@ -54,6 +54,7 @@ export function getOnboardingCustomerView(state, companyId) {
54
54
  companyDetails,
55
55
  companyOfficerUpdateStatus,
56
56
  primaryContactDetails,
57
+ parsingDocumentFileIds,
57
58
  });
58
59
  const companyAddress = addressViewState.newAddressState?.company_address;
59
60
  if (companyAddress == null &&
@@ -119,6 +120,7 @@ export function getOnboardingCustomerView(state, companyId) {
119
120
  return {
120
121
  companyDetailsLocalData,
121
122
  companyOfficerLocalData,
123
+ parsingDocumentFileIds,
122
124
  subscriptionBillingAddress: subscriptionBillingAddress?.addressToCreate,
123
125
  companyView,
124
126
  allNationalityCountries,
@@ -323,3 +325,7 @@ export const getProductSettingsString = (productSettings) => {
323
325
  .map((key) => productKeyMap[key])
324
326
  .join(',');
325
327
  };
328
+ const fromActivationView = (state) => state.onboardingCustomerViewState.aiAgentsActivation;
329
+ export const getAiAgentsActivationSubview = (state) => fromActivationView(state);
330
+ export const getAiAgentsActivationPhases = (state) => fromActivationView(state).phases;
331
+ export const getAiAgentsActivationCounts = (state) => fromActivationView(state).counts;
@@ -26,3 +26,15 @@ export const ALL_ONBOARDING_STEPS = [
26
26
  ...ALL_ZENI_USER_ONBOARDING_STEPS_WITHOUT_ACCOUNT,
27
27
  ];
28
28
  export const toOnboardingStepType = (v) => stringToUnion(v, ALL_ONBOARDING_STEPS);
29
+ export const emptyAiAgentsActivationCounts = {
30
+ customerCount: 0,
31
+ glAccountCount: 0,
32
+ targetTransactionCount: 0,
33
+ transactionCount: 0,
34
+ vendorCount: 0,
35
+ };
36
+ export const emptyAiAgentsActivationSubview = {
37
+ counts: emptyAiAgentsActivationCounts,
38
+ fetchStatus: { fetchState: 'Not-Started', error: undefined },
39
+ phases: [],
40
+ };