import clsx from 'clsx' import { Answer } from 'common/answer' import { FreeResponseContract } from 'common/contract' import { Col } from '../layout/col' import { Row } from '../layout/row' import { Avatar } from '../avatar' import { SiteLink } from '../site-link' import { formatPercent } from 'common/util/format' import { getDpmOutcomeProbability } from 'common/calculate-dpm' import { tradingAllowed } from 'web/lib/firebase/contracts' import { Linkify } from '../linkify' export function AnswerItem(props: { answer: Answer contract: FreeResponseContract showChoice: 'radio' | 'checkbox' | undefined chosenProb: number | undefined totalChosenProb?: number onChoose: (answerId: string, prob: number) => void onDeselect: (answerId: string) => void }) { const { answer, contract, showChoice, chosenProb, totalChosenProb, onChoose, onDeselect, } = props const { resolution, resolutions, totalShares } = contract const { username, avatarUrl, name, number, text } = answer const isChosen = chosenProb !== undefined const prob = getDpmOutcomeProbability(totalShares, answer.id) const roundedProb = Math.round(prob * 100) const probPercent = formatPercent(prob) const wasResolvedTo = resolution === answer.id || (resolutions && resolutions[answer.id]) return (