2023-02-28 18:56:29 +00:00
|
|
|
import { titlefy } from '@vegaprotocol/utils';
|
|
|
|
import { t } from '@vegaprotocol/i18n';
|
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';
|
2023-04-21 15:16:04 +00:00
|
|
|
import { Tab, LocalStoragePersistTabs as 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';
|
2023-05-03 08:44:45 +00:00
|
|
|
import { usePaneLayout } from '@vegaprotocol/react-helpers';
|
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 { 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-04-18 12:55:11 +00:00
|
|
|
import {
|
|
|
|
useMarketClickHandler,
|
|
|
|
useMarketLiquidityClickHandler,
|
|
|
|
} from '../../lib/hooks/use-market-click-handler';
|
2023-04-21 15:16:04 +00:00
|
|
|
import {
|
|
|
|
ResizableGrid,
|
|
|
|
ResizableGridPanel,
|
|
|
|
} from '../../components/resizable-grid';
|
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
|
|
|
|
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-03-31 13:23:44 +00:00
|
|
|
const onMarketClick = useMarketClickHandler(true);
|
2023-06-21 11:23:07 +00:00
|
|
|
const onOrderTypeClick = useMarketLiquidityClickHandler();
|
2023-05-03 08:44:45 +00:00
|
|
|
const [sizes, handleOnLayoutChange] = usePaneLayout({ id: 'portfolio' });
|
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}>
|
2023-05-03 08:44:45 +00:00
|
|
|
<ResizableGrid vertical onChange={handleOnLayoutChange}>
|
2022-08-31 04:35:46 +00:00
|
|
|
<ResizableGridPanel minSize={75}>
|
|
|
|
<PortfolioGridChild>
|
2023-03-22 23:34:58 +00:00
|
|
|
<Tabs storageKey="console-portfolio-top">
|
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-03-09 23:52:38 +00:00
|
|
|
<PositionsContainer
|
|
|
|
onMarketClick={onMarketClick}
|
|
|
|
noBottomPlaceholder
|
2023-05-09 06:09:53 +00:00
|
|
|
storeKey="portfolioPositions"
|
2023-05-25 10:59:08 +00:00
|
|
|
allKeys
|
2023-03-09 23:52:38 +00:00
|
|
|
/>
|
2022-08-05 13:24:46 +00:00
|
|
|
</VegaWalletContainer>
|
|
|
|
</Tab>
|
|
|
|
<Tab id="orders" name={t('Orders')}>
|
|
|
|
<VegaWalletContainer>
|
2023-04-18 12:55:11 +00:00
|
|
|
<OrderListContainer
|
|
|
|
onMarketClick={onMarketClick}
|
|
|
|
onOrderTypeClick={onOrderTypeClick}
|
2023-05-09 06:09:53 +00:00
|
|
|
storeKey="portfolioOrders"
|
2023-04-18 12:55:11 +00:00
|
|
|
/>
|
2022-08-05 13:24:46 +00:00
|
|
|
</VegaWalletContainer>
|
|
|
|
</Tab>
|
|
|
|
<Tab id="fills" name={t('Fills')}>
|
|
|
|
<VegaWalletContainer>
|
2023-05-09 06:09:53 +00:00
|
|
|
<FillsContainer
|
|
|
|
onMarketClick={onMarketClick}
|
|
|
|
storeKey="portfolioFills"
|
|
|
|
/>
|
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}
|
2023-05-03 08:44:45 +00:00
|
|
|
preferredSize={sizes[1] || 300}
|
2022-08-05 13:24:46 +00:00
|
|
|
minSize={50}
|
|
|
|
>
|
2022-08-31 04:35:46 +00:00
|
|
|
<PortfolioGridChild>
|
2023-03-22 23:34:58 +00:00
|
|
|
<Tabs storageKey="console-portfolio-bottom">
|
2022-08-05 13:24:46 +00:00
|
|
|
<Tab id="collateral" name={t('Collateral')}>
|
|
|
|
<VegaWalletContainer>
|
2023-06-16 10:28:59 +00:00
|
|
|
<AccountsContainer
|
|
|
|
storeKey="portfolioCollateral"
|
|
|
|
onMarketClick={onMarketClick}
|
|
|
|
/>
|
2022-08-05 13:24:46 +00:00
|
|
|
</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
|
|
|
};
|