mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
fix: Organize Plaid env variables for development and sandbox envs (#480)
This commit is contained in:
25
packages/webapp/src/hooks/utils/useOpenPlaidConnect.ts
Normal file
25
packages/webapp/src/hooks/utils/useOpenPlaidConnect.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { useCallback } from 'react';
|
||||
import { useSetBankingPlaidToken } from '../state/banking';
|
||||
import { AppToaster } from '@/components';
|
||||
import { useGetPlaidLinkToken } from '../query';
|
||||
import { Intent } from '@blueprintjs/core';
|
||||
|
||||
export const useOpenPlaidConnect = () => {
|
||||
const { mutateAsync: getPlaidLinkToken, isLoading } = useGetPlaidLinkToken();
|
||||
const setPlaidId = useSetBankingPlaidToken();
|
||||
|
||||
const openPlaidAsync = useCallback(() => {
|
||||
return getPlaidLinkToken()
|
||||
.then((res) => {
|
||||
setPlaidId(res.data.link_token);
|
||||
})
|
||||
.catch(() => {
|
||||
AppToaster.show({
|
||||
message: 'Something went wrong.',
|
||||
intent: Intent.DANGER,
|
||||
});
|
||||
});
|
||||
}, [getPlaidLinkToken, setPlaidId]);
|
||||
|
||||
return { openPlaidAsync, isPlaidLoading: isLoading };
|
||||
};
|
||||
Reference in New Issue
Block a user