mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06:40:31 +00:00
refactoring: inventory adjustments list.
refactoring: items categories list.
This commit is contained in:
@@ -1,36 +1,18 @@
|
||||
import { createSelector } from '@reduxjs/toolkit';
|
||||
import {
|
||||
pickItemsFromIds,
|
||||
paginationLocationQuery,
|
||||
defaultPaginationMeta,
|
||||
} from 'store/selectors';
|
||||
|
||||
const inventoryAdjustmentTableQuery = (state) =>
|
||||
state.inventoryAdjustments.tableQuery;
|
||||
const inventoryAdjustmentTableState = (state) =>
|
||||
state.inventoryAdjustments.tableState;
|
||||
|
||||
const inventoryAdjustmentsPaginationSelector = (state, props) => {
|
||||
const viewId = state.inventoryAdjustments.currentViewId;
|
||||
return state.inventoryAdjustments.views?.[viewId];
|
||||
};
|
||||
|
||||
const inventoryAdjustmentItemsSelector = (state) =>
|
||||
state.inventoryAdjustments.items;
|
||||
|
||||
const inventoryAdjustmentCurrentPageSelector = (state, props) => {
|
||||
const currentViewId = state.inventoryAdjustments.currentViewId;
|
||||
const currentView = state.inventoryAdjustments.views?.[currentViewId];
|
||||
const currentPageId = currentView?.paginationMeta?.page;
|
||||
|
||||
return currentView?.pages?.[currentPageId];
|
||||
};
|
||||
|
||||
const getinventoryAdjustmentCurrentViewIdSelector = (state) =>
|
||||
state.inventoryAdjustments.currentViewId;
|
||||
|
||||
export const getInvoiceTableQueryFactory = () =>
|
||||
/**
|
||||
* Retrieve the inventory adjustments table state.
|
||||
*/
|
||||
export const getInventroyAdjsTableStateFactory = () =>
|
||||
createSelector(
|
||||
paginationLocationQuery,
|
||||
inventoryAdjustmentTableQuery,
|
||||
inventoryAdjustmentTableState,
|
||||
(locationQuery, tableQuery) => {
|
||||
return {
|
||||
...locationQuery,
|
||||
@@ -38,22 +20,3 @@ export const getInvoiceTableQueryFactory = () =>
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
export const getInventoryAdjustmentCurrentPageFactory = () =>
|
||||
createSelector(
|
||||
inventoryAdjustmentCurrentPageSelector,
|
||||
inventoryAdjustmentItemsSelector,
|
||||
(currentPage, items) => {
|
||||
return typeof currentPage === 'object'
|
||||
? pickItemsFromIds(items, currentPage.ids) || []
|
||||
: [];
|
||||
},
|
||||
);
|
||||
|
||||
export const getInventoryAdjustmentPaginationMetaFactory = () =>
|
||||
createSelector(inventoryAdjustmentsPaginationSelector, (Page) => {
|
||||
return {
|
||||
...defaultPaginationMeta(),
|
||||
...(Page?.paginationMeta || {}),
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user