feat: add connect to bank dialog

This commit is contained in:
Ahmed Bouhuolia
2024-02-04 18:48:03 +02:00
parent e0ddcb022a
commit 299a943153
15 changed files with 214 additions and 24 deletions

View File

@@ -5,7 +5,7 @@ import useApiRequest from '../useRequest';
/**
* Retrieves the plaid link token.
*/
export function useGetPlaidLinkToken(props) {
export function useGetPlaidLinkToken(props = {}) {
const apiRequest = useApiRequest();
return useMutation(
@@ -15,3 +15,17 @@ export function useGetPlaidLinkToken(props) {
},
);
}
/**
* Retrieves the plaid link token.
*/
export function usePlaidExchangeToken(props = {}) {
const apiRequest = useApiRequest();
return useMutation(
(data) => apiRequest.post('banking/plaid/exchange-token', data, {}),
{
...props,
},
);
}

View File

@@ -0,0 +1,20 @@
import { getPlaidToken, setPlaidId } from '@/store/banking/banking.reducer';
import { useCallback } from 'react';
import { useDispatch, useSelector } from 'react-redux';
export const useSetBankingPlaidToken = () => {
const dispatch = useDispatch();
return useCallback(
(plaidId: string) => {
dispatch(setPlaidId(plaidId));
},
[dispatch],
);
};
export const useGetBankingPlaidToken = () => {
const plaidToken = useSelector(getPlaidToken);
return plaidToken;
};