From e0ad81d3804124cb23d909901b1651659ed0563a Mon Sep 17 00:00:00 2001 From: mantikoros Date: Tue, 27 Sep 2022 12:47:54 -0400 Subject: [PATCH] hide only if no bets; show invested on desktop --- web/components/bet-summary.tsx | 39 ++++++++++++------------- web/components/bets-list.tsx | 3 +- web/pages/[username]/[contractSlug].tsx | 3 +- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/web/components/bet-summary.tsx b/web/components/bet-summary.tsx index afeeb3fd..7460c83d 100644 --- a/web/components/bet-summary.tsx +++ b/web/components/bet-summary.tsx @@ -2,14 +2,9 @@ import { sumBy } from 'lodash' import clsx from 'clsx' import { Bet } from 'web/lib/firebase/bets' -import { - formatMoney, - formatWithCommas, -} from 'common/util/format' +import { formatMoney, formatWithCommas } from 'common/util/format' import { Col } from './layout/col' -import { - Contract, -} from 'web/lib/firebase/contracts' +import { Contract } from 'web/lib/firebase/contracts' import { Row } from './layout/row' import { YesLabel, NoLabel } from './outcome-label' import { @@ -17,22 +12,20 @@ import { getContractBetMetrics, getProbability, } from 'common/calculate' -import { floatingEqual } from 'common/util/math' import { InfoTooltip } from './info-tooltip' import { ProfitBadge } from './profit-badge' export function BetsSummary(props: { contract: Contract - bets: Bet[] - isYourBets: boolean + userBets: Bet[] className?: string }) { const { contract, className } = props const { resolution, outcomeType } = contract const isBinary = outcomeType === 'BINARY' - const bets = props.bets.filter((b) => !b.isAnte) - const { profitPercent, payout, profit, totalShares } = getContractBetMetrics( + const bets = props.userBets.filter((b) => !b.isAnte) + const { profitPercent, payout, profit, invested } = getContractBetMetrics( contract, bets ) @@ -48,12 +41,7 @@ export function BetsSummary(props: { const prob = isBinary ? getProbability(contract) : 0 const expectation = prob * yesWinnings + (1 - prob) * noWinnings - if ( - isBinary && - floatingEqual(totalShares.YES ?? 0, 0) && - floatingEqual(totalShares.NO ?? 0, 0) - ) - return <> + if (bets.length === 0) return <> return ( @@ -87,17 +75,25 @@ export function BetsSummary(props: { ) : (
- Expected value {''} + Expectation{''}
{formatMoney(payout)}
)} + +
+ Invested{' '} + +
+
{formatMoney(invested)}
+ + {isBinary && (
- Expected value{' '} + Expectation{' '}
{formatMoney(expectation)}
@@ -110,7 +106,8 @@ export function BetsSummary(props: {
- {formatMoney(profit)} + {formatMoney(profit)} +
diff --git a/web/components/bets-list.tsx b/web/components/bets-list.tsx index bd29f8ab..038a3910 100644 --- a/web/components/bets-list.tsx +++ b/web/components/bets-list.tsx @@ -346,8 +346,7 @@ function ContractBets(props: { {contract.mechanism === 'cpmm-1' && limitBets.length > 0 && ( diff --git a/web/pages/[username]/[contractSlug].tsx b/web/pages/[username]/[contractSlug].tsx index dd4a90f0..1dde2f95 100644 --- a/web/pages/[username]/[contractSlug].tsx +++ b/web/pages/[username]/[contractSlug].tsx @@ -255,8 +255,7 @@ export function ContractPageContent(