From b583af005b7cbe4f7ea720c0bae3b98c6568470a Mon Sep 17 00:00:00 2001 From: Ciaran McGhie Date: Mon, 14 Nov 2022 14:44:53 +0000 Subject: [PATCH] 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. --- .../app/components/dashboard/market-list/market-list.tsx | 8 +++----- .../src/app/components/detail/providers/providers.tsx | 5 +++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/apps/liquidity-provision-dashboard/src/app/components/dashboard/market-list/market-list.tsx b/apps/liquidity-provision-dashboard/src/app/components/dashboard/market-list/market-list.tsx index 46a70647a..0eac96835 100644 --- a/apps/liquidity-provision-dashboard/src/app/components/dashboard/market-list/market-list.tsx +++ b/apps/liquidity-provision-dashboard/src/app/components/dashboard/market-list/market-list.tsx @@ -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 = () => { { - window.open( - `/markets/${data.id}`, - '_blank', - 'noopener,noreferrer' - ); + navigate(`/markets/${data.id}`); }, }} rowData={localData} diff --git a/apps/liquidity-provision-dashboard/src/app/components/detail/providers/providers.tsx b/apps/liquidity-provision-dashboard/src/app/components/detail/providers/providers.tsx index ea9cea89c..f86685cf6 100644 --- a/apps/liquidity-provision-dashboard/src/app/components/detail/providers/providers.tsx +++ b/apps/liquidity-provision-dashboard/src/app/components/detail/providers/providers.tsx @@ -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}%` + : ''; }} />