mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 23:00:34 +00:00
feat(branches & warehouses): fix api.
This commit is contained in:
@@ -108,7 +108,7 @@ function MakeJournalEntriesForm({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const form = {
|
const form = {
|
||||||
...omit(values, ['journal_number', 'journal_number_manually']),
|
...omit(values, ['journal_number_manually']),
|
||||||
...(values.journal_number_manually && {
|
...(values.journal_number_manually && {
|
||||||
journal_number: values.journal_number,
|
journal_number: values.journal_number,
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import React, { createContext, useState } from 'react';
|
import React, { createContext, useState } from 'react';
|
||||||
import { isEqual, isUndefined } from 'lodash';
|
import { isEqual, isUndefined } from 'lodash';
|
||||||
|
import { Features } from 'common';
|
||||||
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||||
import {
|
import {
|
||||||
useAccounts,
|
useAccounts,
|
||||||
@@ -18,7 +20,11 @@ const MakeJournalFormContext = createContext();
|
|||||||
/**
|
/**
|
||||||
* Make journal form provider.
|
* Make journal form provider.
|
||||||
*/
|
*/
|
||||||
function MakeJournalProvider({ journalId, baseCurrency, ...props }) {
|
function MakeJournalProvider({ journalId, query, baseCurrency, ...props }) {
|
||||||
|
// Features guard.
|
||||||
|
const { featureCan } = useFeatureCan();
|
||||||
|
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||||
|
|
||||||
// Load the accounts list.
|
// Load the accounts list.
|
||||||
const { data: accounts, isLoading: isAccountsLoading } = useAccounts();
|
const { data: accounts, isLoading: isAccountsLoading } = useAccounts();
|
||||||
|
|
||||||
@@ -48,7 +54,7 @@ function MakeJournalProvider({ journalId, baseCurrency, ...props }) {
|
|||||||
data: branches,
|
data: branches,
|
||||||
isLoading: isBranchesLoading,
|
isLoading: isBranchesLoading,
|
||||||
isSuccess: isBranchesSuccess,
|
isSuccess: isBranchesSuccess,
|
||||||
} = useBranches();
|
} = useBranches(query, { enabled: isBranchFeatureCan });
|
||||||
|
|
||||||
// Submit form payload.
|
// Submit form payload.
|
||||||
const [submitPayload, setSubmitPayload] = useState({});
|
const [submitPayload, setSubmitPayload] = useState({});
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ export const defaultManualJournal = {
|
|||||||
currency_code: '',
|
currency_code: '',
|
||||||
publish: '',
|
publish: '',
|
||||||
branch_id: '',
|
branch_id: '',
|
||||||
exchange_rate: '',
|
exchange_rate: 1,
|
||||||
entries: [...repeatValue(defaultEntry, 4)],
|
entries: [...repeatValue(defaultEntry, 4)],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { DialogContent } from 'components';
|
import { DialogContent } from 'components';
|
||||||
|
import { Features } from 'common';
|
||||||
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import {
|
import {
|
||||||
useCreateCashflowTransaction,
|
useCreateCashflowTransaction,
|
||||||
useAccount,
|
useAccount,
|
||||||
@@ -20,6 +22,9 @@ function MoneyInDialogProvider({
|
|||||||
dialogName,
|
dialogName,
|
||||||
...props
|
...props
|
||||||
}) {
|
}) {
|
||||||
|
const { featureCan } = useFeatureCan();
|
||||||
|
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||||
|
|
||||||
// Fetches accounts list.
|
// Fetches accounts list.
|
||||||
const { isFetching: isAccountsLoading, data: accounts } = useAccounts();
|
const { isFetching: isAccountsLoading, data: accounts } = useAccounts();
|
||||||
|
|
||||||
@@ -33,7 +38,7 @@ function MoneyInDialogProvider({
|
|||||||
data: branches,
|
data: branches,
|
||||||
isLoading: isBranchesLoading,
|
isLoading: isBranchesLoading,
|
||||||
isSuccess: isBranchesSuccess,
|
isSuccess: isBranchesSuccess,
|
||||||
} = useBranches();
|
} = useBranches({}, { enabled: isBranchFeatureCan });
|
||||||
|
|
||||||
// Fetch cash flow list .
|
// Fetch cash flow list .
|
||||||
const { data: cashflowAccounts, isLoading: isCashFlowAccountsLoading } =
|
const { data: cashflowAccounts, isLoading: isCashFlowAccountsLoading } =
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { DialogContent } from 'components';
|
import { DialogContent } from 'components';
|
||||||
|
import { Features } from 'common';
|
||||||
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import {
|
import {
|
||||||
useAccounts,
|
useAccounts,
|
||||||
useAccount,
|
useAccount,
|
||||||
@@ -15,6 +17,10 @@ const MoneyInDialogContent = React.createContext();
|
|||||||
* Money out dialog provider.
|
* Money out dialog provider.
|
||||||
*/
|
*/
|
||||||
function MoneyOutProvider({ accountId, accountType, dialogName, ...props }) {
|
function MoneyOutProvider({ accountId, accountType, dialogName, ...props }) {
|
||||||
|
// Features guard.
|
||||||
|
const { featureCan } = useFeatureCan();
|
||||||
|
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||||
|
|
||||||
// Fetches accounts list.
|
// Fetches accounts list.
|
||||||
const { isLoading: isAccountsLoading, data: accounts } = useAccounts();
|
const { isLoading: isAccountsLoading, data: accounts } = useAccounts();
|
||||||
|
|
||||||
@@ -28,7 +34,8 @@ function MoneyOutProvider({ accountId, accountType, dialogName, ...props }) {
|
|||||||
data: branches,
|
data: branches,
|
||||||
isLoading: isBranchesLoading,
|
isLoading: isBranchesLoading,
|
||||||
isSuccess: isBranchesSuccess,
|
isSuccess: isBranchesSuccess,
|
||||||
} = useBranches();
|
} = useBranches({}, { enabled: isBranchFeatureCan });
|
||||||
|
|
||||||
// Fetch cash flow list .
|
// Fetch cash flow list .
|
||||||
const { data: cashflowAccounts, isLoading: isCashFlowAccountsLoading } =
|
const { data: cashflowAccounts, isLoading: isCashFlowAccountsLoading } =
|
||||||
useCashflowAccounts({}, { keepPreviousData: true });
|
useCashflowAccounts({}, { keepPreviousData: true });
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import {
|
|||||||
useBranches,
|
useBranches,
|
||||||
useCreatePaymentMade,
|
useCreatePaymentMade,
|
||||||
} from 'hooks/query';
|
} from 'hooks/query';
|
||||||
|
import { Features } from 'common';
|
||||||
|
import { useFeatureCan } from 'hooks/state';
|
||||||
|
|
||||||
import { pick } from 'lodash';
|
import { pick } from 'lodash';
|
||||||
|
|
||||||
@@ -14,7 +16,11 @@ const QuickPaymentMadeContext = React.createContext();
|
|||||||
/**
|
/**
|
||||||
* Quick payment made dialog provider.
|
* Quick payment made dialog provider.
|
||||||
*/
|
*/
|
||||||
function QuickPaymentMadeFormProvider({ billId, dialogName, ...props }) {
|
function QuickPaymentMadeFormProvider({ query, billId, dialogName, ...props }) {
|
||||||
|
// Features guard.
|
||||||
|
const { featureCan } = useFeatureCan();
|
||||||
|
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||||
|
|
||||||
// Handle fetch bill details.
|
// Handle fetch bill details.
|
||||||
const { isLoading: isBillLoading, data: bill } = useBill(billId, {
|
const { isLoading: isBillLoading, data: bill } = useBill(billId, {
|
||||||
enabled: !!billId,
|
enabled: !!billId,
|
||||||
@@ -31,7 +37,7 @@ function QuickPaymentMadeFormProvider({ billId, dialogName, ...props }) {
|
|||||||
data: branches,
|
data: branches,
|
||||||
isLoading: isBranchesLoading,
|
isLoading: isBranchesLoading,
|
||||||
isSuccess: isBranchesSuccess,
|
isSuccess: isBranchesSuccess,
|
||||||
} = useBranches();
|
} = useBranches(query, { enabled: isBranchFeatureCan });
|
||||||
|
|
||||||
// State provider.
|
// State provider.
|
||||||
const provider = {
|
const provider = {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import React, { useContext, createContext } from 'react';
|
import React, { useContext, createContext } from 'react';
|
||||||
import { pick } from 'lodash';
|
import { pick } from 'lodash';
|
||||||
import { DialogContent } from 'components';
|
import { DialogContent } from 'components';
|
||||||
|
import { Features } from 'common';
|
||||||
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import {
|
import {
|
||||||
useAccounts,
|
useAccounts,
|
||||||
useInvoice,
|
useInvoice,
|
||||||
@@ -15,11 +17,15 @@ const QuickPaymentReceiveContext = createContext();
|
|||||||
* Quick payment receive dialog provider.
|
* Quick payment receive dialog provider.
|
||||||
*/
|
*/
|
||||||
function QuickPaymentReceiveFormProvider({
|
function QuickPaymentReceiveFormProvider({
|
||||||
|
query,
|
||||||
invoiceId,
|
invoiceId,
|
||||||
dialogName,
|
dialogName,
|
||||||
baseCurrency,
|
baseCurrency,
|
||||||
...props
|
...props
|
||||||
}) {
|
}) {
|
||||||
|
const { featureCan } = useFeatureCan();
|
||||||
|
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||||
|
|
||||||
// Handle fetch accounts data.
|
// Handle fetch accounts data.
|
||||||
const { data: accounts, isLoading: isAccountsLoading } = useAccounts();
|
const { data: accounts, isLoading: isAccountsLoading } = useAccounts();
|
||||||
|
|
||||||
@@ -38,9 +44,7 @@ function QuickPaymentReceiveFormProvider({
|
|||||||
data: branches,
|
data: branches,
|
||||||
isLoading: isBranchesLoading,
|
isLoading: isBranchesLoading,
|
||||||
isSuccess: isBranchesSuccess,
|
isSuccess: isBranchesSuccess,
|
||||||
} = useBranches();
|
} = useBranches(query, { enabled: isBranchFeatureCan });
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// State provider.
|
// State provider.
|
||||||
const provider = {
|
const provider = {
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { DialogContent } from 'components';
|
import { DialogContent } from 'components';
|
||||||
import { pick } from 'lodash';
|
import { pick } from 'lodash';
|
||||||
|
import { Features } from 'common';
|
||||||
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import {
|
import {
|
||||||
useAccounts,
|
useAccounts,
|
||||||
useCreditNote,
|
useCreditNote,
|
||||||
@@ -14,7 +15,16 @@ const RefundCreditNoteContext = React.createContext();
|
|||||||
/**
|
/**
|
||||||
* Refund credit note form provider.
|
* Refund credit note form provider.
|
||||||
*/
|
*/
|
||||||
function RefundCreditNoteFormProvider({ creditNoteId, dialogName, ...props }) {
|
function RefundCreditNoteFormProvider({
|
||||||
|
creditNoteId,
|
||||||
|
dialogName,
|
||||||
|
query,
|
||||||
|
...props
|
||||||
|
}) {
|
||||||
|
// Features guard.
|
||||||
|
const { featureCan } = useFeatureCan();
|
||||||
|
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||||
|
|
||||||
// Handle fetch accounts data.
|
// Handle fetch accounts data.
|
||||||
const { data: accounts, isLoading: isAccountsLoading } = useAccounts();
|
const { data: accounts, isLoading: isAccountsLoading } = useAccounts();
|
||||||
|
|
||||||
@@ -31,7 +41,7 @@ function RefundCreditNoteFormProvider({ creditNoteId, dialogName, ...props }) {
|
|||||||
data: branches,
|
data: branches,
|
||||||
isLoading: isBranchesLoading,
|
isLoading: isBranchesLoading,
|
||||||
isSuccess: isBranchesSuccess,
|
isSuccess: isBranchesSuccess,
|
||||||
} = useBranches();
|
} = useBranches(query, { enabled: isBranchFeatureCan });
|
||||||
|
|
||||||
// Create and edit credit note mutations.
|
// Create and edit credit note mutations.
|
||||||
const { mutateAsync: createRefundCreditNoteMutate } =
|
const { mutateAsync: createRefundCreditNoteMutate } =
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { DialogContent } from 'components';
|
import { DialogContent } from 'components';
|
||||||
import { pick } from 'lodash';
|
import { pick } from 'lodash';
|
||||||
|
import { Features } from 'common';
|
||||||
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import {
|
import {
|
||||||
useAccounts,
|
useAccounts,
|
||||||
useVendorCredit,
|
useVendorCredit,
|
||||||
@@ -14,8 +15,13 @@ const RefundVendorCreditContext = React.createContext();
|
|||||||
function RefundVendorCreditFormProvider({
|
function RefundVendorCreditFormProvider({
|
||||||
vendorCreditId,
|
vendorCreditId,
|
||||||
dialogName,
|
dialogName,
|
||||||
|
query,
|
||||||
...props
|
...props
|
||||||
}) {
|
}) {
|
||||||
|
// Features guard.
|
||||||
|
const { featureCan } = useFeatureCan();
|
||||||
|
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||||
|
|
||||||
// Handle fetch accounts data.
|
// Handle fetch accounts data.
|
||||||
const { data: accounts, isLoading: isAccountsLoading } = useAccounts();
|
const { data: accounts, isLoading: isAccountsLoading } = useAccounts();
|
||||||
|
|
||||||
@@ -24,7 +30,7 @@ function RefundVendorCreditFormProvider({
|
|||||||
data: branches,
|
data: branches,
|
||||||
isLoading: isBranchesLoading,
|
isLoading: isBranchesLoading,
|
||||||
isSuccess: isBranchesSuccess,
|
isSuccess: isBranchesSuccess,
|
||||||
} = useBranches();
|
} = useBranches(query, { enabled: isBranchFeatureCan });
|
||||||
|
|
||||||
// Handle fetch vendor credit details.
|
// Handle fetch vendor credit details.
|
||||||
const { data: vendorCredit, isLoading: isVendorCreditLoading } =
|
const { data: vendorCredit, isLoading: isVendorCreditLoading } =
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { Features } from 'common';
|
||||||
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import { useBranches } from 'hooks/query';
|
import { useBranches } from 'hooks/query';
|
||||||
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
||||||
|
|
||||||
@@ -9,9 +10,15 @@ const APAgingSummaryHeaderDimensonsContext = React.createContext();
|
|||||||
* APAging summary header dismensions provider.
|
* APAging summary header dismensions provider.
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function APAgingSummaryHeaderDimensionsProvider({ ...props }) {
|
function APAgingSummaryHeaderDimensionsProvider({ query, ...props }) {
|
||||||
|
// Features guard.
|
||||||
|
const { featureCan } = useFeatureCan();
|
||||||
|
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||||
|
|
||||||
// Fetches the branches list.
|
// Fetches the branches list.
|
||||||
const { isLoading: isBranchesLoading, data: branches } = useBranches();
|
const { isLoading: isBranchesLoading, data: branches } = useBranches(query, {
|
||||||
|
enabled: isBranchFeatureCan,
|
||||||
|
});
|
||||||
|
|
||||||
// Provider
|
// Provider
|
||||||
const provider = {
|
const provider = {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { Features } from 'common';
|
||||||
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import { useBranches } from 'hooks/query';
|
import { useBranches } from 'hooks/query';
|
||||||
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
||||||
|
|
||||||
@@ -9,9 +10,15 @@ const ARAgingSummaryHeaderDimensonsContext = React.createContext();
|
|||||||
* ARAging summary header dismensions provider.
|
* ARAging summary header dismensions provider.
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function ARAgingSummaryHeaderDimensionsProvider({ ...props }) {
|
function ARAgingSummaryHeaderDimensionsProvider({ query, ...props }) {
|
||||||
|
// Features guard.
|
||||||
|
const { featureCan } = useFeatureCan();
|
||||||
|
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||||
|
|
||||||
// Fetches the branches list.
|
// Fetches the branches list.
|
||||||
const { isLoading: isBranchesLoading, data: branches } = useBranches();
|
const { isLoading: isBranchesLoading, data: branches } = useBranches(query, {
|
||||||
|
enabled: isBranchFeatureCan,
|
||||||
|
});
|
||||||
|
|
||||||
// Provider
|
// Provider
|
||||||
const provider = {
|
const provider = {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
import { Features } from 'common';
|
||||||
import { useBranches } from 'hooks/query';
|
import { useBranches } from 'hooks/query';
|
||||||
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
||||||
|
|
||||||
const BalanceSheetHeaderDimensionsPanelContext = React.createContext();
|
const BalanceSheetHeaderDimensionsPanelContext = React.createContext();
|
||||||
@@ -9,9 +11,15 @@ const BalanceSheetHeaderDimensionsPanelContext = React.createContext();
|
|||||||
* BL sheet header provider.
|
* BL sheet header provider.
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function BalanceSheetHeaderDimensionsProvider({ ...props }) {
|
function BalanceSheetHeaderDimensionsProvider({ query, ...props }) {
|
||||||
|
// Features guard.
|
||||||
|
const { featureCan } = useFeatureCan();
|
||||||
|
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||||
|
|
||||||
// Fetches the branches list.
|
// Fetches the branches list.
|
||||||
const { isLoading: isBranchesLoading, data: branches } = useBranches();
|
const { isLoading: isBranchesLoading, data: branches } = useBranches(query, {
|
||||||
|
enabled: isBranchFeatureCan,
|
||||||
|
});
|
||||||
|
|
||||||
// Provider
|
// Provider
|
||||||
const provider = {
|
const provider = {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { Features } from 'common';
|
||||||
import { useBranches } from 'hooks/query';
|
import { useBranches } from 'hooks/query';
|
||||||
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
||||||
|
|
||||||
const CashFlowStatementDimensionsPanelContext = React.createContext();
|
const CashFlowStatementDimensionsPanelContext = React.createContext();
|
||||||
@@ -9,9 +10,16 @@ const CashFlowStatementDimensionsPanelContext = React.createContext();
|
|||||||
* cash flow statement dimensions panel provider.
|
* cash flow statement dimensions panel provider.
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function CashFlowStatementDimensionsPanelProvider({ ...props }) {
|
function CashFlowStatementDimensionsPanelProvider({ query,...props }) {
|
||||||
|
// Features guard.
|
||||||
|
const { featureCan } = useFeatureCan();
|
||||||
|
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||||
|
|
||||||
// Fetches the branches list.
|
// Fetches the branches list.
|
||||||
const { isLoading: isBranchesLoading, data: branches } = useBranches();
|
const { isLoading: isBranchesLoading, data: branches } = useBranches(
|
||||||
|
query,
|
||||||
|
{ enabled: isBranchFeatureCan },
|
||||||
|
);
|
||||||
|
|
||||||
// Provider
|
// Provider
|
||||||
const provider = {
|
const provider = {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
import { Features } from 'common';
|
||||||
import { useBranches } from 'hooks/query';
|
import { useBranches } from 'hooks/query';
|
||||||
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
||||||
|
|
||||||
const GeneralLedgerHeaderDimensionsPanelContext = React.createContext();
|
const GeneralLedgerHeaderDimensionsPanelContext = React.createContext();
|
||||||
@@ -9,9 +11,15 @@ const GeneralLedgerHeaderDimensionsPanelContext = React.createContext();
|
|||||||
* General Ledger Header Dimensions Panel provider.
|
* General Ledger Header Dimensions Panel provider.
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function GeneralLedgerHeaderDimensionsPanelProvider({ ...props }) {
|
function GeneralLedgerHeaderDimensionsPanelProvider({ query, ...props }) {
|
||||||
|
// Features guard.
|
||||||
|
const { featureCan } = useFeatureCan();
|
||||||
|
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||||
|
|
||||||
// Fetches the branches list.
|
// Fetches the branches list.
|
||||||
const { isLoading: isBranchesLoading, data: branches } = useBranches();
|
const { isLoading: isBranchesLoading, data: branches } = useBranches(query, {
|
||||||
|
enabled: isBranchFeatureCan,
|
||||||
|
});
|
||||||
|
|
||||||
// Provider
|
// Provider
|
||||||
const provider = {
|
const provider = {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
import { Features } from 'common';
|
||||||
import { useWarehouses } from 'hooks/query';
|
import { useWarehouses } from 'hooks/query';
|
||||||
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
||||||
|
|
||||||
const InventoryItemDetailsHeaderDimensionsPanelContext = React.createContext();
|
const InventoryItemDetailsHeaderDimensionsPanelContext = React.createContext();
|
||||||
@@ -9,9 +11,17 @@ const InventoryItemDetailsHeaderDimensionsPanelContext = React.createContext();
|
|||||||
* Inventory Item details header provider.
|
* Inventory Item details header provider.
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function InventoryItemDetailsHeaderDimensionsProvider({ ...props }) {
|
function InventoryItemDetailsHeaderDimensionsProvider({ query, ...props }) {
|
||||||
|
// Features guard.
|
||||||
|
const { featureCan } = useFeatureCan();
|
||||||
|
|
||||||
|
const isWarehouseFeatureCan = featureCan(Features.Warehouses);
|
||||||
|
|
||||||
// Fetch warehouses list.
|
// Fetch warehouses list.
|
||||||
const { data: warehouses, isLoading: isWarehouesLoading } = useWarehouses();
|
const { data: warehouses, isLoading: isWarehouesLoading } = useWarehouses(
|
||||||
|
query,
|
||||||
|
{ enabled: isWarehouseFeatureCan },
|
||||||
|
);
|
||||||
|
|
||||||
// Provider
|
// Provider
|
||||||
const provider = {
|
const provider = {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import { useWarehouses } from 'hooks/query';
|
import { useWarehouses } from 'hooks/query';
|
||||||
|
import { Features } from 'common';
|
||||||
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
||||||
|
|
||||||
const InventoryValuationHeaderDimensionsPanelContext = React.createContext();
|
const InventoryValuationHeaderDimensionsPanelContext = React.createContext();
|
||||||
@@ -9,9 +11,17 @@ const InventoryValuationHeaderDimensionsPanelContext = React.createContext();
|
|||||||
* Inventory valuation header provider.
|
* Inventory valuation header provider.
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function InventoryValuationHeaderDimensionsProvider({ ...props }) {
|
function InventoryValuationHeaderDimensionsProvider({ query, ...props }) {
|
||||||
|
// Features guard.
|
||||||
|
const { featureCan } = useFeatureCan();
|
||||||
|
|
||||||
|
const isWarehouseFeatureCan = featureCan(Features.Warehouses);
|
||||||
|
|
||||||
// Fetch warehouses list.
|
// Fetch warehouses list.
|
||||||
const { data: warehouses, isLoading: isWarehouesLoading } = useWarehouses();
|
const { data: warehouses, isLoading: isWarehouesLoading } = useWarehouses(
|
||||||
|
query,
|
||||||
|
{ enabled: isWarehouseFeatureCan },
|
||||||
|
);
|
||||||
|
|
||||||
// Provider
|
// Provider
|
||||||
const provider = {
|
const provider = {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
import { Features } from 'common';
|
||||||
import { useBranches } from 'hooks/query';
|
import { useBranches } from 'hooks/query';
|
||||||
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
||||||
|
|
||||||
const JournalSheetHeaderDimensionsPanelContext = React.createContext();
|
const JournalSheetHeaderDimensionsPanelContext = React.createContext();
|
||||||
@@ -9,9 +11,14 @@ const JournalSheetHeaderDimensionsPanelContext = React.createContext();
|
|||||||
* Journal sheet header provider.
|
* Journal sheet header provider.
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function JournalSheetHeaderDimensionsProvider({ ...props }) {
|
function JournalSheetHeaderDimensionsProvider({ query, ...props }) {
|
||||||
|
const { featureCan } = useFeatureCan();
|
||||||
|
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||||
|
|
||||||
// Fetches the branches list.
|
// Fetches the branches list.
|
||||||
const { isLoading: isBranchesLoading, data: branches } = useBranches();
|
const { isLoading: isBranchesLoading, data: branches } = useBranches(query, {
|
||||||
|
enabled: isBranchFeatureCan,
|
||||||
|
});
|
||||||
|
|
||||||
// Provider
|
// Provider
|
||||||
const provider = {
|
const provider = {
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
|
import { Features } from 'common';
|
||||||
import { useBranches } from 'hooks/query';
|
import { useBranches } from 'hooks/query';
|
||||||
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
||||||
|
|
||||||
const ProfitLossSheetHeaderDimensionsPanelContext = React.createContext();
|
const ProfitLossSheetHeaderDimensionsPanelContext = React.createContext();
|
||||||
@@ -9,9 +11,15 @@ const ProfitLossSheetHeaderDimensionsPanelContext = React.createContext();
|
|||||||
* profit loss sheet header provider.
|
* profit loss sheet header provider.
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function ProfitLossSheetHeaderDimensionsProvider({ ...props }) {
|
function ProfitLossSheetHeaderDimensionsProvider({ query, ...props }) {
|
||||||
|
// Features guard.
|
||||||
|
const { featureCan } = useFeatureCan();
|
||||||
|
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||||
|
|
||||||
// Fetches the branches list.
|
// Fetches the branches list.
|
||||||
const { isLoading: isBranchesLoading, data: branches } = useBranches();
|
const { isLoading: isBranchesLoading, data: branches } = useBranches(query, {
|
||||||
|
enabled: isBranchFeatureCan,
|
||||||
|
});
|
||||||
|
|
||||||
// Provider
|
// Provider
|
||||||
const provider = {
|
const provider = {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { Features } from 'common';
|
||||||
import { useBranches } from 'hooks/query';
|
import { useBranches } from 'hooks/query';
|
||||||
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
import { FinancialHeaderLoadingSkeleton } from '../FinancialHeaderLoadingSkeleton';
|
||||||
|
|
||||||
const TrialBLSheetHeaderDimensionsContext = React.createContext();
|
const TrialBLSheetHeaderDimensionsContext = React.createContext();
|
||||||
@@ -8,9 +10,15 @@ const TrialBLSheetHeaderDimensionsContext = React.createContext();
|
|||||||
* Trial BL sheet header provider.
|
* Trial BL sheet header provider.
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
function TrialBLHeaderDimensionsPanelProvider({ ...props }) {
|
function TrialBLHeaderDimensionsPanelProvider({ query, ...props }) {
|
||||||
|
// Features guard.
|
||||||
|
const { featureCan } = useFeatureCan();
|
||||||
|
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||||
|
|
||||||
// Fetches the branches list.
|
// Fetches the branches list.
|
||||||
const { isLoading: isBranchesLoading, data: branches } = useBranches();
|
const { isLoading: isBranchesLoading, data: branches } = useBranches(query, {
|
||||||
|
enabled: isBranchFeatureCan,
|
||||||
|
});
|
||||||
|
|
||||||
// Provider
|
// Provider
|
||||||
const provider = {
|
const provider = {
|
||||||
@@ -28,4 +36,7 @@ function TrialBLHeaderDimensionsPanelProvider({ ...props }) {
|
|||||||
const useTrialBalanceSheetPanelContext = () =>
|
const useTrialBalanceSheetPanelContext = () =>
|
||||||
React.useContext(TrialBLSheetHeaderDimensionsContext);
|
React.useContext(TrialBLSheetHeaderDimensionsContext);
|
||||||
|
|
||||||
export { TrialBLHeaderDimensionsPanelProvider, useTrialBalanceSheetPanelContext };
|
export {
|
||||||
|
TrialBLHeaderDimensionsPanelProvider,
|
||||||
|
useTrialBalanceSheetPanelContext,
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import React, { createContext, useState } from 'react';
|
import React, { createContext, useState } from 'react';
|
||||||
import {isEqual, isUndefined } from 'lodash';
|
import { isEqual, isUndefined } from 'lodash';
|
||||||
|
import { Features } from 'common';
|
||||||
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||||
import {
|
import {
|
||||||
useAccounts,
|
useAccounts,
|
||||||
@@ -38,6 +39,11 @@ const stringifiedFilterRoles = JSON.stringify([
|
|||||||
* Bill form provider.
|
* Bill form provider.
|
||||||
*/
|
*/
|
||||||
function BillFormProvider({ billId, baseCurrency, ...props }) {
|
function BillFormProvider({ billId, baseCurrency, ...props }) {
|
||||||
|
// Features guard.
|
||||||
|
const { featureCan } = useFeatureCan();
|
||||||
|
const isWarehouseFeatureCan = featureCan(Features.Warehouses);
|
||||||
|
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||||
|
|
||||||
// Handle fetch accounts.
|
// Handle fetch accounts.
|
||||||
const { data: accounts, isLoading: isAccountsLoading } = useAccounts();
|
const { data: accounts, isLoading: isAccountsLoading } = useAccounts();
|
||||||
|
|
||||||
@@ -66,14 +72,14 @@ function BillFormProvider({ billId, baseCurrency, ...props }) {
|
|||||||
data: warehouses,
|
data: warehouses,
|
||||||
isLoading: isWarehouesLoading,
|
isLoading: isWarehouesLoading,
|
||||||
isSuccess: isWarehousesSuccess,
|
isSuccess: isWarehousesSuccess,
|
||||||
} = useWarehouses();
|
} = useWarehouses({}, { enabled: isWarehouseFeatureCan });
|
||||||
|
|
||||||
// Fetches the branches list.
|
// Fetches the branches list.
|
||||||
const {
|
const {
|
||||||
data: branches,
|
data: branches,
|
||||||
isLoading: isBranchesLoading,
|
isLoading: isBranchesLoading,
|
||||||
isSuccess: isBranchesSuccess,
|
isSuccess: isBranchesSuccess,
|
||||||
} = useBranches();
|
} = useBranches({}, { enabled: isBranchFeatureCan });
|
||||||
|
|
||||||
// Handle fetching bill settings.
|
// Handle fetching bill settings.
|
||||||
const { isFetching: isSettingLoading } = useSettings();
|
const { isFetching: isSettingLoading } = useSettings();
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import { useLocation } from 'react-router-dom';
|
|||||||
import { isEmpty, pick, isEqual, isUndefined } from 'lodash';
|
import { isEmpty, pick, isEqual, isUndefined } from 'lodash';
|
||||||
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||||
import { transformToEditForm } from './utils';
|
import { transformToEditForm } from './utils';
|
||||||
|
import { Features } from 'common';
|
||||||
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import {
|
import {
|
||||||
useCreateVendorCredit,
|
useCreateVendorCredit,
|
||||||
useEditVendorCredit,
|
useEditVendorCredit,
|
||||||
@@ -26,9 +28,13 @@ function VendorCreditNoteFormProvider({
|
|||||||
...props
|
...props
|
||||||
}) {
|
}) {
|
||||||
const { state } = useLocation();
|
const { state } = useLocation();
|
||||||
|
|
||||||
const billId = state?.billId;
|
const billId = state?.billId;
|
||||||
|
|
||||||
|
// Features guard.
|
||||||
|
const { featureCan } = useFeatureCan();
|
||||||
|
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||||
|
const isWarehouseFeatureCan = featureCan(Features.Warehouses);
|
||||||
|
|
||||||
// Handle fetching the items table based on the given query.
|
// Handle fetching the items table based on the given query.
|
||||||
const {
|
const {
|
||||||
data: { items },
|
data: { items },
|
||||||
@@ -62,14 +68,14 @@ function VendorCreditNoteFormProvider({
|
|||||||
data: warehouses,
|
data: warehouses,
|
||||||
isLoading: isWarehouesLoading,
|
isLoading: isWarehouesLoading,
|
||||||
isSuccess: isWarehousesSuccess,
|
isSuccess: isWarehousesSuccess,
|
||||||
} = useWarehouses();
|
} = useWarehouses({}, { enabled: isWarehouseFeatureCan });
|
||||||
|
|
||||||
// Fetches the branches list.
|
// Fetches the branches list.
|
||||||
const {
|
const {
|
||||||
data: branches,
|
data: branches,
|
||||||
isLoading: isBranchesLoading,
|
isLoading: isBranchesLoading,
|
||||||
isSuccess: isBranchesSuccess,
|
isSuccess: isBranchesSuccess,
|
||||||
} = useBranches();
|
} = useBranches({}, { enabled: isBranchFeatureCan });
|
||||||
|
|
||||||
// Form submit payload.
|
// Form submit payload.
|
||||||
const [submitPayload, setSubmitPayload] = React.useState();
|
const [submitPayload, setSubmitPayload] = React.useState();
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ import { useLocation } from 'react-router-dom';
|
|||||||
import { isEmpty, pick, isEqual, isUndefined } from 'lodash';
|
import { isEmpty, pick, isEqual, isUndefined } from 'lodash';
|
||||||
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||||
import { transformToEditForm } from './utils';
|
import { transformToEditForm } from './utils';
|
||||||
|
import { Features } from 'common';
|
||||||
|
import { useFeatureCan } from 'hooks/state';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
useCreditNote,
|
useCreditNote,
|
||||||
@@ -25,6 +27,11 @@ function CreditNoteFormProvider({ creditNoteId, baseCurrency, ...props }) {
|
|||||||
const { state } = useLocation();
|
const { state } = useLocation();
|
||||||
const invoiceId = state?.invoiceId;
|
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
|
// Handle fetch customers data table or list
|
||||||
const {
|
const {
|
||||||
data: { customers },
|
data: { customers },
|
||||||
@@ -56,14 +63,14 @@ function CreditNoteFormProvider({ creditNoteId, baseCurrency, ...props }) {
|
|||||||
data: warehouses,
|
data: warehouses,
|
||||||
isLoading: isWarehouesLoading,
|
isLoading: isWarehouesLoading,
|
||||||
isSuccess: isWarehousesSuccess,
|
isSuccess: isWarehousesSuccess,
|
||||||
} = useWarehouses();
|
} = useWarehouses({}, { enabled: isWarehouseFeatureCan });
|
||||||
|
|
||||||
// Fetches the branches list.
|
// Fetches the branches list.
|
||||||
const {
|
const {
|
||||||
data: branches,
|
data: branches,
|
||||||
isLoading: isBranchesLoading,
|
isLoading: isBranchesLoading,
|
||||||
isSuccess: isBranchesSuccess,
|
isSuccess: isBranchesSuccess,
|
||||||
} = useBranches();
|
} = useBranches({}, { enabled: isBranchFeatureCan });
|
||||||
|
|
||||||
// Handle fetching settings.
|
// Handle fetching settings.
|
||||||
useSettingsCreditNotes();
|
useSettingsCreditNotes();
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ import {
|
|||||||
useCreateEstimate,
|
useCreateEstimate,
|
||||||
useEditEstimate,
|
useEditEstimate,
|
||||||
} from 'hooks/query';
|
} from 'hooks/query';
|
||||||
|
import { Features } from 'common';
|
||||||
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import { ITEMS_FILTER_ROLES } from './utils';
|
import { ITEMS_FILTER_ROLES } from './utils';
|
||||||
|
|
||||||
const EstimateFormContext = createContext();
|
const EstimateFormContext = createContext();
|
||||||
@@ -19,7 +21,12 @@ const EstimateFormContext = createContext();
|
|||||||
/**
|
/**
|
||||||
* Estimate form provider.
|
* Estimate form provider.
|
||||||
*/
|
*/
|
||||||
function EstimateFormProvider({ estimateId, baseCurrency, ...props }) {
|
function EstimateFormProvider({ query, estimateId, baseCurrency, ...props }) {
|
||||||
|
// Features guard.
|
||||||
|
const { featureCan } = useFeatureCan();
|
||||||
|
const isWarehouseFeatureCan = featureCan(Features.Warehouses);
|
||||||
|
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data: estimate,
|
data: estimate,
|
||||||
isFetching: isEstimateFetching,
|
isFetching: isEstimateFetching,
|
||||||
@@ -48,14 +55,14 @@ function EstimateFormProvider({ estimateId, baseCurrency, ...props }) {
|
|||||||
data: warehouses,
|
data: warehouses,
|
||||||
isLoading: isWarehouesLoading,
|
isLoading: isWarehouesLoading,
|
||||||
isSuccess: isWarehousesSuccess,
|
isSuccess: isWarehousesSuccess,
|
||||||
} = useWarehouses();
|
} = useWarehouses(query, { enabled: isWarehouseFeatureCan });
|
||||||
|
|
||||||
// Fetches the branches list.
|
// Fetches the branches list.
|
||||||
const {
|
const {
|
||||||
data: branches,
|
data: branches,
|
||||||
isLoading: isBranchesLoading,
|
isLoading: isBranchesLoading,
|
||||||
isSuccess: isBranchesSuccess,
|
isSuccess: isBranchesSuccess,
|
||||||
} = useBranches();
|
} = useBranches(query, { enabled: isBranchFeatureCan });
|
||||||
|
|
||||||
// Handle fetch settings.
|
// Handle fetch settings.
|
||||||
useSettingsEstimates();
|
useSettingsEstimates();
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import React, { createContext, useState } from 'react';
|
import React, { createContext, useState } from 'react';
|
||||||
import { isEmpty, pick, isEqual, isUndefined } from 'lodash';
|
import { isEmpty, pick, isEqual, isUndefined } from 'lodash';
|
||||||
import { useLocation } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
|
import { Features } from 'common';
|
||||||
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||||
import { transformToEditForm, ITEMS_FILTER_ROLES_QUERY } from './utils';
|
import { transformToEditForm, ITEMS_FILTER_ROLES_QUERY } from './utils';
|
||||||
import {
|
import {
|
||||||
@@ -24,6 +26,11 @@ function InvoiceFormProvider({ invoiceId, baseCurrency, ...props }) {
|
|||||||
const { state } = useLocation();
|
const { state } = useLocation();
|
||||||
const estimateId = state?.action;
|
const estimateId = state?.action;
|
||||||
|
|
||||||
|
// Features guard.
|
||||||
|
const { featureCan } = useFeatureCan();
|
||||||
|
const isWarehouseFeatureCan = featureCan(Features.Warehouses);
|
||||||
|
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||||
|
|
||||||
const { data: invoice, isLoading: isInvoiceLoading } = useInvoice(invoiceId, {
|
const { data: invoice, isLoading: isInvoiceLoading } = useInvoice(invoiceId, {
|
||||||
enabled: !!invoiceId,
|
enabled: !!invoiceId,
|
||||||
});
|
});
|
||||||
@@ -60,14 +67,14 @@ function InvoiceFormProvider({ invoiceId, baseCurrency, ...props }) {
|
|||||||
data: warehouses,
|
data: warehouses,
|
||||||
isLoading: isWarehouesLoading,
|
isLoading: isWarehouesLoading,
|
||||||
isSuccess: isWarehousesSuccess,
|
isSuccess: isWarehousesSuccess,
|
||||||
} = useWarehouses();
|
} = useWarehouses({}, { enabled: isWarehouseFeatureCan });
|
||||||
|
|
||||||
// Fetches the branches list.
|
// Fetches the branches list.
|
||||||
const {
|
const {
|
||||||
data: branches,
|
data: branches,
|
||||||
isLoading: isBranchesLoading,
|
isLoading: isBranchesLoading,
|
||||||
isSuccess: isBranchesSuccess,
|
isSuccess: isBranchesSuccess,
|
||||||
} = useBranches();
|
} = useBranches({}, { enabled: isBranchFeatureCan });
|
||||||
|
|
||||||
// Handle fetching settings.
|
// Handle fetching settings.
|
||||||
const { isLoading: isSettingsLoading } = useSettingsInvoices();
|
const { isLoading: isSettingsLoading } = useSettingsInvoices();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import React, { createContext, useState } from 'react';
|
import React, { createContext, useState } from 'react';
|
||||||
import { isEmpty, pick, isEqual, isUndefined } from 'lodash';
|
import {isEqual, isUndefined } from 'lodash';
|
||||||
|
import { Features } from 'common';
|
||||||
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
import DashboardInsider from 'components/Dashboard/DashboardInsider';
|
||||||
import {
|
import {
|
||||||
useReceipt,
|
useReceipt,
|
||||||
@@ -20,6 +21,11 @@ const ReceiptFormContext = createContext();
|
|||||||
* Receipt form provider.
|
* Receipt form provider.
|
||||||
*/
|
*/
|
||||||
function ReceiptFormProvider({ receiptId, baseCurrency, ...props }) {
|
function ReceiptFormProvider({ receiptId, baseCurrency, ...props }) {
|
||||||
|
// Features guard.
|
||||||
|
const { featureCan } = useFeatureCan();
|
||||||
|
const isWarehouseFeatureCan = featureCan(Features.Warehouses);
|
||||||
|
const isBranchFeatureCan = featureCan(Features.Branches);
|
||||||
|
|
||||||
// Fetch sale receipt details.
|
// Fetch sale receipt details.
|
||||||
const { data: receipt, isLoading: isReceiptLoading } = useReceipt(receiptId, {
|
const { data: receipt, isLoading: isReceiptLoading } = useReceipt(receiptId, {
|
||||||
enabled: !!receiptId,
|
enabled: !!receiptId,
|
||||||
@@ -38,14 +44,14 @@ function ReceiptFormProvider({ receiptId, baseCurrency, ...props }) {
|
|||||||
data: warehouses,
|
data: warehouses,
|
||||||
isLoading: isWarehouesLoading,
|
isLoading: isWarehouesLoading,
|
||||||
isSuccess: isWarehousesSuccess,
|
isSuccess: isWarehousesSuccess,
|
||||||
} = useWarehouses();
|
} = useWarehouses({}, { enabled: isWarehouseFeatureCan });
|
||||||
|
|
||||||
// Fetches the branches list.
|
// Fetches the branches list.
|
||||||
const {
|
const {
|
||||||
data: branches,
|
data: branches,
|
||||||
isLoading: isBranchesLoading,
|
isLoading: isBranchesLoading,
|
||||||
isSuccess: isBranchesSuccess,
|
isSuccess: isBranchesSuccess,
|
||||||
} = useBranches();
|
} = useBranches({}, { enabled: isBranchFeatureCan });
|
||||||
|
|
||||||
// Filter all sellable items only.
|
// Filter all sellable items only.
|
||||||
const stringifiedFilterRoles = React.useMemo(
|
const stringifiedFilterRoles = React.useMemo(
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import {
|
|||||||
useCreateWarehouseTransfer,
|
useCreateWarehouseTransfer,
|
||||||
useEditWarehouseTransfer,
|
useEditWarehouseTransfer,
|
||||||
} from 'hooks/query';
|
} from 'hooks/query';
|
||||||
|
import { Features } from 'common';
|
||||||
|
import { useFeatureCan } from 'hooks/state';
|
||||||
import { ITEMS_FILTER_ROLES_QUERY } from './utils.js';
|
import { ITEMS_FILTER_ROLES_QUERY } from './utils.js';
|
||||||
|
|
||||||
const WarehouseFormContext = React.createContext();
|
const WarehouseFormContext = React.createContext();
|
||||||
@@ -15,6 +17,10 @@ const WarehouseFormContext = React.createContext();
|
|||||||
* Warehouse transfer form provider.
|
* Warehouse transfer form provider.
|
||||||
*/
|
*/
|
||||||
function WarehouseTransferFormProvider({ warehouseTransferId, ...props }) {
|
function WarehouseTransferFormProvider({ warehouseTransferId, ...props }) {
|
||||||
|
// Features guard.
|
||||||
|
const { featureCan } = useFeatureCan();
|
||||||
|
const isWarehouseFeatureCan = featureCan(Features.Warehouses);
|
||||||
|
|
||||||
// Handle fetch Items data table or list
|
// Handle fetch Items data table or list
|
||||||
const {
|
const {
|
||||||
data: { items },
|
data: { items },
|
||||||
@@ -36,7 +42,7 @@ function WarehouseTransferFormProvider({ warehouseTransferId, ...props }) {
|
|||||||
data: warehouses,
|
data: warehouses,
|
||||||
isFetching: isWarehouesFetching,
|
isFetching: isWarehouesFetching,
|
||||||
isLoading: isWarehouesLoading,
|
isLoading: isWarehouesLoading,
|
||||||
} = useWarehouses();
|
} = useWarehouses({}, { enabled: isWarehouseFeatureCan });
|
||||||
|
|
||||||
// Create and edit warehouse mutations.
|
// Create and edit warehouse mutations.
|
||||||
const { mutateAsync: createWarehouseTransferMutate } =
|
const { mutateAsync: createWarehouseTransferMutate } =
|
||||||
|
|||||||
Reference in New Issue
Block a user