mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 06:10:31 +00:00
feat: adjustments.
This commit is contained in:
@@ -5,3 +5,55 @@ import {
|
||||
defaultPaginationMeta,
|
||||
} from 'store/selectors';
|
||||
|
||||
const inventoryAdjustmentTableQuery = (state) =>
|
||||
state.inventoryAdjustments.tableQuery;
|
||||
|
||||
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 = () =>
|
||||
createSelector(
|
||||
paginationLocationQuery,
|
||||
inventoryAdjustmentTableQuery,
|
||||
(locationQuery, tableQuery) => {
|
||||
return {
|
||||
...locationQuery,
|
||||
...tableQuery,
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
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