@zeniai/client-epic-state 5.1.34-betaAK1 → 5.1.34-betaAK2

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.
@@ -1,9 +1,16 @@
1
+ import { createSelector } from '@reduxjs/toolkit';
1
2
  import { getInvoicingCustomersByIds } from '../../../entity/invoicing/invoicingCustomer/invoicingCustomerSelector';
2
- export const getInvoicingCustomerListView = (state) => ({
3
- customers: getInvoicingCustomersByIds(state.invoicingCustomerState, state.invoicingCustomerListViewState.ids),
4
- fetchState: state.invoicingCustomerListViewState.fetchState,
5
- error: state.invoicingCustomerListViewState.error,
6
- nextCursor: state.invoicingCustomerListViewState.nextCursor,
7
- filters: state.invoicingCustomerListViewState.filters,
8
- count: state.invoicingCustomerListViewState.counts,
9
- });
3
+ /**
4
+ * Memoized so the denormalized `customers` array (and the wrapping view object)
5
+ * keep referential identity until the customer entity slice or the list-view
6
+ * slice actually change. Without this, the connected list page re-rendered on
7
+ * every unrelated redux action because a fresh array was built each call.
8
+ */
9
+ export const getInvoicingCustomerListView = createSelector((state) => state.invoicingCustomerState, (state) => state.invoicingCustomerListViewState, (customerState, listViewState) => ({
10
+ customers: getInvoicingCustomersByIds(customerState, listViewState.ids),
11
+ fetchState: listViewState.fetchState,
12
+ error: listViewState.error,
13
+ nextCursor: listViewState.nextCursor,
14
+ filters: listViewState.filters,
15
+ count: listViewState.counts,
16
+ }));
@@ -1,9 +1,17 @@
1
+ import { createSelector } from '@reduxjs/toolkit';
1
2
  import { getInvoicingSubscriptionsByIds } from '../../../entity/invoicing/invoicingSubscription/invoicingSubscriptionSelector';
2
- export const getInvoicingSubscriptionListView = (state) => ({
3
- subscriptions: getInvoicingSubscriptionsByIds(state.invoicingSubscriptionState, state.invoicingSubscriptionListViewState.ids),
4
- fetchState: state.invoicingSubscriptionListViewState.fetchState,
5
- error: state.invoicingSubscriptionListViewState.error,
6
- nextCursor: state.invoicingSubscriptionListViewState.nextCursor,
7
- filters: state.invoicingSubscriptionListViewState.filters,
8
- count: state.invoicingSubscriptionListViewState.counts,
9
- });
3
+ /**
4
+ * Memoized so the denormalized `subscriptions` array (and the wrapping view
5
+ * object) keep referential identity until the subscription entity slice or the
6
+ * list-view slice actually change. Without this, the connected list page
7
+ * re-rendered on every unrelated redux action because a fresh array was built
8
+ * each call.
9
+ */
10
+ export const getInvoicingSubscriptionListView = createSelector((state) => state.invoicingSubscriptionState, (state) => state.invoicingSubscriptionListViewState, (subscriptionState, listViewState) => ({
11
+ subscriptions: getInvoicingSubscriptionsByIds(subscriptionState, listViewState.ids),
12
+ fetchState: listViewState.fetchState,
13
+ error: listViewState.error,
14
+ nextCursor: listViewState.nextCursor,
15
+ filters: listViewState.filters,
16
+ count: listViewState.counts,
17
+ }));
@@ -3,7 +3,6 @@ import { from, of } from 'rxjs';
3
3
  import { catchError, filter, mergeMap } from 'rxjs/operators';
4
4
  import { toRecommendationPayload } from '../../../commonPayloadTypes/recommendationPayload';
5
5
  import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
6
- import { getIsAccountingProjectsEnabled } from '../../../entity/tenant/tenantSelector';
7
6
  import { toCustomerTransactionPayload } from '../../../entity/transaction/payloadTypes/customerTransactionPayload';
8
7
  import { toTransferTransactionPayload } from '../../../entity/transaction/payloadTypes/otherTransactionPayload';
9
8
  import { toTransactionID } from '../../../entity/transaction/payloadTypes/transactionIDPayload';
@@ -20,6 +19,7 @@ import { getSupportedTransactionById } from '../../../entity/transaction/transac
20
19
  import { updateVendors } from '../../../entity/vendor/vendorReducer';
21
20
  import { getVendorByVendorId } from '../../../entity/vendor/vendorSelector';
22
21
  import { createZeniAPIStatus, isActionNotAllowed, isSuccessResponse, } from '../../../responsePayload';
22
+ import { getIsAccountingClassesEnabled, getIsAccountingProjectsEnabled, } from '../../../entity/tenant/tenantSelector';
23
23
  import { getUncategorizedAccounts } from '../../accountList/accountListSelector';
