import clsx from 'clsx' import Link from 'next/link' import { Row } from '../layout/row' import { formatPercent } from 'common/util/format' import { Contract, contractPath, getBinaryProbPercent, } from 'web/lib/firebase/contracts' import { Col } from '../layout/col' import { Binary, CPMM, DPM, FreeResponse, FreeResponseContract, FullContract, } from 'common/contract' import { AnswerLabel, BinaryContractOutcomeLabel, FreeResponseOutcomeLabel, } from '../outcome-label' import { getOutcomeProbability, getTopAnswer } from 'common/calculate' import { AbbrContractDetails } from './contract-details' import { TagsList } from '../tags-list' import { CATEGORY_LIST } from 'common/categories' export function ContractCard(props: { contract: Contract showHotVolume?: boolean showCloseTime?: boolean className?: string }) { const { contract, showHotVolume, showCloseTime, className } = props const { question, outcomeType, resolution } = contract const { tags } = contract const categories = tags.filter((tag) => CATEGORY_LIST.includes(tag.toLowerCase()) ) return (

{question}

{outcomeType !== 'FREE_RESPONSE' && categories.length > 0 && ( )} {outcomeType === 'BINARY' && ( )}
{outcomeType === 'FREE_RESPONSE' && ( } truncate="long" /> )} {outcomeType === 'FREE_RESPONSE' && categories.length > 0 && ( )}
) } export function BinaryResolutionOrChance(props: { contract: FullContract large?: boolean className?: string }) { const { contract, large, className } = props const { resolution } = contract const marketClosed = (contract.closeTime || Infinity) < Date.now() const probColor = marketClosed ? 'text-gray-400' : 'text-primary' return ( {resolution ? ( <>
Resolved
) : ( <>
{getBinaryProbPercent(contract)}
chance
)} ) } export function FreeResponseResolutionOrChance(props: { contract: FreeResponseContract truncate: 'short' | 'long' | 'none' className?: string }) { const { contract, truncate, className } = props const { resolution } = contract const topAnswer = getTopAnswer(contract) return ( {resolution ? ( <>
Resolved
) : ( topAnswer && (
{formatPercent(getOutcomeProbability(contract, topAnswer.id))}
chance
) )} ) }