2022-11-16 14:10:17 +00:00
|
|
|
import { useCallback } from 'react';
|
2022-10-12 10:49:13 +00:00
|
|
|
import { Button } from '@vegaprotocol/ui-toolkit';
|
2022-09-30 00:40:44 +00:00
|
|
|
import { t } from '@vegaprotocol/react-helpers';
|
2022-11-16 14:10:17 +00:00
|
|
|
import { useWithdrawalDialog } from '@vegaprotocol/withdraws';
|
2022-09-30 00:40:44 +00:00
|
|
|
import { useAssetDetailsDialogStore } from '@vegaprotocol/assets';
|
|
|
|
import { Splash } from '@vegaprotocol/ui-toolkit';
|
|
|
|
import { useVegaWallet } from '@vegaprotocol/wallet';
|
|
|
|
import { AccountManager } from '@vegaprotocol/accounts';
|
2022-11-16 14:10:17 +00:00
|
|
|
import { useDepositDialog } from '@vegaprotocol/deposits';
|
2022-09-30 00:40:44 +00:00
|
|
|
|
|
|
|
export const AccountsContainer = () => {
|
2023-01-31 16:04:52 +00:00
|
|
|
const { pubKey, isReadOnly } = useVegaWallet();
|
2022-10-17 18:57:13 +00:00
|
|
|
const { open: openAssetDetailsDialog } = useAssetDetailsDialogStore();
|
2022-11-16 14:10:17 +00:00
|
|
|
const openWithdrawalDialog = useWithdrawalDialog((store) => store.open);
|
|
|
|
const openDepositDialog = useDepositDialog((store) => store.open);
|
2022-09-30 00:40:44 +00:00
|
|
|
|
2022-11-07 12:14:21 +00:00
|
|
|
const onClickAsset = useCallback(
|
2022-11-23 23:42:22 +00:00
|
|
|
(assetId?: string) => {
|
|
|
|
assetId && openAssetDetailsDialog(assetId);
|
2022-11-07 12:14:21 +00:00
|
|
|
},
|
|
|
|
[openAssetDetailsDialog]
|
|
|
|
);
|
|
|
|
|
2022-10-03 18:12:34 +00:00
|
|
|
if (!pubKey) {
|
2022-09-30 00:40:44 +00:00
|
|
|
return (
|
|
|
|
<Splash>
|
|
|
|
<p>{t('Please connect Vega wallet')}</p>
|
|
|
|
</Splash>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2022-11-16 14:10:17 +00:00
|
|
|
<div className="h-full relative grid grid-rows-[1fr,min-content]">
|
|
|
|
<div>
|
|
|
|
<AccountManager
|
|
|
|
partyId={pubKey}
|
|
|
|
onClickAsset={onClickAsset}
|
|
|
|
onClickWithdraw={openWithdrawalDialog}
|
|
|
|
onClickDeposit={openDepositDialog}
|
2023-01-31 16:04:52 +00:00
|
|
|
isReadOnly={isReadOnly}
|
2022-11-16 14:10:17 +00:00
|
|
|
/>
|
|
|
|
</div>
|
2023-01-31 16:04:52 +00:00
|
|
|
{!isReadOnly && (
|
|
|
|
<div className="flex justify-end p-2 px-[11px]">
|
|
|
|
<Button size="sm" onClick={() => openDepositDialog()}>
|
|
|
|
{t('Deposit')}
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
)}
|
2022-11-16 14:10:17 +00:00
|
|
|
</div>
|
2022-09-30 00:40:44 +00:00
|
|
|
);
|
|
|
|
};
|