24
24
  import { getPendingReviewLineIdsFromTransaction } from '../../expenseAutomationView/helpers/transactionCategorizationLocalDataHelper';
25
25
  import { syncTransactionCategorizationFromDetailSave } from '../../expenseAutomationView/reducers/transactionsViewReducer';
@@ -69,7 +69,9 @@ export const updateTransactionDetailEpic = (actions$, state$, zeniAPI) => action
69
69
  // then we need to skip mark-miscategorized-as-correct api call
70
70
  if (toVendorTransactionTypeStrict(response.data.transaction.transaction_type) != null ||
71
71
  toJEAndDepositTransactionTypeStrict(response.data.transaction.transaction_type) != null) {
72
- const isAnyClassMissing = checkIfClassMissingForAnyLineItem(response.data.transaction);
72
+ const isAccountingClassesEnabled = getIsAccountingClassesEnabled(state$.value);
73
+ const isAnyClassMissing = isAccountingClassesEnabled &&
74
+ checkIfClassMissingForAnyLineItem(response.data.transaction);
73
75
  const isVendorOrCustomerMissingInAnyLine = toJEAndDepositTransactionTypeStrict(response.data.transaction.transaction_type) != null &&
74
76
  checkIfVendorOrCustomerMissingForAnyLineItem(response.data.transaction);
75
77
  if ((vendorUpdates?.id == null &&
@@ -9,4 +9,10 @@ export interface InvoicingCustomerListView extends SelectorView {
9
9
  filters: InvoicingCustomerFilters;
10
10
  nextCursor: string | null;
11
11
  }
12
+ /**
13
+ * Memoized so the denormalized `customers` array (and the wrapping view object)
14
+ * keep referential identity until the customer entity slice or the list-view
15
+ * slice actually change. Without this, the connected list page re-rendered on
16
+ * every unrelated redux action because a fresh array was built each call.
17
+ */
12
18
  export declare const getInvoicingCustomerListView: (state: RootState) => InvoicingCustomerListView;
@@ -1,13 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getInvoicingCustomerListView = void 0;
4
+ const toolkit_1 = require("@reduxjs/toolkit");
4
5
  const invoicingCustomerSelector_1 = require("../../../entity/invoicing/invoicingCustomer/invoicingCustomerSelector");
5
- const getInvoicingCustomerListView = (state) => ({
6
- customers: (0, invoicingCustomerSelector_1.getInvoicingCustomersByIds)(state.invoicingCustomerState, state.invoicingCustomerListViewState.ids),
7
- fetchState: state.invoicingCustomerListViewState.fetchState,
8
- error: state.invoicingCustomerListViewState.error,
9
- nextCursor: state.invoicingCustomerListViewState.nextCursor,
10
- filters: state.invoicingCustomerListViewState.filters,
11
- count: state.invoicingCustomerListViewState.counts,
12
- });
13
- exports.getInvoicingCustomerListView = getInvoicingCustomerListView;
6
+ /**
7
+ * Memoized so the denormalized `customers` array (and the wrapping view object)
8
+ * keep referential identity until the customer entity slice or the list-view
9
+ * slice actually change. Without this, the connected list page re-rendered on
10
+ * every unrelated redux action because a fresh array was built each call.
11
+ */
12
+ exports.getInvoicingCustomerListView = (0, toolkit_1.createSelector)((state) => state.invoicingCustomerState, (state) => state.invoicingCustomerListViewState, (customerState, listViewState) => ({
13
+ customers: (0, invoicingCustomerSelector_1.getInvoicingCustomersByIds)(customerState, listViewState.ids),
14
+ fetchState: listViewState.fetchState,
15
+ error: listViewState.error,
16
+ nextCursor: listViewState.nextCursor,
17
+ filters: listViewState.filters,
18
+ count: listViewState.counts,
19
+ }));
@@ -9,4 +9,11 @@ export interface InvoicingSubscriptionListView extends SelectorView {
9
9
  nextCursor: string | null;
10
10
  subscriptions: InvoicingSubscription[];
11
11
  }
12
+ /**
13
+ * Memoized so the denormalized `subscriptions` array (and the wrapping view
14
+ * object) keep referential identity until the subscription entity slice or the
15
+ * list-view slice actually change. Without this, the connected list page
16
+ * re-rendered on every unrelated redux action because a fresh array was built
17
+ * each call.
18
+ */
12
19
  export declare const getInvoicingSubscriptionListView: (state: RootState) => InvoicingSubscriptionListView;
@@ -1,13 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getInvoicingSubscriptionListView = void 0;
4
+ const toolkit_1 = require("@reduxjs/toolkit");
4
5
  const invoicingSubscriptionSelector_1 = require("../../../entity/invoicing/invoicingSubscription/invoicingSubscriptionSelector");
5
- const getInvoicingSubscriptionListView = (state) => ({
6
- subscriptions: (0, invoicingSubscriptionSelector_1.getInvoicingSubscriptionsByIds)(state.invoicingSubscriptionState, state.invoicingSubscriptionListViewState.ids),
7
- fetchState: state.invoicingSubscriptionListViewState.fetchState,
8
- error: state.invoicingSubscriptionListViewState.error,
9
- nextCursor: state.invoicingSubscriptionListViewState.nextCursor,
10
- filters: state.invoicingSubscriptionListViewState.filters,
11
- count: state.invoicingSubscriptionListViewState.counts,
12
- });
13
- exports.getInvoicingSubscriptionListView = getInvoicingSubscriptionListView;
6
+ /**
7
+ * Memoized so the denormalized `subscriptions` array (and the wrapping view
8
+ * object) keep referential identity until the subscription entity slice or the
9
+ * list-view slice actually change. Without this, the connected list page
10
+ * re-rendered on every unrelated redux action because a fresh array was built
11
+ * each call.
12
+ */
13
+ exports.getInvoicingSubscriptionListView = (0, toolkit_1.createSelector)((state) => state.invoicingSubscriptionState, (state) => state.invoicingSubscriptionListViewState, (subscriptionState, listViewState) => ({
14
+ subscriptions: (0, invoicingSubscriptionSelector_1.getInvoicingSubscriptionsByIds)(subscriptionState, listViewState.ids),
15
+ fetchState: listViewState.fetchState,
16
+ error: listViewState.error,
17
+ nextCursor: listViewState.nextCursor,
18
+ filters: listViewState.filters,
19
+ count: listViewState.counts,
20
+ }));
@@ -9,7 +9,6 @@ const rxjs_1 = require("rxjs");
9
9
  const operators_1 = require("rxjs/operators");
10
10
  const recommendationPayload_1 = require("../../../commonPayloadTypes/recommendationPayload");
11
11
  const snackbarReducer_1 = require("../../../entity/snackbar/snackbarReducer");
12
- const tenantSelector_1 = require("../../../entity/tenant/tenantSelector");
13
12
  const customerTransactionPayload_1 = require("../../../entity/transaction/payloadTypes/customerTransactionPayload");
14
13
  const otherTransactionPayload_1 = require("../../../entity/transaction/payloadTypes/otherTransactionPayload");
15
14
  const transactionIDPayload_1 = require("../../../entity/transaction/payloadTypes/transactionIDPayload");
@@ -26,6 +25,7 @@ const transactionSelector_1 = require("../../../entity/transaction/transactionSe
26
25
  const vendorReducer_1 = require("../../../entity/vendor/vendorReducer");
27
26
  const vendorSelector_1 = require("../../../entity/vendor/vendorSelector");
28
27
  const responsePayload_1 = require("../../../responsePayload");
28
+ const tenantSelector_1 = require("../../../entity/tenant/tenantSelector");
29
29
  const accountListSelector_1 = require("../../accountList/accountListSelector");
30
30
  const transactionCategorizationLocalDataHelper_1 = require("../../expenseAutomationView/helpers/transactionCategorizationLocalDataHelper");
31
31
  const transactionsViewReducer_1 = require("../../expenseAutomationView/reducers/transactionsViewReducer");
@@ -75,7 +75,9 @@ const updateTransactionDetailEpic = (actions$, state$, zeniAPI) => actions$.pipe
75
75
  // then we need to skip mark-miscategorized-as-correct api call
76
76
  if ((0, transactionType_1.toVendorTransactionTypeStrict)(response.data.transaction.transaction_type) != null ||
77
77
  (0, transactionType_1.toJEAndDepositTransactionTypeStrict)(response.data.transaction.transaction_type) != null) {
78
- const isAnyClassMissing = checkIfClassMissingForAnyLineItem(response.data.transaction);
78
+ const isAccountingClassesEnabled = (0, tenantSelector_1.getIsAccountingClassesEnabled)(state$.value);
79
+ const isAnyClassMissing = isAccountingClassesEnabled &&
80
+ checkIfClassMissingForAnyLineItem(response.data.transaction);
79
81
  const isVendorOrCustomerMissingInAnyLine = (0, transactionType_1.toJEAndDepositTransactionTypeStrict)(response.data.transaction.transaction_type) != null &&
80
82
  checkIfVendorOrCustomerMissingForAnyLineItem(response.data.transaction);
81
83
  if ((vendorUpdates?.id == null &&
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.1.34-betaAK1",
3
+ "version": "5.1.34-betaAK2",
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",