feat: control the multi-select switch

This commit is contained in:
Ahmed Bouhuolia
2024-08-04 15:42:53 +02:00
parent 00f5bb1d73
commit 647bed5c67
2 changed files with 47 additions and 17 deletions

View File

@@ -10,6 +10,7 @@ import {
addTransactionsToCategorizeSelected,
removeTransactionsToCategorizeSelected,
getOpenMatchingTransactionAside,
getTransactionsToCategorizeIdsSelected,
} from '@/store/banking/banking.reducer';
export const useSetBankingPlaidToken = () => {
@@ -94,3 +95,18 @@ export const useGetOpenMatchingTransactionAside = () => {
[openMatchingTransactionAside],
);
};
/**
* Returns the detarmined value whether the given transaction id is checked.
* @param {number} transactionId
* @returns {boolean}
*/
export const useIsTransactionToCategorizeSelected = (transactionId: number) => {
const transactionsToCategorizeIdsSelected = useSelector(
getTransactionsToCategorizeIdsSelected,
);
return useMemo(
() => transactionsToCategorizeIdsSelected.indexOf(transactionId) !== -1,
[transactionsToCategorizeIdsSelected, transactionId],
);
};