From 53d89fa4aca0f05ed8cd3fb7044f6365d9cf07f6 Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Tue, 2 Aug 2022 14:59:47 -0700 Subject: [PATCH] Show the value to 2 decimal places on hover --- web/components/contract/contract-card.tsx | 27 ++++++++++++++--------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/web/components/contract/contract-card.tsx b/web/components/contract/contract-card.tsx index e418178c..b1ab7731 100644 --- a/web/components/contract/contract-card.tsx +++ b/web/components/contract/contract-card.tsx @@ -30,7 +30,7 @@ import { useContractWithPreload } from 'web/hooks/use-contract' import { useUser } from 'web/hooks/use-user' import { track } from '@amplitude/analytics-browser' import { trackCallback } from 'web/lib/service/analytics' -import { formatNumericProbability } from 'common/pseudo-numeric' +import { formatNumericProbability, getMappedValue } from 'common/pseudo-numeric' export function ContractCard(props: { contract: Contract @@ -317,6 +317,12 @@ export function PseudoNumericResolutionOrExpectation(props: { const { resolution, resolutionValue, resolutionProbability } = contract const textColor = `text-blue-400` + const value = resolution + ? resolutionValue + ? resolutionValue + : getMappedValue(contract)(resolutionProbability ?? 0) + : getMappedValue(contract)(getProbability(contract)) + return ( {resolution ? ( @@ -326,20 +332,21 @@ export function PseudoNumericResolutionOrExpectation(props: { {resolution === 'CANCEL' ? ( ) : ( -
- {resolutionValue - ? formatLargeNumber(resolutionValue) - : formatNumericProbability( - resolutionProbability ?? 0, - contract - )} +
+ {formatLargeNumber(value)}
)} ) : ( <> -
- {formatNumericProbability(getProbability(contract), contract)} +
+ {formatLargeNumber(value)}
expected