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