feat: hook up the matching form to the server

This commit is contained in:
Ahmed Bouhuolia
2024-06-26 17:39:12 +02:00
parent d2d37820f5
commit 7a9c7209bc
16 changed files with 538 additions and 177 deletions

View File

@@ -0,0 +1,40 @@
import { useMatchingTransactions } from '@/hooks/query/bank-rules';
import React, { createContext } from 'react';
interface MatchingTransactionBootValues {
isMatchingTransactionsLoading: boolean;
matchingTransactions: Array<any>;
perfectMatchesCount: number;
perfectMatches: Array<any>;
matches: Array<any>;
}
const RuleFormBootContext = createContext<MatchingTransactionBootValues>(
{} as MatchingTransactionBootValues,
);
interface RuleFormBootProps {
children: React.ReactNode;
}
function MatchingTransactionBoot({ ...props }: RuleFormBootProps) {
const {
data: matchingTransactions,
isLoading: isMatchingTransactionsLoading,
} = useMatchingTransactions();
const provider = {
isMatchingTransactionsLoading,
matchingTransactions,
perfectMatchesCount: 2,
perfectMatches: [],
matches: [],
} as MatchingTransactionBootValues;
return <RuleFormBootContext.Provider value={provider} {...props} />;
}
const useMatchingTransactionBoot = () =>
React.useContext<MatchingTransactionBootValues>(RuleFormBootContext);
export { MatchingTransactionBoot, useMatchingTransactionBoot };