2022-11-04 10:47:53 +00:00
|
|
|
import { AsyncRenderer, Button } from '@vegaprotocol/ui-toolkit';
|
2022-11-16 14:10:17 +00:00
|
|
|
import { useDepositDialog, DepositsTable } from '@vegaprotocol/deposits';
|
2023-01-28 02:35:45 +00:00
|
|
|
import { depositsProvider } from '@vegaprotocol/deposits';
|
2023-02-28 18:56:29 +00:00
|
|
|
import { t } from '@vegaprotocol/i18n';
|
|
|
|
import { useDataProvider } from '@vegaprotocol/react-helpers';
|
2023-01-28 02:35:45 +00:00
|
|
|
import { useVegaWallet } from '@vegaprotocol/wallet';
|
2022-07-14 16:12:28 +00:00
|
|
|
|
|
|
|
export const DepositsContainer = () => {
|
2023-01-31 16:04:52 +00:00
|
|
|
const { pubKey, isReadOnly } = useVegaWallet();
|
2023-02-16 16:30:32 +00:00
|
|
|
const { data, loading, error, reload } = useDataProvider({
|
2023-01-28 02:35:45 +00:00
|
|
|
dataProvider: depositsProvider,
|
|
|
|
variables: { partyId: pubKey || '' },
|
|
|
|
skip: !pubKey,
|
|
|
|
});
|
2022-11-16 14:10:17 +00:00
|
|
|
const openDepositDialog = useDepositDialog((state) => state.open);
|
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]">
|
2023-01-17 15:01:24 +00:00
|
|
|
<div className="h-full relative">
|
|
|
|
<DepositsTable
|
2023-01-28 02:35:45 +00:00
|
|
|
rowData={data || []}
|
2023-01-17 15:01:24 +00:00
|
|
|
noRowsOverlayComponent={() => null}
|
2022-09-06 01:30:13 +00:00
|
|
|
/>
|
2023-01-17 15:01:24 +00:00
|
|
|
<div className="pointer-events-none absolute inset-0">
|
|
|
|
<AsyncRenderer
|
2023-01-28 02:35:45 +00:00
|
|
|
data={data}
|
2023-01-17 15:01:24 +00:00
|
|
|
loading={loading}
|
|
|
|
error={error}
|
|
|
|
noDataCondition={(data) => !(data && data.length)}
|
|
|
|
noDataMessage={t('No deposits')}
|
2023-02-16 16:30:32 +00:00
|
|
|
reload={reload}
|
2023-01-17 15:01:24 +00:00
|
|
|
/>
|
|
|
|
</div>
|
2022-07-14 16:12:28 +00:00
|
|
|
</div>
|
2023-01-31 16:04:52 +00:00
|
|
|
{!isReadOnly && (
|
|
|
|
<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={() => openDepositDialog()}
|
|
|
|
data-testid="deposit-button"
|
|
|
|
>
|
|
|
|
{t('Deposit')}
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
)}
|
2022-07-14 16:12:28 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|