mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06:40:31 +00:00
fix: refresh accounts and account transactions.
This commit is contained in:
@@ -32,7 +32,7 @@ import {
|
|||||||
getAddMoneyOutOptions,
|
getAddMoneyOutOptions,
|
||||||
getAddMoneyInOptions,
|
getAddMoneyInOptions,
|
||||||
} from '@/constants/cashflowOptions';
|
} from '@/constants/cashflowOptions';
|
||||||
import { useRefreshCashflowTransactionsInfinity } from '@/hooks/query';
|
import { useRefreshCashflowTransactions } from '@/hooks/query';
|
||||||
import { useAccountTransactionsContext } from './AccountTransactionsProvider';
|
import { useAccountTransactionsContext } from './AccountTransactionsProvider';
|
||||||
|
|
||||||
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
import withDialogActions from '@/containers/Dialog/withDialogActions';
|
||||||
@@ -76,7 +76,7 @@ function AccountTransactionsActionsBar({
|
|||||||
const { accountId, currentAccount } = useAccountTransactionsContext();
|
const { accountId, currentAccount } = useAccountTransactionsContext();
|
||||||
|
|
||||||
// Refresh cashflow infinity transactions hook.
|
// Refresh cashflow infinity transactions hook.
|
||||||
const { refresh } = useRefreshCashflowTransactionsInfinity();
|
const { refresh } = useRefreshCashflowTransactions();
|
||||||
|
|
||||||
const { mutateAsync: updateBankAccount } = useUpdateBankAccount();
|
const { mutateAsync: updateBankAccount } = useUpdateBankAccount();
|
||||||
|
|
||||||
@@ -141,7 +141,7 @@ function AccountTransactionsActionsBar({
|
|||||||
};
|
};
|
||||||
// Handle the refresh button click.
|
// Handle the refresh button click.
|
||||||
const handleRefreshBtnClick = () => {
|
const handleRefreshBtnClick = () => {
|
||||||
refresh();
|
refresh(accountId);
|
||||||
};
|
};
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
|||||||
@@ -48,8 +48,11 @@ function AccountTransactionsDataTable({
|
|||||||
const columns = useAccountTransactionsColumns();
|
const columns = useAccountTransactionsColumns();
|
||||||
|
|
||||||
// Retrieve list context.
|
// Retrieve list context.
|
||||||
const { cashflowTransactions, isCashFlowTransactionsLoading } =
|
const {
|
||||||
useAccountTransactionsAllContext();
|
cashflowTransactions,
|
||||||
|
isCashFlowTransactionsLoading,
|
||||||
|
isCashFlowTransactionsFetching,
|
||||||
|
} = useAccountTransactionsAllContext();
|
||||||
|
|
||||||
const { mutateAsync: uncategorizeTransaction } = useUncategorizeTransaction();
|
const { mutateAsync: uncategorizeTransaction } = useUncategorizeTransaction();
|
||||||
const { mutateAsync: unmatchTransaction } =
|
const { mutateAsync: unmatchTransaction } =
|
||||||
@@ -118,6 +121,7 @@ function AccountTransactionsDataTable({
|
|||||||
sticky={true}
|
sticky={true}
|
||||||
loading={isCashFlowTransactionsLoading}
|
loading={isCashFlowTransactionsLoading}
|
||||||
headerLoading={isCashFlowTransactionsLoading}
|
headerLoading={isCashFlowTransactionsLoading}
|
||||||
|
progressBarLoading={isCashFlowTransactionsFetching}
|
||||||
expandColumnSpace={1}
|
expandColumnSpace={1}
|
||||||
expandToggleColumn={2}
|
expandToggleColumn={2}
|
||||||
selectionColumnWidth={45}
|
selectionColumnWidth={45}
|
||||||
|
|||||||
@@ -13,10 +13,10 @@ import {
|
|||||||
useAccountTransactionsContext,
|
useAccountTransactionsContext,
|
||||||
} from './AccountTransactionsProvider';
|
} from './AccountTransactionsProvider';
|
||||||
import { AccountTransactionsDetailsBar } from './AccountTransactionsDetailsBar';
|
import { AccountTransactionsDetailsBar } from './AccountTransactionsDetailsBar';
|
||||||
import { AccountTransactionsProgressBar } from './components';
|
|
||||||
import { AccountTransactionsFilterTabs } from './AccountTransactionsFilterTabs';
|
import { AccountTransactionsFilterTabs } from './AccountTransactionsFilterTabs';
|
||||||
import { AppContentShell } from '@/components/AppShell';
|
import { AppContentShell } from '@/components/AppShell';
|
||||||
import { CategorizeTransactionAside } from '../CategorizeTransactionAside/CategorizeTransactionAside';
|
import { CategorizeTransactionAside } from '../CategorizeTransactionAside/CategorizeTransactionAside';
|
||||||
|
import { AccountTransactionsLoadingBar } from './components';
|
||||||
import { withBanking } from '../withBanking';
|
import { withBanking } from '../withBanking';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -42,8 +42,8 @@ function AccountTransactionsMain() {
|
|||||||
return (
|
return (
|
||||||
<AppContentShell.Main ref={(e) => setScrollableRef(e)}>
|
<AppContentShell.Main ref={(e) => setScrollableRef(e)}>
|
||||||
<AccountTransactionsActionsBar />
|
<AccountTransactionsActionsBar />
|
||||||
|
<AccountTransactionsLoadingBar />
|
||||||
<AccountTransactionsDetailsBar />
|
<AccountTransactionsDetailsBar />
|
||||||
<AccountTransactionsProgressBar />
|
|
||||||
|
|
||||||
<DashboardPageContent>
|
<DashboardPageContent>
|
||||||
<AccountTransactionsFilterTabs />
|
<AccountTransactionsFilterTabs />
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ function AccountTransactionsProvider({ query, ...props }) {
|
|||||||
const {
|
const {
|
||||||
data: bankAccountMetaSummary,
|
data: bankAccountMetaSummary,
|
||||||
isLoading: isBankAccountMetaSummaryLoading,
|
isLoading: isBankAccountMetaSummaryLoading,
|
||||||
|
isFetching: isBankAccountMetaSummaryFetching,
|
||||||
} = useGetBankAccountSummaryMeta(accountId);
|
} = useGetBankAccountSummaryMeta(accountId);
|
||||||
|
|
||||||
const [scrollableRef, setScrollableRef] = useState();
|
const [scrollableRef, setScrollableRef] = useState();
|
||||||
@@ -52,15 +53,18 @@ function AccountTransactionsProvider({ query, ...props }) {
|
|||||||
|
|
||||||
isCashFlowAccountsFetching,
|
isCashFlowAccountsFetching,
|
||||||
isCashFlowAccountsLoading,
|
isCashFlowAccountsLoading,
|
||||||
|
|
||||||
isCurrentAccountFetching,
|
isCurrentAccountFetching,
|
||||||
isCurrentAccountLoading,
|
isCurrentAccountLoading,
|
||||||
|
|
||||||
isBankAccountMetaSummaryLoading,
|
isBankAccountMetaSummaryLoading,
|
||||||
|
isBankAccountMetaSummaryFetching,
|
||||||
|
|
||||||
filterTab,
|
filterTab,
|
||||||
setFilterTab,
|
setFilterTab,
|
||||||
|
|
||||||
scrollableRef,
|
scrollableRef,
|
||||||
setScrollableRef
|
setScrollableRef,
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -34,7 +34,11 @@ function ExcludedTransactionsTableRoot({
|
|||||||
// #withBankingActions
|
// #withBankingActions
|
||||||
setExcludedTransactionsSelected,
|
setExcludedTransactionsSelected,
|
||||||
}: ExcludeTransactionsTableProps) {
|
}: ExcludeTransactionsTableProps) {
|
||||||
const { excludedBankTransactions } = useExcludedTransactionsBoot();
|
const {
|
||||||
|
excludedBankTransactions,
|
||||||
|
isExcludedTransactionsLoading,
|
||||||
|
isExcludedTransactionsFetching,
|
||||||
|
} = useExcludedTransactionsBoot();
|
||||||
const { mutateAsync: unexcludeBankTransaction } =
|
const { mutateAsync: unexcludeBankTransaction } =
|
||||||
useUnexcludeUncategorizedTransaction();
|
useUnexcludeUncategorizedTransaction();
|
||||||
|
|
||||||
@@ -79,8 +83,9 @@ function ExcludedTransactionsTableRoot({
|
|||||||
columns={columns}
|
columns={columns}
|
||||||
data={excludedBankTransactions}
|
data={excludedBankTransactions}
|
||||||
sticky={true}
|
sticky={true}
|
||||||
loading={false}
|
loading={isExcludedTransactionsLoading}
|
||||||
headerLoading={false}
|
headerLoading={isExcludedTransactionsLoading}
|
||||||
|
progressBarLoading={isExcludedTransactionsFetching}
|
||||||
expandColumnSpace={1}
|
expandColumnSpace={1}
|
||||||
expandToggleColumn={2}
|
expandToggleColumn={2}
|
||||||
selectionColumnWidth={45}
|
selectionColumnWidth={45}
|
||||||
|
|||||||
@@ -30,8 +30,11 @@ function PendingTransactionsDataTableRoot({
|
|||||||
const { scrollableRef } = useAccountTransactionsContext();
|
const { scrollableRef } = useAccountTransactionsContext();
|
||||||
|
|
||||||
// Retrieve list context.
|
// Retrieve list context.
|
||||||
const { pendingTransactions, isPendingTransactionsLoading } =
|
const {
|
||||||
usePendingTransactionsContext();
|
pendingTransactions,
|
||||||
|
isPendingTransactionsLoading,
|
||||||
|
isPendingTransactionFetching,
|
||||||
|
} = usePendingTransactionsContext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CashflowTransactionsTable
|
<CashflowTransactionsTable
|
||||||
@@ -41,6 +44,7 @@ function PendingTransactionsDataTableRoot({
|
|||||||
sticky={true}
|
sticky={true}
|
||||||
loading={isPendingTransactionsLoading}
|
loading={isPendingTransactionsLoading}
|
||||||
headerLoading={isPendingTransactionsLoading}
|
headerLoading={isPendingTransactionsLoading}
|
||||||
|
progressBarLoading={isPendingTransactionFetching}
|
||||||
TableCellRenderer={TableFastCell}
|
TableCellRenderer={TableFastCell}
|
||||||
TableLoadingRenderer={TableSkeletonRows}
|
TableLoadingRenderer={TableSkeletonRows}
|
||||||
TableRowsRenderer={TableVirtualizedListRows}
|
TableRowsRenderer={TableVirtualizedListRows}
|
||||||
|
|||||||
@@ -52,8 +52,11 @@ function AccountTransactionsDataTable({
|
|||||||
const { scrollableRef } = useAccountTransactionsContext();
|
const { scrollableRef } = useAccountTransactionsContext();
|
||||||
|
|
||||||
// Retrieve list context.
|
// Retrieve list context.
|
||||||
const { uncategorizedTransactions, isUncategorizedTransactionsLoading } =
|
const {
|
||||||
useAccountUncategorizedTransactionsContext();
|
uncategorizedTransactions,
|
||||||
|
isUncategorizedTransactionsLoading,
|
||||||
|
isUncategorizedTransactionFetching,
|
||||||
|
} = useAccountUncategorizedTransactionsContext();
|
||||||
|
|
||||||
const { mutateAsync: excludeTransaction } =
|
const { mutateAsync: excludeTransaction } =
|
||||||
useExcludeUncategorizedTransaction();
|
useExcludeUncategorizedTransaction();
|
||||||
@@ -105,6 +108,7 @@ function AccountTransactionsDataTable({
|
|||||||
selectionColumn={true}
|
selectionColumn={true}
|
||||||
loading={isUncategorizedTransactionsLoading}
|
loading={isUncategorizedTransactionsLoading}
|
||||||
headerLoading={isUncategorizedTransactionsLoading}
|
headerLoading={isUncategorizedTransactionsLoading}
|
||||||
|
progressBarLoading={isUncategorizedTransactionFetching}
|
||||||
expandColumnSpace={1}
|
expandColumnSpace={1}
|
||||||
expandToggleColumn={2}
|
expandToggleColumn={2}
|
||||||
selectionColumnWidth={45}
|
selectionColumnWidth={45}
|
||||||
|
|||||||
@@ -1,18 +1,29 @@
|
|||||||
// @ts-nocheck
|
// @ts-nocheck
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import intl from 'react-intl-universal';
|
import intl from 'react-intl-universal';
|
||||||
import {
|
import { Intent, Menu, MenuItem, Tag } from '@blueprintjs/core';
|
||||||
Intent,
|
import { FormatDateCell, Icon } from '@/components';
|
||||||
Menu,
|
|
||||||
MenuItem,
|
|
||||||
Tag,
|
|
||||||
PopoverInteractionKind,
|
|
||||||
Position,
|
|
||||||
Tooltip,
|
|
||||||
} from '@blueprintjs/core';
|
|
||||||
import { Box, FormatDateCell, Icon, MaterialProgressBar } from '@/components';
|
|
||||||
import { useAccountTransactionsContext } from './AccountTransactionsProvider';
|
|
||||||
import { safeCallback } from '@/utils';
|
import { safeCallback } from '@/utils';
|
||||||
|
import { useAccountTransactionsContext } from './AccountTransactionsProvider';
|
||||||
|
import FinancialLoadingBar from '@/containers/FinancialStatements/FinancialLoadingBar';
|
||||||
|
|
||||||
|
export function AccountTransactionsLoadingBar() {
|
||||||
|
const {
|
||||||
|
isBankAccountMetaSummaryFetching,
|
||||||
|
isCurrentAccountFetching,
|
||||||
|
isCashFlowAccountsFetching,
|
||||||
|
} = useAccountTransactionsContext();
|
||||||
|
|
||||||
|
const isLoading =
|
||||||
|
isCashFlowAccountsFetching ||
|
||||||
|
isCurrentAccountFetching ||
|
||||||
|
isBankAccountMetaSummaryFetching;
|
||||||
|
|
||||||
|
if (isLoading) {
|
||||||
|
return <FinancialLoadingBar />;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
export function ActionsMenu({
|
export function ActionsMenu({
|
||||||
payload: { onUncategorize, onUnmatch },
|
payload: { onUncategorize, onUnmatch },
|
||||||
@@ -137,16 +148,3 @@ export function useAccountTransactionsColumns() {
|
|||||||
[],
|
[],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Account transactions progress bar.
|
|
||||||
*/
|
|
||||||
export function AccountTransactionsProgressBar() {
|
|
||||||
const { isCashFlowTransactionsFetching, isUncategorizedTransactionFetching } =
|
|
||||||
useAccountTransactionsContext();
|
|
||||||
|
|
||||||
return isCashFlowTransactionsFetching ||
|
|
||||||
isUncategorizedTransactionFetching ? (
|
|
||||||
<MaterialProgressBar />
|
|
||||||
) : null;
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import { CashFlowAccountsProvider } from './CashFlowAccountsProvider';
|
|||||||
import CashflowAccountsGrid from './CashflowAccountsGrid';
|
import CashflowAccountsGrid from './CashflowAccountsGrid';
|
||||||
import CashFlowAccountsActionsBar from './CashFlowAccountsActionsBar';
|
import CashFlowAccountsActionsBar from './CashFlowAccountsActionsBar';
|
||||||
import { CashflowAccountsPlaidLink } from './CashflowAccountsPlaidLink';
|
import { CashflowAccountsPlaidLink } from './CashflowAccountsPlaidLink';
|
||||||
|
import { CashflowAccountsLoadingBar } from './CashFlowAccountsLoadingBar';
|
||||||
|
|
||||||
import withCashflowAccounts from '@/containers/CashFlow/AccountTransactions/withCashflowAccounts';
|
import withCashflowAccounts from '@/containers/CashFlow/AccountTransactions/withCashflowAccounts';
|
||||||
import withCashflowAccountsTableActions from '@/containers/CashFlow/AccountTransactions/withCashflowAccountsTableActions';
|
import withCashflowAccountsTableActions from '@/containers/CashFlow/AccountTransactions/withCashflowAccountsTableActions';
|
||||||
@@ -35,6 +36,7 @@ function CashFlowAccountsList({
|
|||||||
return (
|
return (
|
||||||
<CashFlowAccountsProvider tableState={cashflowAccountsTableState}>
|
<CashFlowAccountsProvider tableState={cashflowAccountsTableState}>
|
||||||
<CashFlowAccountsActionsBar />
|
<CashFlowAccountsActionsBar />
|
||||||
|
<CashflowAccountsLoadingBar />
|
||||||
|
|
||||||
<DashboardPageContent>
|
<DashboardPageContent>
|
||||||
<CashflowAccountsGrid />
|
<CashflowAccountsGrid />
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
// @ts-nocheck
|
||||||
|
import FinancialLoadingBar from '@/containers/FinancialStatements/FinancialLoadingBar';
|
||||||
|
import { useCashFlowAccountsContext } from './CashFlowAccountsProvider';
|
||||||
|
|
||||||
|
export function CashflowAccountsLoadingBar() {
|
||||||
|
const { isCashFlowAccountsFetching } = useCashFlowAccountsContext();
|
||||||
|
|
||||||
|
if (isCashFlowAccountsFetching) {
|
||||||
|
return <FinancialLoadingBar />;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import { useMutation, useQueryClient, useInfiniteQuery } from 'react-query';
|
|||||||
import { useRequestQuery } from '../useQueryRequest';
|
import { useRequestQuery } from '../useQueryRequest';
|
||||||
import useApiRequest from '../useRequest';
|
import useApiRequest from '../useRequest';
|
||||||
import t from './types';
|
import t from './types';
|
||||||
|
import { BANK_QUERY_KEY } from '@/constants/query-keys/banking';
|
||||||
|
|
||||||
const commonInvalidateQueries = (queryClient) => {
|
const commonInvalidateQueries = (queryClient) => {
|
||||||
// Invalidate settings.
|
// Invalidate settings.
|
||||||
@@ -175,19 +176,6 @@ export function useAccountUncategorizedTransactionsInfinity(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Refresh cashflow transactions infinity.
|
|
||||||
*/
|
|
||||||
export function useRefreshCashflowTransactionsInfinity() {
|
|
||||||
const queryClient = useQueryClient();
|
|
||||||
|
|
||||||
return {
|
|
||||||
refresh: () => {
|
|
||||||
queryClient.invalidateQueries(t.CASHFLOW_ACCOUNT_TRANSACTIONS_INFINITY);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh cashflow accounts.
|
* Refresh cashflow accounts.
|
||||||
*/
|
*/
|
||||||
@@ -208,8 +196,25 @@ export function useRefreshCashflowTransactions() {
|
|||||||
const query = useQueryClient();
|
const query = useQueryClient();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
refresh: () => {
|
refresh: (accountId: number) => {
|
||||||
query.invalidateQueries(t.CASH_FLOW_TRANSACTIONS);
|
query.invalidateQueries(t.CASHFLOW_ACCOUNT_TRANSACTIONS_INFINITY);
|
||||||
|
query.invalidateQueries(
|
||||||
|
t.CASHFLOW_ACCOUNT_UNCATEGORIZED_TRANSACTIONS_INFINITY,
|
||||||
|
);
|
||||||
|
query.invalidateQueries(
|
||||||
|
BANK_QUERY_KEY.RECOGNIZED_BANK_TRANSACTIONS_INFINITY,
|
||||||
|
);
|
||||||
|
query.invalidateQueries(
|
||||||
|
BANK_QUERY_KEY.EXCLUDED_BANK_TRANSACTIONS_INFINITY,
|
||||||
|
);
|
||||||
|
query.invalidateQueries(
|
||||||
|
BANK_QUERY_KEY.PENDING_BANK_ACCOUNT_TRANSACTIONS_INFINITY,
|
||||||
|
);
|
||||||
|
query.invalidateQueries([
|
||||||
|
BANK_QUERY_KEY.BANK_ACCOUNT_SUMMARY_META,
|
||||||
|
accountId,
|
||||||
|
]);
|
||||||
|
query.invalidateQueries([t.ACCOUNT, accountId]);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user