feat: 1648 add deposit button and show accounts 0 state (#1696)
* 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>
This commit is contained in:
parent
00381a2b3e
commit
7c5bfc4471
@ -33,7 +33,7 @@ describe('accounts', { tags: '@smoke' }, () => {
|
|||||||
cy.getByTestId('tab-accounts')
|
cy.getByTestId('tab-accounts')
|
||||||
.get(tradingAccountRowId)
|
.get(tradingAccountRowId)
|
||||||
.find('[col-id="breakdown"]')
|
.find('[col-id="breakdown"]')
|
||||||
.should('have.text', 'Collateral breakdown');
|
.should('have.text', 'Breakdown');
|
||||||
|
|
||||||
cy.getByTestId('tab-accounts')
|
cy.getByTestId('tab-accounts')
|
||||||
.get(tradingAccountRowId)
|
.get(tradingAccountRowId)
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { Dialog } from '@vegaprotocol/ui-toolkit';
|
import { Button } from '@vegaprotocol/ui-toolkit';
|
||||||
import { t } from '@vegaprotocol/react-helpers';
|
import { t } from '@vegaprotocol/react-helpers';
|
||||||
import { WithdrawalDialogs } from '@vegaprotocol/withdraws';
|
import { WithdrawalDialogs } from '@vegaprotocol/withdraws';
|
||||||
import { Web3Container } from '@vegaprotocol/web3';
|
import { Web3Container } from '@vegaprotocol/web3';
|
||||||
import { DepositContainer } from '@vegaprotocol/deposits';
|
|
||||||
import { useAssetDetailsDialogStore } from '@vegaprotocol/assets';
|
import { useAssetDetailsDialogStore } from '@vegaprotocol/assets';
|
||||||
import { Splash } from '@vegaprotocol/ui-toolkit';
|
import { Splash } from '@vegaprotocol/ui-toolkit';
|
||||||
import { useVegaWallet } from '@vegaprotocol/wallet';
|
import { useVegaWallet } from '@vegaprotocol/wallet';
|
||||||
import { AccountManager } from '@vegaprotocol/accounts';
|
import { AccountManager } from '@vegaprotocol/accounts';
|
||||||
|
import { DepositDialog } from './deposits-container';
|
||||||
|
|
||||||
export const AccountsContainer = () => {
|
export const AccountsContainer = () => {
|
||||||
const { pubKey } = useVegaWallet();
|
const { pubKey } = useVegaWallet();
|
||||||
@ -23,12 +23,17 @@ export const AccountsContainer = () => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Web3Container>
|
<Web3Container>
|
||||||
<div className="h-full">
|
<div className="h-full relative grid grid-rows-[1fr,min-content]">
|
||||||
<AssetAccountTable partyId={pubKey} />
|
<AssetAccountTable partyId={pubKey} />
|
||||||
<DepositDialog
|
<DepositDialog
|
||||||
depositDialog={depositDialog}
|
depositDialog={depositDialog}
|
||||||
setDepositDialog={setDepositDialog}
|
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>
|
</div>
|
||||||
</Web3Container>
|
</Web3Container>
|
||||||
);
|
);
|
||||||
@ -68,22 +73,3 @@ export const AssetAccountTable = ({ partyId }: { partyId: string }) => {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface DepositDialogProps {
|
|
||||||
assetId?: string;
|
|
||||||
depositDialog: boolean;
|
|
||||||
setDepositDialog: (open: boolean) => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const DepositDialog = ({
|
|
||||||
assetId,
|
|
||||||
depositDialog,
|
|
||||||
setDepositDialog,
|
|
||||||
}: DepositDialogProps) => {
|
|
||||||
return (
|
|
||||||
<Dialog open={depositDialog} onChange={setDepositDialog}>
|
|
||||||
<h1 className="text-2xl mb-4">{t('Deposit')}</h1>
|
|
||||||
<DepositContainer assetId={assetId} />
|
|
||||||
</Dialog>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
@ -1,20 +1,15 @@
|
|||||||
import { AsyncRenderer, Button } from '@vegaprotocol/ui-toolkit';
|
import { AsyncRenderer, Button, Dialog } from '@vegaprotocol/ui-toolkit';
|
||||||
import { DepositsTable } from '@vegaprotocol/deposits';
|
import { DepositContainer, DepositsTable } from '@vegaprotocol/deposits';
|
||||||
import { useDeposits } from '@vegaprotocol/deposits';
|
import { useDeposits } from '@vegaprotocol/deposits';
|
||||||
import { t } from '@vegaprotocol/react-helpers';
|
import { t } from '@vegaprotocol/react-helpers';
|
||||||
import Link from 'next/link';
|
import { useState } from 'react';
|
||||||
|
|
||||||
export const DepositsContainer = () => {
|
export const DepositsContainer = () => {
|
||||||
const { deposits, loading, error } = useDeposits();
|
const { deposits, loading, error } = useDeposits();
|
||||||
|
const [depositDialog, setDepositDialog] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-full grid grid-rows-[min-content_1fr]">
|
<div className="h-full grid grid-rows-[1fr,min-content]">
|
||||||
<header className="flex justify-between items-center p-4">
|
|
||||||
<h4 className="text-lg text-black dark:text-white">{t('Deposits')}</h4>
|
|
||||||
<Link href="/portfolio/deposit" passHref={true}>
|
|
||||||
<Button>Deposit</Button>
|
|
||||||
</Link>
|
|
||||||
</header>
|
|
||||||
<div>
|
<div>
|
||||||
<AsyncRenderer
|
<AsyncRenderer
|
||||||
data={deposits}
|
data={deposits}
|
||||||
@ -25,6 +20,34 @@ export const DepositsContainer = () => {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<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>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export interface DepositDialogProps {
|
||||||
|
assetId?: string;
|
||||||
|
depositDialog: boolean;
|
||||||
|
setDepositDialog: (open: boolean) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const DepositDialog = ({
|
||||||
|
assetId,
|
||||||
|
depositDialog,
|
||||||
|
setDepositDialog,
|
||||||
|
}: DepositDialogProps) => {
|
||||||
|
return (
|
||||||
|
<Dialog open={depositDialog} onChange={setDepositDialog}>
|
||||||
|
<h1 className="text-2xl mb-4">{t('Deposit')}</h1>
|
||||||
|
<DepositContainer assetId={assetId} />
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
@ -17,19 +17,8 @@ export const WithdrawalsContainer = () => {
|
|||||||
return (
|
return (
|
||||||
<Web3Container>
|
<Web3Container>
|
||||||
<VegaWalletContainer>
|
<VegaWalletContainer>
|
||||||
<div className="h-full grid grid-rows-[min-content_1fr]">
|
<div className="h-full relative grid grid-rows-[1fr,min-content]">
|
||||||
<header className="flex justify-between items-center p-4">
|
<div className="h-full">
|
||||||
<h4 className="text-lg text-black dark:text-white">
|
|
||||||
{t('Withdrawals')}
|
|
||||||
</h4>
|
|
||||||
<Button
|
|
||||||
onClick={() => setWithdrawDialog(true)}
|
|
||||||
data-testid="withdraw-dialog-button"
|
|
||||||
>
|
|
||||||
{t('Make withdrawal')}
|
|
||||||
</Button>
|
|
||||||
</header>
|
|
||||||
<div className="h-full px-4">
|
|
||||||
<AsyncRenderer
|
<AsyncRenderer
|
||||||
data={{ pending, completed }}
|
data={{ pending, completed }}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
@ -42,13 +31,23 @@ export const WithdrawalsContainer = () => {
|
|||||||
<PendingWithdrawalsTable rowData={pending} />
|
<PendingWithdrawalsTable rowData={pending} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
{completed && completed.length > 0 && (
|
||||||
<h4 className="pt-3 pb-1">{t('Withdrawal history')}</h4>
|
<h4 className="pt-3 pb-1">{t('Withdrawal history')}</h4>
|
||||||
|
)}
|
||||||
<WithdrawalsTable rowData={completed} />
|
<WithdrawalsTable rowData={completed} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
<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={() => setWithdrawDialog(true)}
|
||||||
|
data-testid="withdraw-dialog-button"
|
||||||
|
>
|
||||||
|
{t('Make withdrawal')}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<WithdrawalDialogs
|
<WithdrawalDialogs
|
||||||
withdrawDialog={withdrawDialog}
|
withdrawDialog={withdrawDialog}
|
||||||
|
@ -32,7 +32,7 @@ export const AccountManager = ({
|
|||||||
},
|
},
|
||||||
[gridRef]
|
[gridRef]
|
||||||
);
|
);
|
||||||
const { data, error, loading } = useDataProvider<AccountFields[], never>({
|
const { data, loading, error } = useDataProvider<AccountFields[], never>({
|
||||||
dataProvider: aggregatedAccountsDataProvider,
|
dataProvider: aggregatedAccountsDataProvider,
|
||||||
update,
|
update,
|
||||||
variables,
|
variables,
|
||||||
@ -52,8 +52,7 @@ export const AccountManager = ({
|
|||||||
successCallback(rowsThisBlock, lastRow);
|
successCallback(rowsThisBlock, lastRow);
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<AsyncRenderer loading={loading} error={error} data={data}>
|
<AsyncRenderer data={data || []} error={error} loading={loading}>
|
||||||
{data && (
|
|
||||||
<AccountTable
|
<AccountTable
|
||||||
rowModelType={data?.length ? 'infinite' : 'clientSide'}
|
rowModelType={data?.length ? 'infinite' : 'clientSide'}
|
||||||
rowData={data?.length ? undefined : []}
|
rowData={data?.length ? undefined : []}
|
||||||
@ -63,7 +62,6 @@ export const AccountManager = ({
|
|||||||
onClickDeposit={onClickDeposit}
|
onClickDeposit={onClickDeposit}
|
||||||
onClickWithdraw={onClickWithdraw}
|
onClickWithdraw={onClickWithdraw}
|
||||||
/>
|
/>
|
||||||
)}
|
|
||||||
</AsyncRenderer>
|
</AsyncRenderer>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -57,7 +57,7 @@ describe('AccountsTable', () => {
|
|||||||
'tBTC',
|
'tBTC',
|
||||||
'1,256.00000',
|
'1,256.00000',
|
||||||
'1,256.00001,256.0000',
|
'1,256.00001,256.0000',
|
||||||
'Collateral breakdown',
|
'Breakdown',
|
||||||
'Deposit',
|
'Deposit',
|
||||||
];
|
];
|
||||||
cells.forEach((cell, i) => {
|
cells.forEach((cell, i) => {
|
||||||
|
@ -154,7 +154,7 @@ export const AccountTable = forwardRef<AgGridReact, AccountTableProps>(
|
|||||||
setBreakdown(value || null);
|
setBreakdown(value || null);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{t('Collateral breakdown')}
|
{t('Breakdown')}
|
||||||
</ButtonLink>
|
</ButtonLink>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
Loading…
Reference in New Issue
Block a user