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