2023-06-27 00:10:22 +00:00
|
|
|
import type { ComponentProps } from 'react';
|
|
|
|
import { Splash } from '@vegaprotocol/ui-toolkit';
|
2023-05-16 16:57:36 +00:00
|
|
|
import { TradesContainer } from '@vegaprotocol/trades';
|
|
|
|
import { DepthChartContainer } from '@vegaprotocol/market-depth';
|
|
|
|
import { CandlesChartContainer } from '@vegaprotocol/candles-chart';
|
2023-06-27 00:10:22 +00:00
|
|
|
import { Filter } from '@vegaprotocol/orders';
|
2023-05-16 16:57:36 +00:00
|
|
|
import { NO_MARKET } from './constants';
|
2023-07-24 08:37:18 +00:00
|
|
|
import { OrderbookContainer } from '../../components/orderbook-container';
|
2023-06-27 00:10:22 +00:00
|
|
|
import { FillsContainer } from '../../components/fills-container';
|
|
|
|
import { PositionsContainer } from '../../components/positions-container';
|
|
|
|
import { AccountsContainer } from '../../components/accounts-container';
|
|
|
|
import { LiquidityContainer } from '../../components/liquidity-container';
|
|
|
|
import type { OrderContainerProps } from '../../components/orders-container';
|
|
|
|
import { OrdersContainer } from '../../components/orders-container';
|
2023-05-16 16:57:36 +00:00
|
|
|
|
|
|
|
type MarketDependantView =
|
|
|
|
| typeof CandlesChartContainer
|
|
|
|
| typeof DepthChartContainer
|
|
|
|
| typeof OrderbookContainer
|
|
|
|
| typeof TradesContainer;
|
|
|
|
|
|
|
|
type MarketDependantViewProps = ComponentProps<MarketDependantView>;
|
|
|
|
|
|
|
|
const requiresMarket = (View: MarketDependantView) => {
|
|
|
|
const WrappedComponent = (props: MarketDependantViewProps) =>
|
|
|
|
props.marketId ? <View {...props} /> : <Splash>{NO_MARKET}</Splash>;
|
|
|
|
WrappedComponent.displayName = `RequiresMarket(${View.name})`;
|
|
|
|
return WrappedComponent;
|
|
|
|
};
|
|
|
|
|
|
|
|
export type TradingView = keyof typeof TradingViews;
|
|
|
|
|
|
|
|
export const TradingViews = {
|
|
|
|
candles: {
|
|
|
|
label: 'Candles',
|
|
|
|
component: requiresMarket(CandlesChartContainer),
|
|
|
|
},
|
|
|
|
depth: {
|
|
|
|
label: 'Depth',
|
|
|
|
component: requiresMarket(DepthChartContainer),
|
|
|
|
},
|
|
|
|
liquidity: {
|
|
|
|
label: 'Liquidity',
|
|
|
|
component: requiresMarket(LiquidityContainer),
|
|
|
|
},
|
|
|
|
orderbook: {
|
|
|
|
label: 'Orderbook',
|
|
|
|
component: requiresMarket(OrderbookContainer),
|
|
|
|
},
|
|
|
|
trades: {
|
|
|
|
label: 'Trades',
|
|
|
|
component: requiresMarket(TradesContainer),
|
|
|
|
},
|
|
|
|
positions: { label: 'Positions', component: PositionsContainer },
|
|
|
|
activeOrders: {
|
|
|
|
label: 'Active',
|
2023-06-27 00:10:22 +00:00
|
|
|
component: (props: OrderContainerProps) => (
|
|
|
|
<OrdersContainer {...props} filter={Filter.Open} />
|
2023-05-16 16:57:36 +00:00
|
|
|
),
|
|
|
|
},
|
|
|
|
closedOrders: {
|
|
|
|
label: 'Closed',
|
2023-06-27 00:10:22 +00:00
|
|
|
component: (props: OrderContainerProps) => (
|
|
|
|
<OrdersContainer {...props} filter={Filter.Closed} />
|
2023-05-16 16:57:36 +00:00
|
|
|
),
|
|
|
|
},
|
|
|
|
rejectedOrders: {
|
|
|
|
label: 'Rejected',
|
2023-06-27 00:10:22 +00:00
|
|
|
component: (props: OrderContainerProps) => (
|
|
|
|
<OrdersContainer {...props} filter={Filter.Rejected} />
|
2023-05-16 16:57:36 +00:00
|
|
|
),
|
|
|
|
},
|
|
|
|
orders: {
|
|
|
|
label: 'All',
|
2023-06-27 00:10:22 +00:00
|
|
|
component: OrdersContainer,
|
2023-05-16 16:57:36 +00:00
|
|
|
},
|
|
|
|
collateral: { label: 'Collateral', component: AccountsContainer },
|
|
|
|
fills: { label: 'Fills', component: FillsContainer },
|
|
|
|
};
|