From f071475b4f8347addedf3c1ee285ec3da96dfbe7 Mon Sep 17 00:00:00 2001 From: elforjani3 Date: Sat, 28 Nov 2020 19:39:07 +0200 Subject: [PATCH] Fix :empty status with Vendor Table. --- client/src/containers/Vendors/VendorsTable.js | 9 ++++++++- client/src/containers/Vendors/withVendors.js | 3 +++ client/src/store/vendors/vendors.selectors.js | 7 +++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/client/src/containers/Vendors/VendorsTable.js b/client/src/containers/Vendors/VendorsTable.js index 8f9936df1..e35676940 100644 --- a/client/src/containers/Vendors/VendorsTable.js +++ b/client/src/containers/Vendors/VendorsTable.js @@ -32,6 +32,7 @@ function VendorsTable({ vendorsPageination, vendorTableQuery, vendorItems, + vendorsCurrentViewId, // #withVendorsActions addVendorsTableQueries, @@ -182,6 +183,10 @@ function VendorsTable({ onEditVendor, onDeleteVendor, }); + const showEmptyStatus = [ + vendorsCurrentViewId === -1, + vendorItems.length === 0, + ].every((condition) => condition === true); return (
@@ -190,7 +195,7 @@ function VendorsTable({ mount={false} > - + @@ -228,11 +233,13 @@ export default compose( vendorsLoading, vendorTableQuery, vendorsPageination, + vendorsCurrentViewId, }) => ({ vendorItems, vendorsLoading, vendorsPageination, vendorTableQuery, + vendorsCurrentViewId, }), ), withVendorsActions, diff --git a/client/src/containers/Vendors/withVendors.js b/client/src/containers/Vendors/withVendors.js index e9846f243..8a4c36ee6 100644 --- a/client/src/containers/Vendors/withVendors.js +++ b/client/src/containers/Vendors/withVendors.js @@ -5,11 +5,13 @@ import { getVendorCurrentPageFactory, getVendorsTableQuery, getVendorsPaginationMetaFactory, + getVendorsCurrentViewIdFactory, } from 'store/vendors/vendors.selectors'; export default (mapState) => { const getVendorsItems = getVendorCurrentPageFactory(); const getVendorsPaginationMeta = getVendorsPaginationMetaFactory(); + const getVendorsCurrentViewId = getVendorsCurrentViewIdFactory(); const mapStateToProps = (state, props) => { const query = getVendorsTableQuery(state, props); @@ -20,6 +22,7 @@ export default (mapState) => { vendorTableQuery: query, vendorsPageination: getVendorsPaginationMeta(state, props, query), vendorsLoading: state.vendors.loading, + vendorsCurrentViewId: getVendorsCurrentViewId(state, props), }; return mapState ? mapState(mapped, state, props) : mapped; }; diff --git a/client/src/store/vendors/vendors.selectors.js b/client/src/store/vendors/vendors.selectors.js index 0bc45539b..c00a952a9 100644 --- a/client/src/store/vendors/vendors.selectors.js +++ b/client/src/store/vendors/vendors.selectors.js @@ -10,6 +10,8 @@ const vendorByIdSelector = (state, props) => state.vendors.items[props.vendorId]; const vendorsItemsSelector = (state) => state.vendors.items; +const vendorsCurrentViewIdSelector = (state) => state.vendors.currentViewId; + const vendorsPaginationSelector = (state, props) => { const viewId = state.vendors.currentViewId; return state.vendors.views?.[viewId]; @@ -57,3 +59,8 @@ export const getVendorByIdFactory = () => createSelector(vendorByIdSelector, (vendor) => { return vendor; }); + + export const getVendorsCurrentViewIdFactory = () => + createSelector(vendorsCurrentViewIdSelector, (currentViewId) => { + return currentViewId; + });