mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
feat(branches & warehouses): fix api.
This commit is contained in:
@@ -3,6 +3,8 @@ import { useLocation } from 'react-router-dom';
|
||||
import { isEmpty, pick, isEqual, isUndefined } from 'lodash';
|
||||
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||
import { transformToEditForm } from './utils';
|
||||
import { Features } from 'common';
|
||||
import { useFeatureCan } from 'hooks/state';
|
||||
|
||||
import {
|
||||
useCreditNote,
|
||||
@@ -25,6 +27,11 @@ function CreditNoteFormProvider({ creditNoteId, baseCurrency, ...props }) {
|
||||
const { state } = useLocation();
|
||||
const invoiceId = state?.invoiceId;
|
||||
|
||||
// Features guard.
|
||||
const { featureCan } = useFeatureCan();
|
||||
const isWarehouseFeatureCan = featureCan(Features.Warehouses);
|
||||
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||
|
||||
// Handle fetch customers data table or list
|
||||
const {
|
||||
data: { customers },
|
||||
@@ -56,14 +63,14 @@ function CreditNoteFormProvider({ creditNoteId, baseCurrency, ...props }) {
|
||||
data: warehouses,
|
||||
isLoading: isWarehouesLoading,
|
||||
isSuccess: isWarehousesSuccess,
|
||||
} = useWarehouses();
|
||||
} = useWarehouses({}, { enabled: isWarehouseFeatureCan });
|
||||
|
||||
// Fetches the branches list.
|
||||
const {
|
||||
data: branches,
|
||||
isLoading: isBranchesLoading,
|
||||
isSuccess: isBranchesSuccess,
|
||||
} = useBranches();
|
||||
} = useBranches({}, { enabled: isBranchFeatureCan });
|
||||
|
||||
// Handle fetching settings.
|
||||
useSettingsCreditNotes();
|
||||
|
||||
Reference in New Issue
Block a user