mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
feat(branches): fix branches provider.
This commit is contained in:
@@ -3,7 +3,6 @@ import intl from 'react-intl-universal';
|
|||||||
|
|
||||||
import BranchesDataTable from './BranchesDataTable';
|
import BranchesDataTable from './BranchesDataTable';
|
||||||
import BranchesEmptyStatus from './BranchesEmptyStatus';
|
import BranchesEmptyStatus from './BranchesEmptyStatus';
|
||||||
import { Choose } from 'components';
|
|
||||||
|
|
||||||
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
|
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
|
||||||
import { useBranchesContext } from './BranchesProvider';
|
import { useBranchesContext } from './BranchesProvider';
|
||||||
@@ -21,14 +20,9 @@ function Branches({
|
|||||||
}, [changePreferencesPageTitle]);
|
}, [changePreferencesPageTitle]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Choose>
|
<React.Fragment>
|
||||||
<Choose.When condition={isEmptyStatus}>
|
{isEmptyStatus ? <BranchesEmptyStatus /> : <BranchesDataTable />}
|
||||||
<BranchesEmptyStatus />
|
</React.Fragment>
|
||||||
</Choose.When>
|
|
||||||
<Choose.Otherwise>
|
|
||||||
<BranchesDataTable />
|
|
||||||
</Choose.Otherwise>
|
|
||||||
</Choose>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
export default compose(withDashboardActions)(Branches);
|
export default compose(withDashboardActions)(Branches);
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const BranchesContext = React.createContext();
|
|||||||
/**
|
/**
|
||||||
* Branches data provider.
|
* Branches data provider.
|
||||||
*/
|
*/
|
||||||
function BranchesProvider({ ...props }) {
|
function BranchesProvider({ query, ...props }) {
|
||||||
// Features guard.
|
// Features guard.
|
||||||
const { featureCan } = useFeatureCan();
|
const { featureCan } = useFeatureCan();
|
||||||
|
|
||||||
@@ -22,10 +22,11 @@ function BranchesProvider({ ...props }) {
|
|||||||
isLoading: isBranchesLoading,
|
isLoading: isBranchesLoading,
|
||||||
isFetching: isBranchesFetching,
|
isFetching: isBranchesFetching,
|
||||||
data: branches,
|
data: branches,
|
||||||
} = useBranches({}, { enabled: isBranchFeatureCan });
|
} = useBranches(query, { enabled: isBranchFeatureCan });
|
||||||
|
|
||||||
// Detarmines the datatable empty status.
|
// Detarmines the datatable empty status.
|
||||||
const isEmptyStatus = isEmpty(branches) || !isBranchFeatureCan;
|
const isEmptyStatus =
|
||||||
|
(isEmpty(branches) && !isBranchesLoading) || !isBranchFeatureCan;
|
||||||
|
|
||||||
// Provider state.
|
// Provider state.
|
||||||
const provider = {
|
const provider = {
|
||||||
|
|||||||
Reference in New Issue
Block a user