fix: format market list
This commit is contained in:
parent
0ddbcbd125
commit
087e2fed03
@ -11,7 +11,11 @@ import { TradesContainer } from '@vegaprotocol/trades';
|
|||||||
import { PositionsContainer } from '@vegaprotocol/positions';
|
import { PositionsContainer } from '@vegaprotocol/positions';
|
||||||
import { OrderbookContainer } from '@vegaprotocol/market-depth';
|
import { OrderbookContainer } from '@vegaprotocol/market-depth';
|
||||||
import type { Market_market } from './__generated__/Market';
|
import type { Market_market } from './__generated__/Market';
|
||||||
import { addDecimalsFormatNumber, t } from '@vegaprotocol/react-helpers';
|
import {
|
||||||
|
addDecimalsFormatNumber,
|
||||||
|
formatLabel,
|
||||||
|
t,
|
||||||
|
} from '@vegaprotocol/react-helpers';
|
||||||
import { AccountsContainer } from '@vegaprotocol/accounts';
|
import { AccountsContainer } from '@vegaprotocol/accounts';
|
||||||
import { DepthChartContainer } from '@vegaprotocol/market-depth';
|
import { DepthChartContainer } from '@vegaprotocol/market-depth';
|
||||||
import { CandlesChartContainer } from '@vegaprotocol/candles-chart';
|
import { CandlesChartContainer } from '@vegaprotocol/candles-chart';
|
||||||
@ -25,8 +29,6 @@ import {
|
|||||||
import type { CandleClose } from '@vegaprotocol/types';
|
import type { CandleClose } from '@vegaprotocol/types';
|
||||||
import { AuctionTrigger } from '@vegaprotocol/types';
|
import { AuctionTrigger } from '@vegaprotocol/types';
|
||||||
import { MarketTradingMode } from '@vegaprotocol/types';
|
import { MarketTradingMode } from '@vegaprotocol/types';
|
||||||
import capitalize from 'lodash/capitalize';
|
|
||||||
import startCase from 'lodash/startCase';
|
|
||||||
|
|
||||||
const TradingViews = {
|
const TradingViews = {
|
||||||
Candles: CandlesChartContainer,
|
Candles: CandlesChartContainer,
|
||||||
@ -47,8 +49,6 @@ interface TradeMarketHeaderProps {
|
|||||||
className?: string;
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatLabel = (str: string) => capitalize(startCase(str).toLowerCase());
|
|
||||||
|
|
||||||
export const TradeMarketHeader = ({
|
export const TradeMarketHeader = ({
|
||||||
market,
|
market,
|
||||||
className,
|
className,
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// @generated
|
// @generated
|
||||||
// This file was automatically generated and should not be edited.
|
// This file was automatically generated and should not be edited.
|
||||||
|
|
||||||
import { MarketState, MarketTradingMode } from "@vegaprotocol/types";
|
import { MarketState, MarketTradingMode, AuctionTrigger } from "@vegaprotocol/types";
|
||||||
|
|
||||||
// ====================================================
|
// ====================================================
|
||||||
// GraphQL fragment: MarketDataFields
|
// GraphQL fragment: MarketDataFields
|
||||||
@ -43,4 +43,8 @@ export interface MarketDataFields {
|
|||||||
* the mark price (actually an unsigned int)
|
* the mark price (actually an unsigned int)
|
||||||
*/
|
*/
|
||||||
markPrice: string;
|
markPrice: string;
|
||||||
|
/**
|
||||||
|
* what triggered an auction (if an auction was started)
|
||||||
|
*/
|
||||||
|
trigger: AuctionTrigger;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// @generated
|
// @generated
|
||||||
// This file was automatically generated and should not be edited.
|
// This file was automatically generated and should not be edited.
|
||||||
|
|
||||||
import { MarketState, MarketTradingMode } from "@vegaprotocol/types";
|
import { MarketState, MarketTradingMode, AuctionTrigger } from "@vegaprotocol/types";
|
||||||
|
|
||||||
// ====================================================
|
// ====================================================
|
||||||
// GraphQL subscription operation: MarketDataSub
|
// GraphQL subscription operation: MarketDataSub
|
||||||
@ -43,6 +43,10 @@ export interface MarketDataSub_marketData {
|
|||||||
* the mark price (actually an unsigned int)
|
* the mark price (actually an unsigned int)
|
||||||
*/
|
*/
|
||||||
markPrice: string;
|
markPrice: string;
|
||||||
|
/**
|
||||||
|
* what triggered an auction (if an auction was started)
|
||||||
|
*/
|
||||||
|
trigger: AuctionTrigger;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface MarketDataSub {
|
export interface MarketDataSub {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
// @generated
|
// @generated
|
||||||
// This file was automatically generated and should not be edited.
|
// This file was automatically generated and should not be edited.
|
||||||
|
|
||||||
import { MarketState, MarketTradingMode } from "@vegaprotocol/types";
|
import { MarketState, MarketTradingMode, AuctionTrigger } from "@vegaprotocol/types";
|
||||||
|
|
||||||
// ====================================================
|
// ====================================================
|
||||||
// GraphQL query operation: Markets
|
// GraphQL query operation: Markets
|
||||||
@ -43,6 +43,10 @@ export interface Markets_markets_data {
|
|||||||
* the mark price (actually an unsigned int)
|
* the mark price (actually an unsigned int)
|
||||||
*/
|
*/
|
||||||
markPrice: string;
|
markPrice: string;
|
||||||
|
/**
|
||||||
|
* what triggered an auction (if an auction was started)
|
||||||
|
*/
|
||||||
|
trigger: AuctionTrigger;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Markets_markets_tradableInstrument_instrument_product_settlementAsset {
|
export interface Markets_markets_tradableInstrument_instrument_product_settlementAsset {
|
||||||
|
@ -4,11 +4,13 @@ import {
|
|||||||
PriceFlashCell,
|
PriceFlashCell,
|
||||||
addDecimalsFormatNumber,
|
addDecimalsFormatNumber,
|
||||||
t,
|
t,
|
||||||
|
formatLabel,
|
||||||
} from '@vegaprotocol/react-helpers';
|
} from '@vegaprotocol/react-helpers';
|
||||||
import { AgGridDynamic as AgGrid } from '@vegaprotocol/ui-toolkit';
|
import { AgGridDynamic as AgGrid } from '@vegaprotocol/ui-toolkit';
|
||||||
import { AgGridColumn } from 'ag-grid-react';
|
import { AgGridColumn } from 'ag-grid-react';
|
||||||
import type { AgGridReact } from 'ag-grid-react';
|
import type { AgGridReact } from 'ag-grid-react';
|
||||||
import type { Markets_markets } from '../__generated__/Markets';
|
import type { Markets_markets } from '../__generated__/Markets';
|
||||||
|
import { MarketTradingMode, AuctionTrigger } from '@vegaprotocol/types';
|
||||||
|
|
||||||
interface MarketListTableProps {
|
interface MarketListTableProps {
|
||||||
datasource: IDatasource;
|
datasource: IDatasource;
|
||||||
@ -44,13 +46,19 @@ export const MarketListTable = forwardRef<AgGridReact, MarketListTableProps>(
|
|||||||
field="tradableInstrument.instrument.product.settlementAsset.symbol"
|
field="tradableInstrument.instrument.product.settlementAsset.symbol"
|
||||||
/>
|
/>
|
||||||
<AgGridColumn
|
<AgGridColumn
|
||||||
headerName={t('State')}
|
headerName={t('Trading mode')}
|
||||||
field="data"
|
field="data"
|
||||||
valueFormatter={({ value }: ValueFormatterParams) =>
|
minWidth={200}
|
||||||
value === undefined
|
valueFormatter={({ value }: ValueFormatterParams) => {
|
||||||
? value
|
if (!value) return value;
|
||||||
: `${value.market.state} (${value.market.tradingMode})`
|
const { market, trigger } = value;
|
||||||
}
|
return market &&
|
||||||
|
market.tradingMode === MarketTradingMode.MonitoringAuction &&
|
||||||
|
trigger &&
|
||||||
|
trigger !== AuctionTrigger.Unspecified
|
||||||
|
? `${formatLabel(market.tradingMode)} - ${trigger.toLowerCase()}`
|
||||||
|
: formatLabel(market?.tradingMode);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<AgGridColumn
|
<AgGridColumn
|
||||||
headerName={t('Best bid')}
|
headerName={t('Best bid')}
|
||||||
|
@ -21,6 +21,7 @@ const MARKET_DATA_FRAGMENT = gql`
|
|||||||
bestBidPrice
|
bestBidPrice
|
||||||
bestOfferPrice
|
bestOfferPrice
|
||||||
markPrice
|
markPrice
|
||||||
|
trigger
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
|
import capitalize from 'lodash/capitalize';
|
||||||
|
import startCase from 'lodash/startCase';
|
||||||
|
|
||||||
export const getUserLocale = () => 'default';
|
export const getUserLocale = () => 'default';
|
||||||
|
|
||||||
export const splitAt = (index: number) => (x: string) =>
|
export const splitAt = (index: number) => (x: string) =>
|
||||||
[x.slice(0, index), x.slice(index)];
|
[x.slice(0, index), x.slice(index)];
|
||||||
|
|
||||||
|
export const formatLabel = (str: string) =>
|
||||||
|
capitalize(startCase(str).toLowerCase());
|
||||||
|
Loading…
Reference in New Issue
Block a user