Files
bigcapital/packages/webapp/src/store/items/items.selectors.tsx
2023-02-03 01:02:31 +02:00

27 lines
772 B
TypeScript

// @ts-nocheck
import { isEqual } from 'lodash';
import { paginationLocationQuery } from '@/store/selectors';
import { createDeepEqualSelector } from '@/utils';
import { defaultTableQuery } from './items.reducer';
const itemsTableStateSelector = (state) => state.items.tableState;
// Get items table state marged with location query.
export const getItemsTableStateFactory = () =>
createDeepEqualSelector(
paginationLocationQuery,
itemsTableStateSelector,
(locationQuery, tableState) => {
return {
...locationQuery,
...tableState,
};
},
);
export const isItemsTableStateChangedFactory = () =>
createDeepEqualSelector(itemsTableStateSelector, (tableState) => {
return !isEqual(tableState, defaultTableQuery);
});