2022-09-23 14:29:35 +00:00
|
|
|
import { t, titlefy } from '@vegaprotocol/react-helpers';
|
2022-06-07 09:26:45 +00:00
|
|
|
import { PositionsContainer } from '@vegaprotocol/positions';
|
2022-07-13 14:23:46 +00:00
|
|
|
import { OrderListContainer } from '@vegaprotocol/orders';
|
2022-08-31 04:35:46 +00:00
|
|
|
import { ResizableGridPanel, Tab, Tabs } from '@vegaprotocol/ui-toolkit';
|
2022-07-14 16:12:28 +00:00
|
|
|
import { WithdrawalsContainer } from './withdrawals-container';
|
2022-06-30 07:52:25 +00:00
|
|
|
import { FillsContainer } from '@vegaprotocol/fills';
|
|
|
|
import type { ReactNode } from 'react';
|
2022-09-23 14:29:35 +00:00
|
|
|
import { useEffect } from 'react';
|
2022-07-14 16:12:28 +00:00
|
|
|
import { VegaWalletContainer } from '../../components/vega-wallet-container';
|
|
|
|
import { DepositsContainer } from './deposits-container';
|
2022-08-31 04:35:46 +00:00
|
|
|
import { ResizableGrid } from '@vegaprotocol/ui-toolkit';
|
|
|
|
import { LayoutPriority } from 'allotment';
|
2022-10-14 15:42:53 +00:00
|
|
|
import { usePageTitleStore } from '../../stores';
|
2022-11-04 10:47:39 +00:00
|
|
|
import { LedgerContainer } from '@vegaprotocol/ledger';
|
2022-11-08 07:23:38 +00:00
|
|
|
import { AccountsContainer } from '../../components/accounts-container';
|
2022-12-20 11:22:35 +00:00
|
|
|
import { AccountHistoryContainer } from './account-history-container';
|
2023-01-19 21:53:10 +00:00
|
|
|
import { useNavigate } from 'react-router-dom';
|
|
|
|
import { Links, Routes } from '../../pages/client-router';
|
2022-06-07 09:26:45 +00:00
|
|
|
|
2022-11-08 07:23:38 +00:00
|
|
|
export const Portfolio = () => {
|
2022-10-14 15:42:53 +00:00
|
|
|
const { updateTitle } = usePageTitleStore((store) => ({
|
|
|
|
updateTitle: store.updateTitle,
|
2022-09-23 14:29:35 +00:00
|
|
|
}));
|
2022-11-08 07:23:38 +00:00
|
|
|
|
2023-01-19 21:53:10 +00:00
|
|
|
const navigate = useNavigate();
|
|
|
|
|
2022-09-23 14:29:35 +00:00
|
|
|
useEffect(() => {
|
2022-10-14 15:42:53 +00:00
|
|
|
updateTitle(titlefy([t('Portfolio')]));
|
|
|
|
}, [updateTitle]);
|
2022-11-08 07:23:38 +00:00
|
|
|
|
2023-01-19 21:53:10 +00:00
|
|
|
const onMarketClick = (marketId: string) => {
|
|
|
|
navigate(Links[Routes.MARKET](marketId), {
|
|
|
|
replace: true,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2022-08-31 04:35:46 +00:00
|
|
|
const wrapperClasses = 'h-full max-h-full flex flex-col';
|
2022-02-17 05:03:46 +00:00
|
|
|
return (
|
2022-06-30 07:52:25 +00:00
|
|
|
<div className={wrapperClasses}>
|
2022-11-07 12:14:21 +00:00
|
|
|
<ResizableGrid vertical>
|
2022-08-31 04:35:46 +00:00
|
|
|
<ResizableGridPanel minSize={75}>
|
|
|
|
<PortfolioGridChild>
|
2022-08-05 13:24:46 +00:00
|
|
|
<Tabs>
|
2022-12-20 11:22:35 +00:00
|
|
|
<Tab id="account-history" name={t('Account history')}>
|
|
|
|
<VegaWalletContainer>
|
|
|
|
<AccountHistoryContainer />
|
|
|
|
</VegaWalletContainer>
|
|
|
|
</Tab>
|
2022-08-05 13:24:46 +00:00
|
|
|
<Tab id="positions" name={t('Positions')}>
|
|
|
|
<VegaWalletContainer>
|
2023-01-19 21:53:10 +00:00
|
|
|
<PositionsContainer onMarketClick={onMarketClick} />
|
2022-08-05 13:24:46 +00:00
|
|
|
</VegaWalletContainer>
|
|
|
|
</Tab>
|
|
|
|
<Tab id="orders" name={t('Orders')}>
|
|
|
|
<VegaWalletContainer>
|
2023-01-19 21:53:10 +00:00
|
|
|
<OrderListContainer onMarketClick={onMarketClick} />
|
2022-08-05 13:24:46 +00:00
|
|
|
</VegaWalletContainer>
|
|
|
|
</Tab>
|
|
|
|
<Tab id="fills" name={t('Fills')}>
|
|
|
|
<VegaWalletContainer>
|
2023-01-19 21:53:10 +00:00
|
|
|
<FillsContainer onMarketClick={onMarketClick} />
|
2022-08-05 13:24:46 +00:00
|
|
|
</VegaWalletContainer>
|
|
|
|
</Tab>
|
2022-11-04 10:47:39 +00:00
|
|
|
<Tab id="ledger-entries" name={t('Ledger entries')}>
|
|
|
|
<VegaWalletContainer>
|
|
|
|
<LedgerContainer />
|
|
|
|
</VegaWalletContainer>
|
|
|
|
</Tab>
|
2022-08-05 13:24:46 +00:00
|
|
|
</Tabs>
|
|
|
|
</PortfolioGridChild>
|
2022-08-31 04:35:46 +00:00
|
|
|
</ResizableGridPanel>
|
|
|
|
<ResizableGridPanel
|
2022-08-05 13:24:46 +00:00
|
|
|
priority={LayoutPriority.Low}
|
|
|
|
preferredSize={300}
|
|
|
|
minSize={50}
|
|
|
|
>
|
2022-08-31 04:35:46 +00:00
|
|
|
<PortfolioGridChild>
|
2022-08-05 13:24:46 +00:00
|
|
|
<Tabs>
|
|
|
|
<Tab id="collateral" name={t('Collateral')}>
|
|
|
|
<VegaWalletContainer>
|
|
|
|
<AccountsContainer />
|
|
|
|
</VegaWalletContainer>
|
|
|
|
</Tab>
|
|
|
|
<Tab id="deposits" name={t('Deposits')}>
|
2022-09-06 01:30:13 +00:00
|
|
|
<VegaWalletContainer>
|
|
|
|
<DepositsContainer />
|
|
|
|
</VegaWalletContainer>
|
2022-08-05 13:24:46 +00:00
|
|
|
</Tab>
|
|
|
|
<Tab id="withdrawals" name={t('Withdrawals')}>
|
2022-09-06 01:30:13 +00:00
|
|
|
<WithdrawalsContainer />
|
2022-08-05 13:24:46 +00:00
|
|
|
</Tab>
|
|
|
|
</Tabs>
|
|
|
|
</PortfolioGridChild>
|
2022-08-31 04:35:46 +00:00
|
|
|
</ResizableGridPanel>
|
|
|
|
</ResizableGrid>
|
2022-06-30 07:52:25 +00:00
|
|
|
</div>
|
2022-02-17 05:03:46 +00:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-06-30 07:52:25 +00:00
|
|
|
interface PortfolioGridChildProps {
|
|
|
|
children: ReactNode;
|
|
|
|
}
|
|
|
|
|
2022-08-31 04:35:46 +00:00
|
|
|
const PortfolioGridChild = ({ children }: PortfolioGridChildProps) => {
|
|
|
|
return (
|
|
|
|
<section className="bg-white dark:bg-black w-full h-full">
|
|
|
|
{children}
|
|
|
|
</section>
|
|
|
|
);
|
2022-06-30 07:52:25 +00:00
|
|
|
};
|