7c5bfc4471
* feat: #1648 add deposit button and show accounts 0 state * fix: remove text-white and text-black * fix: #1648 revert and add back row model type and data source in accounts table * fix: #1648 fix linting issue * fix: #1648 table tweaks buttons at the bottom * fix: #1644 hide withdrawals history title * fix: #1648 fix accounts-table test * fix: #1648 fix trading-accounts.cy.ts test * fix: leave ag grid to show overlay if data is simply null but there is no error or it's not loading Co-authored-by: Bartłomiej Głownia <bglownia@gmail.com>
76 lines
2.3 KiB
TypeScript
76 lines
2.3 KiB
TypeScript
import { useState } from 'react';
|
|
import { Button } from '@vegaprotocol/ui-toolkit';
|
|
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';
|
|
import { DepositDialog } from './deposits-container';
|
|
|
|
export const AccountsContainer = () => {
|
|
const { pubKey } = useVegaWallet();
|
|
const [depositDialog, setDepositDialog] = useState(false);
|
|
|
|
if (!pubKey) {
|
|
return (
|
|
<Splash>
|
|
<p>{t('Please connect Vega wallet')}</p>
|
|
</Splash>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<Web3Container>
|
|
<div className="h-full relative grid grid-rows-[1fr,min-content]">
|
|
<AssetAccountTable partyId={pubKey} />
|
|
<DepositDialog
|
|
depositDialog={depositDialog}
|
|
setDepositDialog={setDepositDialog}
|
|
/>
|
|
<div className="w-full dark:bg-black bg-white absolute bottom-0 h-auto flex justify-end px-[11px] py-2">
|
|
<Button size="sm" onClick={() => setDepositDialog(true)}>
|
|
Deposit
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
</Web3Container>
|
|
);
|
|
};
|
|
|
|
export const AssetAccountTable = ({ partyId }: { partyId: string }) => {
|
|
const [withdrawDialog, setWithdrawDialog] = useState(false);
|
|
const [depositDialog, setDepositDialog] = useState(false);
|
|
const { open: openAssetDetailsDialog } = useAssetDetailsDialogStore();
|
|
const [assetId, setAssetId] = useState<string>();
|
|
return (
|
|
<>
|
|
<AccountManager
|
|
partyId={partyId}
|
|
onClickAsset={(value) => {
|
|
value && openAssetDetailsDialog(value);
|
|
}}
|
|
onClickWithdraw={(assetId) => {
|
|
setWithdrawDialog(true);
|
|
setAssetId(assetId);
|
|
}}
|
|
onClickDeposit={(assetId) => {
|
|
setDepositDialog(true);
|
|
setAssetId(assetId);
|
|
}}
|
|
/>
|
|
<WithdrawalDialogs
|
|
assetId={assetId}
|
|
withdrawDialog={withdrawDialog}
|
|
setWithdrawDialog={setWithdrawDialog}
|
|
/>
|
|
<DepositDialog
|
|
assetId={assetId}
|
|
depositDialog={depositDialog}
|
|
setDepositDialog={setDepositDialog}
|
|
/>
|
|
</>
|
|
);
|
|
};
|