mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
Merge pull request #589 from bigcapitalhq/bank-pending-transactions
feat: Pending bank transactions
This commit is contained in:
@@ -686,3 +686,34 @@ export function useExcludedBankTransactionsInfinity(
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export function usePendingBankTransactionsInfinity(
|
||||
query,
|
||||
infinityProps,
|
||||
axios,
|
||||
) {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useInfiniteQuery(
|
||||
[BANK_QUERY_KEY.PENDING_BANK_ACCOUNT_TRANSACTIONS_INFINITY, query],
|
||||
async ({ pageParam = 1 }) => {
|
||||
const response = await apiRequest.http({
|
||||
...axios,
|
||||
method: 'get',
|
||||
url: `/api/banking/bank_accounts/pending_transactions`,
|
||||
params: { page: pageParam, ...query },
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
{
|
||||
getPreviousPageParam: (firstPage) => firstPage.pagination.page - 1,
|
||||
getNextPageParam: (lastPage) => {
|
||||
const { pagination } = lastPage;
|
||||
return pagination.total > pagination.page_size * pagination.page
|
||||
? lastPage.pagination.page + 1
|
||||
: undefined;
|
||||
},
|
||||
...infinityProps,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
28
packages/webapp/src/hooks/query/bank-transaction.ts
Normal file
28
packages/webapp/src/hooks/query/bank-transaction.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
// @ts-nocheck
|
||||
import { useQuery, UseQueryOptions, UseQueryResult } from 'react-query';
|
||||
import useApiRequest from '../useRequest';
|
||||
import { BANK_QUERY_KEY } from '@/constants/query-keys/banking';
|
||||
|
||||
interface GetBankRuleRes {}
|
||||
|
||||
/**
|
||||
* Retrieve the given bank rule.
|
||||
* @param {number} bankRuleId -
|
||||
* @param {UseQueryOptions<GetBankRuleRes, Error>} options -
|
||||
* @returns {UseQueryResult<GetBankRuleRes, Error>}
|
||||
*/
|
||||
export function usePendingBankAccountTransactions(
|
||||
bankRuleId: number,
|
||||
options?: UseQueryOptions<GetBankRuleRes, Error>,
|
||||
): UseQueryResult<GetBankRuleRes, Error> {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery<GetBankRuleRes, Error>(
|
||||
[BANK_QUERY_KEY.PENDING_BANK_ACCOUNT_TRANSACTIONS],
|
||||
() =>
|
||||
apiRequest
|
||||
.get(`/banking/bank_account/pending_transactions`)
|
||||
.then((res) => res.data),
|
||||
{ ...options },
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user