mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
feat: add connect to bank dialog
This commit is contained in:
@@ -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,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
20
packages/webapp/src/hooks/state/banking.ts
Normal file
20
packages/webapp/src/hooks/state/banking.ts
Normal 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;
|
||||
};
|
||||
Reference in New Issue
Block a user