mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 14:20:31 +00:00
Fix :empty status with Vendor Table.
This commit is contained in:
@@ -32,6 +32,7 @@ function VendorsTable({
|
|||||||
vendorsPageination,
|
vendorsPageination,
|
||||||
vendorTableQuery,
|
vendorTableQuery,
|
||||||
vendorItems,
|
vendorItems,
|
||||||
|
vendorsCurrentViewId,
|
||||||
|
|
||||||
// #withVendorsActions
|
// #withVendorsActions
|
||||||
addVendorsTableQueries,
|
addVendorsTableQueries,
|
||||||
@@ -182,6 +183,10 @@ function VendorsTable({
|
|||||||
onEditVendor,
|
onEditVendor,
|
||||||
onDeleteVendor,
|
onDeleteVendor,
|
||||||
});
|
});
|
||||||
|
const showEmptyStatus = [
|
||||||
|
vendorsCurrentViewId === -1,
|
||||||
|
vendorItems.length === 0,
|
||||||
|
].every((condition) => condition === true);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(CLASSES.DASHBOARD_DATATABLE)}>
|
<div className={classNames(CLASSES.DASHBOARD_DATATABLE)}>
|
||||||
@@ -190,7 +195,7 @@ function VendorsTable({
|
|||||||
mount={false}
|
mount={false}
|
||||||
>
|
>
|
||||||
<Choose>
|
<Choose>
|
||||||
<Choose.When condition={true}>
|
<Choose.When condition={showEmptyStatus}>
|
||||||
<VendorsEmptyStatus />
|
<VendorsEmptyStatus />
|
||||||
</Choose.When>
|
</Choose.When>
|
||||||
|
|
||||||
@@ -228,11 +233,13 @@ export default compose(
|
|||||||
vendorsLoading,
|
vendorsLoading,
|
||||||
vendorTableQuery,
|
vendorTableQuery,
|
||||||
vendorsPageination,
|
vendorsPageination,
|
||||||
|
vendorsCurrentViewId,
|
||||||
}) => ({
|
}) => ({
|
||||||
vendorItems,
|
vendorItems,
|
||||||
vendorsLoading,
|
vendorsLoading,
|
||||||
vendorsPageination,
|
vendorsPageination,
|
||||||
vendorTableQuery,
|
vendorTableQuery,
|
||||||
|
vendorsCurrentViewId,
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
withVendorsActions,
|
withVendorsActions,
|
||||||
|
|||||||
@@ -5,11 +5,13 @@ import {
|
|||||||
getVendorCurrentPageFactory,
|
getVendorCurrentPageFactory,
|
||||||
getVendorsTableQuery,
|
getVendorsTableQuery,
|
||||||
getVendorsPaginationMetaFactory,
|
getVendorsPaginationMetaFactory,
|
||||||
|
getVendorsCurrentViewIdFactory,
|
||||||
} from 'store/vendors/vendors.selectors';
|
} from 'store/vendors/vendors.selectors';
|
||||||
|
|
||||||
export default (mapState) => {
|
export default (mapState) => {
|
||||||
const getVendorsItems = getVendorCurrentPageFactory();
|
const getVendorsItems = getVendorCurrentPageFactory();
|
||||||
const getVendorsPaginationMeta = getVendorsPaginationMetaFactory();
|
const getVendorsPaginationMeta = getVendorsPaginationMetaFactory();
|
||||||
|
const getVendorsCurrentViewId = getVendorsCurrentViewIdFactory();
|
||||||
const mapStateToProps = (state, props) => {
|
const mapStateToProps = (state, props) => {
|
||||||
const query = getVendorsTableQuery(state, props);
|
const query = getVendorsTableQuery(state, props);
|
||||||
|
|
||||||
@@ -20,6 +22,7 @@ export default (mapState) => {
|
|||||||
vendorTableQuery: query,
|
vendorTableQuery: query,
|
||||||
vendorsPageination: getVendorsPaginationMeta(state, props, query),
|
vendorsPageination: getVendorsPaginationMeta(state, props, query),
|
||||||
vendorsLoading: state.vendors.loading,
|
vendorsLoading: state.vendors.loading,
|
||||||
|
vendorsCurrentViewId: getVendorsCurrentViewId(state, props),
|
||||||
};
|
};
|
||||||
return mapState ? mapState(mapped, state, props) : mapped;
|
return mapState ? mapState(mapped, state, props) : mapped;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ const vendorByIdSelector = (state, props) =>
|
|||||||
state.vendors.items[props.vendorId];
|
state.vendors.items[props.vendorId];
|
||||||
const vendorsItemsSelector = (state) => state.vendors.items;
|
const vendorsItemsSelector = (state) => state.vendors.items;
|
||||||
|
|
||||||
|
const vendorsCurrentViewIdSelector = (state) => state.vendors.currentViewId;
|
||||||
|
|
||||||
const vendorsPaginationSelector = (state, props) => {
|
const vendorsPaginationSelector = (state, props) => {
|
||||||
const viewId = state.vendors.currentViewId;
|
const viewId = state.vendors.currentViewId;
|
||||||
return state.vendors.views?.[viewId];
|
return state.vendors.views?.[viewId];
|
||||||
@@ -57,3 +59,8 @@ export const getVendorByIdFactory = () =>
|
|||||||
createSelector(vendorByIdSelector, (vendor) => {
|
createSelector(vendorByIdSelector, (vendor) => {
|
||||||
return vendor;
|
return vendor;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const getVendorsCurrentViewIdFactory = () =>
|
||||||
|
createSelector(vendorsCurrentViewIdSelector, (currentViewId) => {
|
||||||
|
return currentViewId;
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user