mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 22:00:31 +00:00
feat(branch & warehouse): fix EmptyStatus.
This commit is contained in:
@@ -2,7 +2,9 @@ import React from 'react';
|
||||
import classNames from 'classnames';
|
||||
import { CLASSES } from 'common/classes';
|
||||
import { useBranches } from 'hooks/query';
|
||||
import PreferencesPageLoader from '../PreferencesPageLoader';
|
||||
import { useFeatureCan } from 'hooks/state';
|
||||
import { Features } from 'common';
|
||||
import { isEmpty } from 'lodash';
|
||||
|
||||
const BranchesContext = React.createContext();
|
||||
|
||||
@@ -10,18 +12,27 @@ const BranchesContext = React.createContext();
|
||||
* Branches data provider.
|
||||
*/
|
||||
function BranchesProvider({ ...props }) {
|
||||
// Features guard.
|
||||
const { featureCan } = useFeatureCan();
|
||||
|
||||
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||
|
||||
// Fetches the branches list.
|
||||
const {
|
||||
isLoading: isBranchesLoading,
|
||||
isFetching: isBranchesFetching,
|
||||
data: branches,
|
||||
} = useBranches();
|
||||
} = useBranches({}, { enabled: isBranchFeatureCan });
|
||||
|
||||
// Detarmines the datatable empty status.
|
||||
const isEmptyStatus = isEmpty(branches) || !isBranchFeatureCan;
|
||||
|
||||
// Provider state.
|
||||
const provider = {
|
||||
branches,
|
||||
isBranchesLoading,
|
||||
isBranchesFetching,
|
||||
isEmptyStatus,
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user