mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-19 22:30:31 +00:00
feat: Edit stripe payment integation drawer
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import React, { createContext, useContext } from 'react';
|
||||
import { Spinner } from '@blueprintjs/core';
|
||||
import { useAccounts } from '@/hooks/query';
|
||||
|
||||
interface StripeIntegrationEditContextType {
|
||||
accounts: any;
|
||||
isAccountsLoading: boolean;
|
||||
}
|
||||
|
||||
const StripeIntegrationEditContext =
|
||||
createContext<StripeIntegrationEditContextType>(
|
||||
{} as StripeIntegrationEditContextType,
|
||||
);
|
||||
|
||||
export const useStripeIntegrationEditBoot = () => {
|
||||
const context = useContext<StripeIntegrationEditContextType>(
|
||||
StripeIntegrationEditContext,
|
||||
);
|
||||
|
||||
if (!context) {
|
||||
throw new Error(
|
||||
'useStripeIntegrationEditContext must be used within a StripeIntegrationEditProvider',
|
||||
);
|
||||
}
|
||||
return context;
|
||||
};
|
||||
|
||||
export const StripeIntegrationEditBoot: React.FC = ({ children }) => {
|
||||
const { data: accounts, isLoading: isAccountsLoading } = useAccounts({}, {});
|
||||
const value = { accounts, isAccountsLoading };
|
||||
const isLoading = isAccountsLoading;
|
||||
|
||||
if (isLoading) {
|
||||
return <Spinner size={20} />;
|
||||
}
|
||||
return (
|
||||
<StripeIntegrationEditContext.Provider value={value}>
|
||||
{children}
|
||||
</StripeIntegrationEditContext.Provider>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user