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