This commit is contained in:
github-actions[bot] 2022-10-12 18:56:25 +00:00 committed by GitHub
commit 1644031d79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,11 +1,7 @@
import clsx from 'clsx' import clsx from 'clsx'
import Link from 'next/link' import Link from 'next/link'
import { Row } from '../layout/row' import { Row } from '../layout/row'
import { import { formatLargeNumber, formatPercent } from 'common/util/format'
formatLargeNumber,
formatMoney,
formatPercent,
} from 'common/util/format'
import { contractPath, getBinaryProbPercent } from 'web/lib/firebase/contracts' import { contractPath, getBinaryProbPercent } from 'web/lib/firebase/contracts'
import { Col } from '../layout/col' import { Col } from '../layout/col'
import { import {
@ -42,6 +38,7 @@ import { SiteLink } from '../site-link'
import { ProbChange } from './prob-change-table' import { ProbChange } from './prob-change-table'
import { Card } from '../card' import { Card } from '../card'
import { ProfitBadgeMana } from '../profit-badge' import { ProfitBadgeMana } from '../profit-badge'
import { floatingEqual } from 'common/util/math'
export function ContractCard(props: { export function ContractCard(props: {
contract: Contract contract: Contract
@ -405,7 +402,7 @@ export function ContractCardProbChange(props: {
const metrics = useUserContractMetrics(user?.id, contract.id) const metrics = useUserContractMetrics(user?.id, contract.id)
const dayMetrics = metrics && metrics.from && metrics.from.day const dayMetrics = metrics && metrics.from && metrics.from.day
const outcome = const outcome =
metrics && metrics.hasShares && metrics.totalShares.YES ? 'YES' : 'NO' metrics && floatingEqual(metrics.totalShares.NO ?? 0, 0) ? 'YES' : 'NO'
return ( return (
<Card className={clsx(className, 'mb-4')}> <Card className={clsx(className, 'mb-4')}>
@ -423,7 +420,7 @@ export function ContractCardProbChange(props: {
</SiteLink> </SiteLink>
<ProbChange className="py-2 pr-4" contract={contract} /> <ProbChange className="py-2 pr-4" contract={contract} />
</Row> </Row>
{showPosition && metrics && ( {showPosition && metrics && metrics.hasShares && (
<Row <Row
className={clsx( className={clsx(
'items-center justify-between gap-4 pl-6 pr-4 pb-2 text-sm' 'items-center justify-between gap-4 pl-6 pr-4 pb-2 text-sm'
@ -431,7 +428,7 @@ export function ContractCardProbChange(props: {
> >
<Row className="gap-1 text-gray-700"> <Row className="gap-1 text-gray-700">
<div className="text-gray-500">Position</div> <div className="text-gray-500">Position</div>
{formatMoney(metrics.payout)} {outcome} {Math.floor(metrics.totalShares[outcome])} {outcome}
</Row> </Row>
{dayMetrics && ( {dayMetrics && (