2022-10-12 10:49:13 +00:00
|
|
|
import { AsyncRenderer, Button, Dialog } from '@vegaprotocol/ui-toolkit';
|
|
|
|
import { DepositContainer, DepositsTable } from '@vegaprotocol/deposits';
|
2022-09-06 01:30:13 +00:00
|
|
|
import { useDeposits } from '@vegaprotocol/deposits';
|
2022-07-14 16:12:28 +00:00
|
|
|
import { t } from '@vegaprotocol/react-helpers';
|
2022-10-12 10:49:13 +00:00
|
|
|
import { useState } from 'react';
|
2022-07-14 16:12:28 +00:00
|
|
|
|
|
|
|
export const DepositsContainer = () => {
|
2022-09-06 01:30:13 +00:00
|
|
|
const { deposits, loading, error } = useDeposits();
|
2022-10-12 10:49:13 +00:00
|
|
|
const [depositDialog, setDepositDialog] = useState(false);
|
2022-09-06 01:30:13 +00:00
|
|
|
|
2022-07-14 16:12:28 +00:00
|
|
|
return (
|
2022-10-12 10:49:13 +00:00
|
|
|
<div className="h-full grid grid-rows-[1fr,min-content]">
|
2022-09-06 01:30:13 +00:00
|
|
|
<div>
|
|
|
|
<AsyncRenderer
|
|
|
|
data={deposits}
|
|
|
|
loading={loading}
|
|
|
|
error={error}
|
|
|
|
render={(data) => {
|
|
|
|
return <DepositsTable deposits={data} />;
|
|
|
|
}}
|
|
|
|
/>
|
2022-07-14 16:12:28 +00:00
|
|
|
</div>
|
2022-10-12 10:49:13 +00:00
|
|
|
<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>
|
2022-07-14 16:12:28 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
2022-10-12 10:49:13 +00:00
|
|
|
|
|
|
|
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>
|
|
|
|
);
|
|
|
|
};
|