vega-frontend-monorepo/apps/trading/pages/portfolio/withdrawals-container.tsx
Art 48ce7978ee
feat: updated withdrawal tab (849) (#1579)
* feat: updated withdrawal tab (849)

* added pending table to the token app, added pending completed filtering to the data provider

* amended and added unit tests

* amended time formats

* added units

* fixes errors

* addressed comments
2022-10-06 17:40:34 +02:00

61 lines
2.0 KiB
TypeScript

import { AsyncRenderer, Button } from '@vegaprotocol/ui-toolkit';
import {
PendingWithdrawalsTable,
useWithdrawals,
WithdrawalDialogs,
WithdrawalsTable,
} from '@vegaprotocol/withdraws';
import { t } from '@vegaprotocol/react-helpers';
import { useState } from 'react';
import { VegaWalletContainer } from '../../components/vega-wallet-container';
import { Web3Container } from '@vegaprotocol/web3';
export const WithdrawalsContainer = () => {
const { pending, completed, loading, error } = useWithdrawals();
const [withdrawDialog, setWithdrawDialog] = useState(false);
return (
<Web3Container>
<VegaWalletContainer>
<div className="h-full grid grid-rows-[min-content_1fr]">
<header className="flex justify-between items-center p-4">
<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
data={{ pending, completed }}
loading={loading}
error={error}
render={({ pending, completed }) => (
<>
{pending && pending.length > 0 && (
<>
<h4 className="pt-3 pb-1">{t('Pending withdrawals')}</h4>
<PendingWithdrawalsTable rowData={pending} />
</>
)}
<h4 className="pt-3 pb-1">{t('Withdrawal history')}</h4>
<WithdrawalsTable rowData={completed} />
</>
)}
/>
</div>
</div>
<WithdrawalDialogs
withdrawDialog={withdrawDialog}
setWithdrawDialog={setWithdrawDialog}
/>
</VegaWalletContainer>
</Web3Container>
);
};