@zeniai/client-epic-state 4.18.87 → 4.18.88

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.
@@ -7,6 +7,7 @@ import { RootState } from '../../reducer';
7
7
  import { MonthClosePerformanceTrend } from './monthEndCloseChecksViewState';
8
8
  export interface MonthEndCloseChecksView extends SelectorView {
9
9
  monthClosePerformanceTrend: MonthClosePerformanceTrend[];
10
+ monthClosePerformanceTrendFetchStatus: FetchStateAndError;
10
11
  refreshStatus: FetchStateAndError;
11
12
  selectedPeriod: MonthYearPeriod;
12
13
  monthEndCloseChecks?: MonthEndCloseChecksInfo;
@@ -7,7 +7,6 @@ exports.getMonthEndCloseChecksViewByTenantId = exports.isMonthEndInsightDisabled
7
7
  const toolkit_1 = require("@reduxjs/toolkit");
8
8
  const isEqual_1 = __importDefault(require("lodash/isEqual"));
9
9
  const formatZeniDateFY_1 = require("../../commonStateTypes/fiscalYearHelpers/formatZeniDateFY");
10
- const reduceFetchState_1 = require("../../commonStateTypes/reduceFetchState");
11
10
  const timePeriod_1 = require("../../commonStateTypes/timePeriod");
12
11
  const monthEndCloseChecksSelector_1 = require("../../entity/monthEndCloseChecks/monthEndCloseChecksSelector");
13
12
  const fetchAllTenantsEpic_1 = require("../../entity/tenant/epic/fetchAllTenantsEpic");
@@ -41,27 +40,23 @@ const isMonthEndInsightDisabled = (currentTenant, selectedPeriod, userAllowedToA
41
40
  };
42
41
  exports.isMonthEndInsightDisabled = isMonthEndInsightDisabled;
43
42
  exports.getMonthEndCloseChecksViewByTenantId = (0, toolkit_1.createSelector)((state) => state.monthEndCloseChecksState, (state) => state.monthEndCloseChecksViewState, (state) => state.expenseAutomationViewState, (state) => (0, tenantSelector_1.getCurrentTenant)(state), (state) => state.companyState, (state) => state.tenantState, (_state, tenantId) => tenantId, (monthEndCloseChecksState, monthEndCloseChecksViewState, expenseAutomationViewState, currentTenant, companyState, tenantState, tenantId) => {
44
- var _a, _b, _c, _d, _e;
43
+ var _a, _b, _c, _d, _e, _f, _g;
45
44
  const { refreshStatus } = monthEndCloseChecksViewState;
46
45
  const { loggedInUser } = tenantState;
47
46
  const selectedPeriod = (_a = expenseAutomationViewState.selectedPeriodByTenantId[tenantId]) !== null && _a !== void 0 ? _a : fetchAllTenantsEpic_1.defaultMonthYearPeriod;
48
47
  const { monthEndCloseChecksViewByTenantId, monthClosePerformanceTrend, monthClosePerformanceTrendFetchStatus, } = monthEndCloseChecksViewState;
49
48
  const monthClosePerformanceTrendForSelectedPeriod = (_b = monthClosePerformanceTrend[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)]) !== null && _b !== void 0 ? _b : [];
50
- const monthYearPeriodId = selectedPeriod != null ? (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod) : null;
51
- const monthEndCloseChecksView = monthYearPeriodId != null
52
- ? (_c = monthEndCloseChecksViewByTenantId[tenantId]) === null || _c === void 0 ? void 0 : _c[monthYearPeriodId]
53
- : undefined;
54
- const monthEndCloseChecks = monthYearPeriodId != null
55
- ? (0, monthEndCloseChecksSelector_1.getMonthEndCloseChecksByTenantId)(monthEndCloseChecksState, tenantId, monthYearPeriodId)
56
- : undefined;
49
+ const monthYearPeriodId = (0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod);
50
+ const monthEndCloseChecksView = (_c = monthEndCloseChecksViewByTenantId[tenantId]) === null || _c === void 0 ? void 0 : _c[monthYearPeriodId];
51
+ const monthEndCloseChecks = (0, monthEndCloseChecksSelector_1.getMonthEndCloseChecksByTenantId)(monthEndCloseChecksState, tenantId, monthYearPeriodId);
57
52
  if (monthEndCloseChecksView != null && monthEndCloseChecks != null) {
58
53
  const sortedMonthEndCloseCheckList = [
59
54
  ...monthEndCloseChecks.monthEndCloseCheckList,
60
55
  ].sort((a, b) => b.frequency.localeCompare(a.frequency));
61
56
  const currentCompany = companyState.companiesById[currentTenant.companyId];
62
57
  const managementInfo = currentCompany === null || currentCompany === void 0 ? void 0 : currentCompany.managementInfo;
63
- const preparerUserIds = managementInfo != null ? managementInfo.preparerUserIds : [];
64
- const isZeniUser = Boolean((_d = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.userEmail) === null || _d === void 0 ? void 0 : _d.includes('zeni.ai'));
58
+ const preparerUserIds = (_d = managementInfo === null || managementInfo === void 0 ? void 0 : managementInfo.preparerUserIds) !== null && _d !== void 0 ? _d : [];
59
+ const isZeniUser = Boolean((_e = loggedInUser === null || loggedInUser === void 0 ? void 0 : loggedInUser.userEmail) === null || _e === void 0 ? void 0 : _e.includes('zeni.ai'));
65
60
  const isPreparer = loggedInUser != null && preparerUserIds.includes(loggedInUser.userId);
66
61
  const userAllowedToAccessMonthEndInsights = isZeniUser === false || isPreparer === false;
67
62
  const monthEndCloseCheckListWithDisabledState = sortedMonthEndCloseCheckList.map((check) => {
@@ -73,12 +68,11 @@ exports.getMonthEndCloseChecksViewByTenantId = (0, toolkit_1.createSelector)((st
73
68
  }
74
69
  return check;
75
70
  });
76
- const combinedFetchState = (0, reduceFetchState_1.reduceAnyFetchState)([
77
- monthEndCloseChecksView,
78
- (_e = monthClosePerformanceTrendFetchStatus[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)]) !== null && _e !== void 0 ? _e : { fetchState: 'Not-Started' },
79
- ]);
80
- return Object.assign(Object.assign({}, monthEndCloseChecksView), { fetchState: combinedFetchState.fetchState, error: combinedFetchState.error, monthEndCloseChecks: Object.assign(Object.assign({}, monthEndCloseChecks), { monthEndCloseCheckList: monthEndCloseCheckListWithDisabledState }), reportId: 'expense_automation_card', selectedPeriod,
81
- refreshStatus, monthClosePerformanceTrend: monthClosePerformanceTrendForSelectedPeriod });
71
+ return Object.assign(Object.assign({}, monthEndCloseChecksView), { fetchState: monthEndCloseChecksView.fetchState, error: monthEndCloseChecksView.error, monthEndCloseChecks: Object.assign(Object.assign({}, monthEndCloseChecks), { monthEndCloseCheckList: monthEndCloseCheckListWithDisabledState }), reportId: 'expense_automation_card', selectedPeriod,
72
+ refreshStatus, monthClosePerformanceTrend: monthClosePerformanceTrendForSelectedPeriod, monthClosePerformanceTrendFetchStatus: (_f = monthClosePerformanceTrendFetchStatus[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)]) !== null && _f !== void 0 ? _f : {
73
+ fetchState: 'Not-Started',
74
+ error: undefined,
75
+ } });
82
76
  }
83
77
  return {
84
78
  fetchState: 'Not-Started',
@@ -87,5 +81,9 @@ exports.getMonthEndCloseChecksViewByTenantId = (0, toolkit_1.createSelector)((st
87
81
  selectedPeriod,
88
82
  refreshStatus,
89
83
  monthClosePerformanceTrend: monthClosePerformanceTrendForSelectedPeriod,
84
+ monthClosePerformanceTrendFetchStatus: (_g = monthClosePerformanceTrendFetchStatus[(0, timePeriod_1.toMonthYearPeriodId)(selectedPeriod)]) !== null && _g !== void 0 ? _g : {
85
+ fetchState: 'Not-Started',
86
+ error: undefined,
87
+ },
90
88
  };
91
89
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "4.18.87",
3
+ "version": "4.18.88",
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
  "types": "lib/index.d.ts",