fix: parse equitylikeshare as a float not an int value (#2048)

* fix: parse equitylikeshare as a float not an int value

We were incorrectly parsing equityLikeShare as an integer, which was
causing any value from the API not '1' to be incorrectly rounded to '0'.

This commit parses it as a float trimmed to 2 decimal places and then
converts that to a percentage value. We can increase precision in future
if necessary.

* feat: open details view in current tab

Clicking on the details view of the table currently opens each market in
a new tab. This is pretty noisy - you very quickly end up with a load
of open markets. There's a back navigation button and browser navigation
/history works fine as well - so we don't need to be using tabs here.
This commit is contained in:
Ciaran McGhie
2022-11-14 14:44:53 +00:00
committed by GitHub
parent 458ace802f
commit b583af005b
2 changed files with 6 additions and 7 deletions
@@ -1,4 +1,5 @@
import { useCallback, useState } from 'react';
import { useNavigate } from 'react-router-dom';
import { AgGridColumn } from 'ag-grid-react';
import type {
ValueFormatterParams,
@@ -25,6 +26,7 @@ import { Status } from '../../status';
export const MarketList = () => {
const { data, error, loading } = useMarketsLiquidity();
const [isHealthDialogOpen, setIsHealthDialogOpen] = useState(false);
const navigate = useNavigate();
const getRowId = useCallback(({ data }: GetRowIdParams) => data.id, []);
@@ -39,11 +41,7 @@ export const MarketList = () => {
<Grid
gridOptions={{
onRowClicked: ({ data }: RowClickedEvent) => {
window.open(
`/markets/${data.id}`,
'_blank',
'noopener,noreferrer'
);
navigate(`/markets/${data.id}`);
},
}}
rowData={localData}
@@ -63,8 +63,9 @@ export const LPProvidersGrid = ({
headerName={t('Equity-like share')}
field="equityLikeShare"
valueFormatter={({ value }: { value?: string | null }) => {
const valueOr0 = value ? value : '';
return `${parseInt(valueOr0) * 100}%`;
return value
? `${parseFloat(parseFloat(value).toFixed(2)) * 100}%`
: '';
}}
/>
<AgGridColumn