@zeniai/client-epic-state 4.19.99-betaRD4 → 4.19.99-betaRD6

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.
@@ -28,6 +28,7 @@ export const getAiAccountantCockpitView = createSelector((state) => state.aiAcco
28
28
  const sortedCustomers = getSortedCustomers(filteredCustomers, uiState.sortKey, uiState.sortOrder);
29
29
  const selectedCustomersForJobTrigger = allCustomers.filter((customer) => selectedTenantIdsForJobTrigger.includes(customer.tenantId));
30
30
  return {
31
+ averageAccuracy: calcOverallAverageAccuracy(allCustomers),
31
32
  fetchState: customersFetchStatus.fetchState,
32
33
  error: customersFetchStatus.error,
33
34
  customers: sortedCustomers,
@@ -59,3 +60,13 @@ const getSortedCustomers = (customers, sortKey, sortOrder) => {
59
60
  }
60
61
  }, direction);
61
62
  };
63
+ const calcOverallAverageAccuracy = (customers) => {
64
+ const customerAccuracies = customers
65
+ .map((customer) => customer.averageAccuracy)
66
+ .filter((accuracy) => accuracy > 0);
67
+ if (customerAccuracies.length === 0) {
68
+ return 0;
69
+ }
70
+ return (customerAccuracies.reduce((sum, accuracy) => sum + accuracy, 0) /
71
+ customerAccuracies.length);
72
+ };
@@ -1,5 +1,6 @@
1
- import { from, of } from 'rxjs';
1
+ import { from } from 'rxjs';
2
2
  import { catchError, filter, mergeMap } from 'rxjs/operators';
3
+ import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
3
4
  import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
4
5
  import { cancelAiAccountantOnboarding, cancelAiAccountantOnboardingFailure, cancelAiAccountantOnboardingSuccess, fetchAiAccountantCustomers, } from '../aiAccountantViewReducer';
5
6
  export const cancelAiAccountantOnboardingEpic = (actions$, _, zeniAPI) => actions$.pipe(filter(cancelAiAccountantOnboarding.match), mergeMap((action) => {
@@ -16,11 +17,30 @@ export const cancelAiAccountantOnboardingEpic = (actions$, _, zeniAPI) => action
16
17
  return from([
17
18
  cancelAiAccountantOnboardingSuccess(tenantId),
18
19
  fetchAiAccountantCustomers(),
20
+ openSnackbar({
21
+ messageSection: 'common',
22
+ messageText: 'success',
23
+ type: 'success',
24
+ }),
19
25
  ]);
20
26
  }
21
27
  else {
22
- return of(cancelAiAccountantOnboardingFailure(tenantId, response.status));
28
+ return from([
29
+ cancelAiAccountantOnboardingFailure(tenantId, response.status),
30
+ openSnackbar({
31
+ messageSection: 'common',
32
+ messageText: 'failed',
33
+ type: 'error',
34
+ }),
35
+ ]);
23
36
  }
24
- }), catchError((error) => of(cancelAiAccountantOnboardingFailure(tenantId, createZeniAPIStatus('Unexpected error', 'AI Accountant cancel onboarding failed: ' +
25
- JSON.stringify(error))))));
37
+ }), catchError((error) => from([
38
+ cancelAiAccountantOnboardingFailure(tenantId, createZeniAPIStatus('Unexpected error', 'AI Accountant cancel onboarding failed: ' +
39
+ JSON.stringify(error))),
40
+ openSnackbar({
41
+ messageSection: 'common',
42
+ messageText: 'failed',
43
+ type: 'error',
44
+ }),
45
+ ])));
26
46
  }));
@@ -1,5 +1,6 @@
1
- import { from, of } from 'rxjs';
1
+ import { from } from 'rxjs';
2
2
  import { catchError, filter, mergeMap } from 'rxjs/operators';
3
+ import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
3
4
  import { createZeniAPIStatus, isSuccessResponse } from '../../../responsePayload';
4
5
  import { fetchAiAccountantCustomers, triggerAiAccountantJob, triggerAiAccountantJobFailure, triggerAiAccountantJobSuccess, } from '../aiAccountantViewReducer';
5
6
  export const triggerAiAccountantJobEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(triggerAiAccountantJob.match), mergeMap((action) => {
@@ -29,11 +30,30 @@ export const triggerAiAccountantJobEpic = (actions$, state$, zeniAPI) => actions
29
30
  return from([
30
31
  triggerAiAccountantJobSuccess(),
31
32
  fetchAiAccountantCustomers(),
33
+ openSnackbar({
34
+ messageSection: 'common',
35
+ messageText: 'success',
36
+ type: 'success',
37
+ }),
32
38
  ]);
33
39
  }
34
40
  else {
35
- return of(triggerAiAccountantJobFailure(response.status));
41
+ return from([
42
+ triggerAiAccountantJobFailure(response.status),
43
+ openSnackbar({
44
+ messageSection: 'common',
45
+ messageText: 'failed',
46
+ type: 'error',
47
+ }),
48
+ ]);
36
49
  }
37
- }), catchError((error) => of(triggerAiAccountantJobFailure(createZeniAPIStatus('Unexpected error', 'AI Accountant trigger job failed: ' +
38
- JSON.stringify(error))))));
50
+ }), catchError((error) => from([
51
+ triggerAiAccountantJobFailure(createZeniAPIStatus('Unexpected error', 'AI Accountant trigger job failed: ' +
52
+ JSON.stringify(error))),
53
+ openSnackbar({
54
+ messageSection: 'common',
55
+ messageText: 'failed',
56
+ type: 'error',
57
+ }),
58
+ ])));
39
59
  }));