feat: account drawer.

This commit is contained in:
elforjani3
2021-04-27 15:58:37 +02:00
parent 5bb31f783c
commit 5b62410afa
14 changed files with 437 additions and 12 deletions

View File

@@ -0,0 +1,40 @@
import React from 'react';
import { useAccount, useAccountTransactions } from 'hooks/query';
import DashboardInsider from 'components/Dashboard/DashboardInsider';
const AccountDrawerContext = React.createContext();
/**
* Account drawer provider.
*/
function AccountDrawerProvider({ accountId, ...props }) {
// Fetches the specific account details.
const { data: account, isLoading: isAccountLoading } = useAccount(accountId, {
enabled: !!accountId,
});
// Load the specific account transactions.
const {
data: accounts,
isLoading: isAccountsLoading,
} = useAccountTransactions(accountId, {
enabled: !!accountId,
});
// provider.
const provider = {
accountId,
account,
accounts,
};
return (
<DashboardInsider loading={isAccountLoading || isAccountsLoading}>
<AccountDrawerContext.Provider value={provider} {...props} />
</DashboardInsider>
);
}
const useAccountDrawerContext = () => React.useContext(AccountDrawerContext);
export { AccountDrawerProvider, useAccountDrawerContext };