2022-09-30 00:40:44 +00:00
|
|
|
import { useState } 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';
|
|
|
|
import { WithdrawalDialogs } from '@vegaprotocol/withdraws';
|
|
|
|
import { Web3Container } from '@vegaprotocol/web3';
|
|
|
|
import { useAssetDetailsDialogStore } from '@vegaprotocol/assets';
|
|
|
|
import { Splash } from '@vegaprotocol/ui-toolkit';
|
|
|
|
import { useVegaWallet } from '@vegaprotocol/wallet';
|
|
|
|
import { AccountManager } from '@vegaprotocol/accounts';
|
2022-10-12 10:49:13 +00:00
|
|
|
import { DepositDialog } from './deposits-container';
|
2022-09-30 00:40:44 +00:00
|
|
|
|
|
|
|
export const AccountsContainer = () => {
|
2022-10-03 18:12:34 +00:00
|
|
|
const { pubKey } = useVegaWallet();
|
2022-10-17 18:57:13 +00:00
|
|
|
const [withdrawDialog, setWithdrawDialog] = useState(false);
|
2022-09-30 00:40:44 +00:00
|
|
|
const [depositDialog, setDepositDialog] = useState(false);
|
2022-10-17 18:57:13 +00:00
|
|
|
const { open: openAssetDetailsDialog } = useAssetDetailsDialogStore();
|
|
|
|
const [assetId, setAssetId] = useState<string>();
|
2022-09-30 00:40:44 +00:00
|
|
|
|
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 (
|
|
|
|
<Web3Container>
|
2022-10-12 10:49:13 +00:00
|
|
|
<div className="h-full relative grid grid-rows-[1fr,min-content]">
|
2022-10-17 18:57:13 +00:00
|
|
|
<div>
|
|
|
|
<AccountManager
|
|
|
|
partyId={pubKey}
|
|
|
|
onClickAsset={(value) => {
|
|
|
|
value && openAssetDetailsDialog(value);
|
|
|
|
}}
|
|
|
|
onClickWithdraw={(assetId) => {
|
|
|
|
setWithdrawDialog(true);
|
|
|
|
setAssetId(assetId);
|
|
|
|
}}
|
|
|
|
onClickDeposit={(assetId) => {
|
|
|
|
setDepositDialog(true);
|
|
|
|
setAssetId(assetId);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="flex justify-end p-2 px-[11px]">
|
|
|
|
<Button
|
|
|
|
size="sm"
|
|
|
|
onClick={() => {
|
|
|
|
setAssetId(undefined);
|
|
|
|
setDepositDialog(true);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{t('Deposit')}
|
2022-10-12 10:49:13 +00:00
|
|
|
</Button>
|
|
|
|
</div>
|
2022-09-30 00:40:44 +00:00
|
|
|
</div>
|
|
|
|
<WithdrawalDialogs
|
|
|
|
assetId={assetId}
|
|
|
|
withdrawDialog={withdrawDialog}
|
|
|
|
setWithdrawDialog={setWithdrawDialog}
|
|
|
|
/>
|
|
|
|
<DepositDialog
|
|
|
|
assetId={assetId}
|
|
|
|
depositDialog={depositDialog}
|
|
|
|
setDepositDialog={setDepositDialog}
|
|
|
|
/>
|
2022-10-17 18:57:13 +00:00
|
|
|
</Web3Container>
|
2022-09-30 00:40:44 +00:00
|
|
|
);
|
|
|
|
};
|