mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
fix(projects): fetch projects if the feature was enabled.
This commit is contained in:
@@ -24,6 +24,7 @@ function MakeJournalProvider({ journalId, query, ...props }) {
|
||||
// Features guard.
|
||||
const { featureCan } = useFeatureCan();
|
||||
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||
const isProjectFeatureCan = featureCan(Features.Projects);
|
||||
|
||||
// Load the accounts list.
|
||||
const { data: accounts, isLoading: isAccountsLoading } = useAccounts();
|
||||
@@ -60,7 +61,7 @@ function MakeJournalProvider({ journalId, query, ...props }) {
|
||||
const {
|
||||
data: { projects },
|
||||
isLoading: isProjectsLoading,
|
||||
} = useProjects();
|
||||
} = useProjects({}, { enabled: !!isProjectFeatureCan });
|
||||
|
||||
// Submit form payload.
|
||||
const [submitPayload, setSubmitPayload] = useState({});
|
||||
|
||||
@@ -23,6 +23,7 @@ function ExpenseFormPageProvider({ query, expenseId, ...props }) {
|
||||
// Features guard.
|
||||
const { featureCan } = useFeatureCan();
|
||||
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||
const isProjectsFeatureCan = featureCan(Features.Projects);
|
||||
|
||||
const { data: currencies, isLoading: isCurrenciesLoading } = useCurrencies();
|
||||
|
||||
@@ -51,7 +52,7 @@ function ExpenseFormPageProvider({ query, expenseId, ...props }) {
|
||||
const {
|
||||
data: { projects },
|
||||
isLoading: isProjectsLoading,
|
||||
} = useProjects();
|
||||
} = useProjects({}, { enabled: !!isProjectsFeatureCan });
|
||||
|
||||
// Create and edit expense mutate.
|
||||
const { mutateAsync: createExpenseMutate } = useCreateExpense();
|
||||
@@ -75,7 +76,7 @@ function ExpenseFormPageProvider({ query, expenseId, ...props }) {
|
||||
accounts,
|
||||
branches,
|
||||
projects,
|
||||
|
||||
|
||||
isCurrenciesLoading,
|
||||
isExpenseLoading,
|
||||
isCustomersLoading,
|
||||
|
||||
@@ -44,6 +44,7 @@ function BillFormProvider({ billId, ...props }) {
|
||||
const { featureCan } = useFeatureCan();
|
||||
const isWarehouseFeatureCan = featureCan(Features.Warehouses);
|
||||
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||
const isProjectsFeatureCan = featureCan(Features.Projects);
|
||||
|
||||
// Handle fetch accounts.
|
||||
const { data: accounts, isLoading: isAccountsLoading } = useAccounts();
|
||||
@@ -86,7 +87,7 @@ function BillFormProvider({ billId, ...props }) {
|
||||
const {
|
||||
data: { projects },
|
||||
isLoading: isProjectsLoading,
|
||||
} = useProjects();
|
||||
} = useProjects({}, { enabled: !!isProjectsFeatureCan });
|
||||
|
||||
// Handle fetching bill settings.
|
||||
const { isFetching: isSettingLoading } = useSettings();
|
||||
@@ -101,7 +102,8 @@ function BillFormProvider({ billId, ...props }) {
|
||||
const isNewMode = !billId;
|
||||
|
||||
// Determines whether the warehouse and branches are loading.
|
||||
const isFeatureLoading = isWarehouesLoading || isBranchesLoading;
|
||||
const isFeatureLoading =
|
||||
isWarehouesLoading || isBranchesLoading || isProjectsLoading;
|
||||
|
||||
const provider = {
|
||||
accounts,
|
||||
|
||||
@@ -27,6 +27,7 @@ function EstimateFormProvider({ query, estimateId, ...props }) {
|
||||
const { featureCan } = useFeatureCan();
|
||||
const isWarehouseFeatureCan = featureCan(Features.Warehouses);
|
||||
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||
const isProjectsFeatureCan = featureCan(Features.Projects);
|
||||
|
||||
const {
|
||||
data: estimate,
|
||||
@@ -68,7 +69,7 @@ function EstimateFormProvider({ query, estimateId, ...props }) {
|
||||
const {
|
||||
data: { projects },
|
||||
isLoading: isProjectsLoading,
|
||||
} = useProjects();
|
||||
} = useProjects({}, { enabled: !!isProjectsFeatureCan });
|
||||
|
||||
// Handle fetch settings.
|
||||
useSettingsEstimates();
|
||||
@@ -83,7 +84,8 @@ function EstimateFormProvider({ query, estimateId, ...props }) {
|
||||
const isNewMode = !estimateId;
|
||||
|
||||
// Determines whether the warehouse and branches are loading.
|
||||
const isFeatureLoading = isWarehouesLoading || isBranchesLoading;
|
||||
const isFeatureLoading =
|
||||
isWarehouesLoading || isBranchesLoading || isProjectsLoading;
|
||||
|
||||
// Provider payload.
|
||||
const provider = {
|
||||
|
||||
@@ -32,6 +32,7 @@ function InvoiceFormProvider({ invoiceId, baseCurrency, ...props }) {
|
||||
const { featureCan } = useFeatureCan();
|
||||
const isWarehouseFeatureCan = featureCan(Features.Warehouses);
|
||||
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||
const isProjectsFeatureCan = featureCan(Features.Projects);
|
||||
|
||||
const { data: invoice, isLoading: isInvoiceLoading } = useInvoice(invoiceId, {
|
||||
enabled: !!invoiceId,
|
||||
@@ -41,7 +42,7 @@ function InvoiceFormProvider({ invoiceId, baseCurrency, ...props }) {
|
||||
const {
|
||||
data: { projects },
|
||||
isLoading: isProjectsLoading,
|
||||
} = useProjects();
|
||||
} = useProjects({}, { enabled: !!isProjectsFeatureCan });
|
||||
|
||||
// Fetches the estimate by the given id.
|
||||
const { data: estimate, isLoading: isEstimateLoading } = useEstimate(
|
||||
@@ -98,7 +99,8 @@ function InvoiceFormProvider({ invoiceId, baseCurrency, ...props }) {
|
||||
const isNewMode = !invoiceId;
|
||||
|
||||
// Determines whether the warehouse and branches are loading.
|
||||
const isFeatureLoading = isWarehouesLoading || isBranchesLoading;
|
||||
const isFeatureLoading =
|
||||
isWarehouesLoading || isBranchesLoading || isProjectsLoading;
|
||||
|
||||
const provider = {
|
||||
invoice,
|
||||
|
||||
@@ -27,6 +27,7 @@ function PaymentReceiveFormProvider({ query, paymentReceiveId, ...props }) {
|
||||
// Features guard.
|
||||
const { featureCan } = useFeatureCan();
|
||||
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||
const isProjectsFeatureCan = featureCan(Features.Projects);
|
||||
|
||||
// Fetches payment recevie details.
|
||||
const {
|
||||
@@ -62,7 +63,7 @@ function PaymentReceiveFormProvider({ query, paymentReceiveId, ...props }) {
|
||||
const {
|
||||
data: { projects },
|
||||
isLoading: isProjectsLoading,
|
||||
} = useProjects();
|
||||
} = useProjects({}, { enabled: !!isProjectsFeatureCan });
|
||||
|
||||
// Detarmines whether the new mode.
|
||||
const isNewMode = !paymentReceiveId;
|
||||
@@ -82,7 +83,7 @@ function PaymentReceiveFormProvider({ query, paymentReceiveId, ...props }) {
|
||||
customers,
|
||||
branches,
|
||||
projects,
|
||||
|
||||
|
||||
isPaymentLoading,
|
||||
isAccountsLoading,
|
||||
isPaymentFetching,
|
||||
|
||||
@@ -26,6 +26,7 @@ function ReceiptFormProvider({ receiptId, ...props }) {
|
||||
const { featureCan } = useFeatureCan();
|
||||
const isWarehouseFeatureCan = featureCan(Features.Warehouses);
|
||||
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||
const isProjectsFeatureCan = featureCan(Features.Projects);
|
||||
|
||||
// Fetch sale receipt details.
|
||||
const { data: receipt, isLoading: isReceiptLoading } = useReceipt(receiptId, {
|
||||
@@ -89,7 +90,7 @@ function ReceiptFormProvider({ receiptId, ...props }) {
|
||||
const {
|
||||
data: { projects },
|
||||
isLoading: isProjectsLoading,
|
||||
} = useProjects();
|
||||
} = useProjects({}, { enabled: !!isProjectsFeatureCan });
|
||||
|
||||
// Fetch receipt settings.
|
||||
const { isLoading: isSettingLoading } = useSettingsReceipts();
|
||||
|
||||
Reference in New Issue
Block a user