vega-frontend-monorepo/apps/trading/pages/portfolio/deposits-container.tsx
m.ray 7c5bfc4471
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>
2022-10-12 11:49:13 +01:00

54 lines
1.5 KiB
TypeScript

import { AsyncRenderer, Button, Dialog } from '@vegaprotocol/ui-toolkit';
import { DepositContainer, DepositsTable } from '@vegaprotocol/deposits';
import { useDeposits } from '@vegaprotocol/deposits';
import { t } from '@vegaprotocol/react-helpers';
import { useState } from 'react';
export const DepositsContainer = () => {
const { deposits, loading, error } = useDeposits();
const [depositDialog, setDepositDialog] = useState(false);
return (
<div className="h-full grid grid-rows-[1fr,min-content]">
<div>
<AsyncRenderer
data={deposits}
loading={loading}
error={error}
render={(data) => {
return <DepositsTable deposits={data} />;
}}
/>
</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>
);
};
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>
);
};