import { useRef, memo, useState } from 'react'; import { addDecimalsFormatNumber } from '@vegaprotocol/utils'; import { t } from '@vegaprotocol/i18n'; import { useDataProvider } from '@vegaprotocol/data-provider'; import type { AgGridReact } from 'ag-grid-react'; import { aggregatedAccountsDataProvider, aggregatedAccountDataProvider, } from './accounts-data-provider'; import type { PinnedAsset } from './accounts-table'; import { AccountTable } from './accounts-table'; import { Dialog } from '@vegaprotocol/ui-toolkit'; import BreakdownTable from './breakdown-table'; const AccountBreakdown = ({ assetId, partyId, }: { assetId: string; partyId: string; }) => { const { data } = useDataProvider({ dataProvider: aggregatedAccountDataProvider, variables: { partyId, assetId }, }); return (

{data?.asset?.symbol} {t('usage breakdown')}

{data && (

{t('You have %s %s in total.', [ addDecimalsFormatNumber(data.total, data.asset.decimals), data.asset.symbol, ])}

)}
); }; interface AccountManagerProps { partyId: string; onClickAsset: (assetId: string) => void; onClickWithdraw?: (assetId?: string) => void; onClickDeposit?: (assetId?: string) => void; isReadOnly: boolean; pinnedAsset?: PinnedAsset; storeKey?: string; } export const AccountManager = ({ onClickAsset, onClickWithdraw, onClickDeposit, partyId, isReadOnly, pinnedAsset, storeKey, }: AccountManagerProps) => { const gridRef = useRef(null); const [breakdownAssetId, setBreakdownAssetId] = useState(); const { data, error } = useDataProvider({ dataProvider: aggregatedAccountsDataProvider, variables: { partyId }, }); return (
{ if (!isOpen) { setBreakdownAssetId(undefined); } }} > {breakdownAssetId && ( )}
); }; export default memo(AccountManager);