From 2118229953056822ad789cebc44406da03e20ddd Mon Sep 17 00:00:00 2001 From: James Grugett Date: Mon, 18 Apr 2022 17:53:35 -0500 Subject: [PATCH] Clean up unused parts of answer item --- web/components/answers/answer-item.tsx | 206 ++++++++++--------------- 1 file changed, 80 insertions(+), 126 deletions(-) diff --git a/web/components/answers/answer-item.tsx b/web/components/answers/answer-item.tsx index 07e4ffc7..fdeafea0 100644 --- a/web/components/answers/answer-item.tsx +++ b/web/components/answers/answer-item.tsx @@ -1,6 +1,5 @@ import clsx from 'clsx' import _ from 'lodash' -import { useState } from 'react' import { Answer } from '../../../common/answer' import { DPM, FreeResponse, FullContract } from '../../../common/contract' @@ -8,19 +7,14 @@ import { Col } from '../layout/col' import { Row } from '../layout/row' import { Avatar } from '../avatar' import { SiteLink } from '../site-link' -import { BuyButton } from '../yes-no-selector' import { formatPercent } from '../../../common/util/format' import { getDpmOutcomeProbability } from '../../../common/calculate-dpm' import { tradingAllowed } from '../../lib/firebase/contracts' -import { AnswerBetPanel } from './answer-bet-panel' import { Linkify } from '../linkify' -import { User } from '../../../common/user' -import { ContractActivity } from '../feed/contract-activity' export function AnswerItem(props: { answer: Answer contract: FullContract - user: User | null | undefined showChoice: 'radio' | 'checkbox' | undefined chosenProb: number | undefined totalChosenProb?: number @@ -30,7 +24,6 @@ export function AnswerItem(props: { const { answer, contract, - user, showChoice, chosenProb, totalChosenProb, @@ -47,10 +40,6 @@ export function AnswerItem(props: { const wasResolvedTo = resolution === answer.id || (resolutions && resolutions[answer.id]) - const [isBetting, setIsBetting] = useState(false) - - const canBet = !isBetting && !showChoice && tradingAllowed(contract) - return (
canBet && setIsBetting(true)} >
@@ -83,124 +70,91 @@ export function AnswerItem(props: { {/* TODO: Show total pool? */}
#{number}
- - {isBetting && ( - - )} - {isBetting ? ( - setIsBetting(false)} - className="sm:w-72" - /> - ) : ( - - {!wasResolvedTo && - (showChoice === 'checkbox' ? ( - { - const { value } = e.target - const numberValue = value - ? parseInt(value.replace(/[^\d]/, '')) - : 0 - if (!isNaN(numberValue)) onChoose(answer.id, numberValue) - }} - /> - ) : ( -
- {probPercent} -
- ))} - {showChoice ? ( -
- - {showChoice === 'checkbox' && ( -
- {chosenProb && totalChosenProb - ? Math.round((100 * chosenProb) / totalChosenProb) - : 0} - % share -
- )} -
+ + {!wasResolvedTo && + (showChoice === 'checkbox' ? ( + { + const { value } = e.target + const numberValue = value + ? parseInt(value.replace(/[^\d]/, '')) + : 0 + if (!isNaN(numberValue)) onChoose(answer.id, numberValue) + }} + /> ) : ( - <> - {tradingAllowed(contract) && ( - { - setIsBetting(true) - }} +
+ {probPercent} +
+ ))} + {showChoice ? ( +
+ + {showChoice === 'checkbox' && ( +
+ {chosenProb && totalChosenProb + ? Math.round((100 * chosenProb) / totalChosenProb) + : 0} + % share +
+ )} +
+ ) : ( + wasResolvedTo && ( + +
+ Chosen{' '} + {resolutions ? `${Math.round(resolutions[answer.id])}%` : ''} +
+
{probPercent}
+ + ) + )} +
) }