Show shares as contract card position. Fix bug on outcome
This commit is contained in:
parent
da1fcb646f
commit
de76557326
|
@ -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 && (
|
||||||
|
|
Loading…
Reference in New Issue
Block a user