mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
feat: bulk categorizing bank transactions
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
import { useCallback, useMemo } from 'react';
|
||||
import {
|
||||
getPlaidToken,
|
||||
setPlaidId,
|
||||
resetPlaidId,
|
||||
setTransactionsToCategorizeSelected,
|
||||
resetTransactionsToCategorizeSelected,
|
||||
getTransactionsToCategorizeSelected,
|
||||
addTransactionsToCategorizeSelected,
|
||||
removeTransactionsToCategorizeSelected,
|
||||
} from '@/store/banking/banking.reducer';
|
||||
import { useCallback } from 'react';
|
||||
import { useDispatch, useSelector } from 'react-redux';
|
||||
|
||||
export const useSetBankingPlaidToken = () => {
|
||||
const dispatch = useDispatch();
|
||||
@@ -30,3 +35,50 @@ export const useResetBankingPlaidToken = () => {
|
||||
dispatch(resetPlaidId());
|
||||
}, [dispatch]);
|
||||
};
|
||||
|
||||
export const useGetTransactionsToCategorizeSelected = () => {
|
||||
const selectedTransactions = useSelector(getTransactionsToCategorizeSelected);
|
||||
|
||||
return useMemo(() => selectedTransactions, [selectedTransactions]);
|
||||
};
|
||||
|
||||
export const useSetTransactionsToCategorizeSelected = () => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
return useCallback(
|
||||
(ids: Array<string | number>) => {
|
||||
return dispatch(setTransactionsToCategorizeSelected({ ids }));
|
||||
},
|
||||
[dispatch],
|
||||
);
|
||||
};
|
||||
|
||||
export const useAddTransactionsToCategorizeSelected = () => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
return useCallback(
|
||||
(id: string | number) => {
|
||||
return dispatch(addTransactionsToCategorizeSelected({ id }));
|
||||
},
|
||||
[dispatch],
|
||||
);
|
||||
};
|
||||
|
||||
export const useRemoveTransactionsToCategorizeSelected = () => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
return useCallback(
|
||||
(id: string | number) => {
|
||||
return dispatch(removeTransactionsToCategorizeSelected({ id }));
|
||||
},
|
||||
[dispatch],
|
||||
);
|
||||
};
|
||||
|
||||
export const useResetTransactionsToCategorizeSelected = () => {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
return useCallback(() => {
|
||||
dispatch(resetTransactionsToCategorizeSelected());
|
||||
}, [dispatch]);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user