fix(#1134): pass correct price and volume formatters to depth chart (#1135)

This commit is contained in:
John Walley 2022-08-24 18:23:05 +01:00 committed by GitHub
parent 50da2a9d3c
commit d6b362805e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,8 +4,8 @@ import { AsyncRenderer } from '@vegaprotocol/ui-toolkit';
import {
useDataProvider,
addDecimal,
addDecimalsFormatNumber,
ThemeContext,
getNumberFormat,
} from '@vegaprotocol/react-helpers';
import dataProvider from './market-depth-data-provider';
import {
@ -175,18 +175,25 @@ export const DepthChartContainer = ({ marketId }: DepthChartManagerProps) => {
setPositionDecimalPlaces(data.positionDecimalPlaces);
}, [data]);
const volumeFormat = useCallback(
(volume: number) =>
getNumberFormat(data?.positionDecimalPlaces || 0).format(volume),
[data?.positionDecimalPlaces]
);
const priceFormat = useCallback(
(price: number) => getNumberFormat(data?.decimalPlaces || 0).format(price),
[data?.decimalPlaces]
);
return (
<AsyncRenderer loading={loading} error={error} data={data}>
{depthData && (
<DepthChart
{...depthData}
theme={theme}
volumeFormat={(volume) =>
addDecimalsFormatNumber(volume, data?.positionDecimalPlaces || 0)
}
priceFormat={(price) =>
addDecimalsFormatNumber(price, data?.decimalPlaces || 0)
}
volumeFormat={volumeFormat}
priceFormat={priceFormat}
/>
)}
</AsyncRenderer>