fix(trading): volumes formatting (#3293)

This commit is contained in:
Art 2023-03-29 07:12:52 +02:00 committed by GitHub
parent d8aac83f2d
commit 6854980b32
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 14 deletions

View File

@ -39,7 +39,7 @@ describe('market info is displayed', { tags: '@smoke' }, () => {
it('market volume displayed', () => {
cy.getByTestId(marketTitle).contains('Market volume').click();
validateMarketDataRow(0, '24 Hour Volume', '1');
validateMarketDataRow(1, 'Open Interest', '0');
validateMarketDataRow(1, 'Open Interest', '-');
validateMarketDataRow(2, 'Best Bid Volume', '1');
validateMarketDataRow(3, 'Best Offer Volume', '3');
validateMarketDataRow(4, 'Best Static Bid Volume', '2');

View File

@ -106,7 +106,7 @@ export const MarketInfoTable = ({
decimalPlaces={decimalPlaces}
assetSymbol={assetSymbol}
asPercentage={asPercentage}
unformatted={unformatted || key.toLowerCase().includes('volume')}
unformatted={unformatted}
noBorder={noBorder}
/>
))}

View File

@ -96,21 +96,19 @@ export const MarketVolumeInfoPanel = ({
...props
}: MarketInfoWithDataAndCandlesProps & PanelProps) => {
const last24hourVolume = market.candles && calcCandleVolume(market.candles);
const dash = (value: string | undefined) =>
value && value !== '0' ? value : '-';
return (
<MarketInfoTable
data={{
'24hourVolume':
last24hourVolume && last24hourVolume !== '0'
? addDecimalsFormatNumber(
last24hourVolume,
market.positionDecimalPlaces
)
: '-',
openInterest: market.data?.openInterest,
bestBidVolume: market.data?.bestBidVolume,
bestOfferVolume: market.data?.bestOfferVolume,
bestStaticBidVolume: market.data?.bestStaticBidVolume,
bestStaticOfferVolume: market.data?.bestStaticOfferVolume,
'24hourVolume': dash(last24hourVolume),
openInterest: dash(market.data?.openInterest),
bestBidVolume: dash(market.data?.bestBidVolume),
bestOfferVolume: dash(market.data?.bestOfferVolume),
bestStaticBidVolume: dash(market.data?.bestStaticBidVolume),
bestStaticOfferVolume: dash(market.data?.bestStaticOfferVolume),
}}
decimalPlaces={market.positionDecimalPlaces}
{...props}