mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
feat: add due bills reducer and selector.
This commit is contained in:
@@ -9,8 +9,18 @@ const billPageSelector = (state, props, query) => {
|
||||
};
|
||||
const billItemsSelector = (state) => state.bills.items;
|
||||
|
||||
/**
|
||||
* Retrieve bill details.
|
||||
* @return {IBill}
|
||||
*/
|
||||
const billByIdSelector = (state, props) => state.bills.items[props.billId];
|
||||
|
||||
/**
|
||||
* Retrieve vendor due bills ids.
|
||||
* @return {number[]}
|
||||
*/
|
||||
const billsDueVendorSelector = (state, props) => state.bills.dueBills[props.vendorId];
|
||||
|
||||
const billPaginationSelector = (state, props) => {
|
||||
const viewId = state.bills.currentViewId;
|
||||
return state.bills.views?.[viewId];
|
||||
@@ -51,3 +61,17 @@ export const getBillPaginationMetaFactory = () =>
|
||||
createSelector(billPaginationSelector, (billPage) => {
|
||||
return billPage?.paginationMeta || {};
|
||||
});
|
||||
|
||||
/**
|
||||
* Retrieve due bills of specific vendor.
|
||||
*/
|
||||
export const getVendorDueBillsFactory = () =>
|
||||
createSelector(
|
||||
billItemsSelector,
|
||||
billsDueVendorSelector,
|
||||
(billsItems, dueBillsIds) => {
|
||||
return Array.isArray(dueBillsIds)
|
||||
? pickItemsFromIds(billsItems, dueBillsIds) || []
|
||||
: [];
|
||||
},
|
||||
);
|
||||
Reference in New Issue
Block a user