Clean up unused parts of answer item
This commit is contained in:
parent
7ec1ce174c
commit
2118229953
|
@ -1,6 +1,5 @@
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import { useState } from 'react'
|
|
||||||
|
|
||||||
import { Answer } from '../../../common/answer'
|
import { Answer } from '../../../common/answer'
|
||||||
import { DPM, FreeResponse, FullContract } from '../../../common/contract'
|
import { DPM, FreeResponse, FullContract } from '../../../common/contract'
|
||||||
|
@ -8,19 +7,14 @@ import { Col } from '../layout/col'
|
||||||
import { Row } from '../layout/row'
|
import { Row } from '../layout/row'
|
||||||
import { Avatar } from '../avatar'
|
import { Avatar } from '../avatar'
|
||||||
import { SiteLink } from '../site-link'
|
import { SiteLink } from '../site-link'
|
||||||
import { BuyButton } from '../yes-no-selector'
|
|
||||||
import { formatPercent } from '../../../common/util/format'
|
import { formatPercent } from '../../../common/util/format'
|
||||||
import { getDpmOutcomeProbability } from '../../../common/calculate-dpm'
|
import { getDpmOutcomeProbability } from '../../../common/calculate-dpm'
|
||||||
import { tradingAllowed } from '../../lib/firebase/contracts'
|
import { tradingAllowed } from '../../lib/firebase/contracts'
|
||||||
import { AnswerBetPanel } from './answer-bet-panel'
|
|
||||||
import { Linkify } from '../linkify'
|
import { Linkify } from '../linkify'
|
||||||
import { User } from '../../../common/user'
|
|
||||||
import { ContractActivity } from '../feed/contract-activity'
|
|
||||||
|
|
||||||
export function AnswerItem(props: {
|
export function AnswerItem(props: {
|
||||||
answer: Answer
|
answer: Answer
|
||||||
contract: FullContract<DPM, FreeResponse>
|
contract: FullContract<DPM, FreeResponse>
|
||||||
user: User | null | undefined
|
|
||||||
showChoice: 'radio' | 'checkbox' | undefined
|
showChoice: 'radio' | 'checkbox' | undefined
|
||||||
chosenProb: number | undefined
|
chosenProb: number | undefined
|
||||||
totalChosenProb?: number
|
totalChosenProb?: number
|
||||||
|
@ -30,7 +24,6 @@ export function AnswerItem(props: {
|
||||||
const {
|
const {
|
||||||
answer,
|
answer,
|
||||||
contract,
|
contract,
|
||||||
user,
|
|
||||||
showChoice,
|
showChoice,
|
||||||
chosenProb,
|
chosenProb,
|
||||||
totalChosenProb,
|
totalChosenProb,
|
||||||
|
@ -47,10 +40,6 @@ export function AnswerItem(props: {
|
||||||
const wasResolvedTo =
|
const wasResolvedTo =
|
||||||
resolution === answer.id || (resolutions && resolutions[answer.id])
|
resolution === answer.id || (resolutions && resolutions[answer.id])
|
||||||
|
|
||||||
const [isBetting, setIsBetting] = useState(false)
|
|
||||||
|
|
||||||
const canBet = !isBetting && !showChoice && tradingAllowed(contract)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={clsx(
|
className={clsx(
|
||||||
|
@ -63,10 +52,8 @@ export function AnswerItem(props: {
|
||||||
? 'bg-gray-50'
|
? 'bg-gray-50'
|
||||||
: showChoice === 'radio'
|
: showChoice === 'radio'
|
||||||
? 'bg-green-50'
|
? 'bg-green-50'
|
||||||
: 'bg-blue-50',
|
: 'bg-blue-50'
|
||||||
canBet && 'cursor-pointer hover:bg-gray-100'
|
|
||||||
)}
|
)}
|
||||||
onClick={() => canBet && setIsBetting(true)}
|
|
||||||
>
|
>
|
||||||
<Col className="flex-1 gap-3">
|
<Col className="flex-1 gap-3">
|
||||||
<div className="whitespace-pre-line">
|
<div className="whitespace-pre-line">
|
||||||
|
@ -83,28 +70,8 @@ export function AnswerItem(props: {
|
||||||
{/* TODO: Show total pool? */}
|
{/* TODO: Show total pool? */}
|
||||||
<div className="text-base">#{number}</div>
|
<div className="text-base">#{number}</div>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
{isBetting && (
|
|
||||||
<ContractActivity
|
|
||||||
className="hidden md:flex"
|
|
||||||
contract={contract}
|
|
||||||
bets={[]}
|
|
||||||
comments={[]}
|
|
||||||
user={user}
|
|
||||||
filterToOutcome={answer.id}
|
|
||||||
mode="all"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</Col>
|
</Col>
|
||||||
|
|
||||||
{isBetting ? (
|
|
||||||
<AnswerBetPanel
|
|
||||||
answer={answer}
|
|
||||||
contract={contract}
|
|
||||||
closePanel={() => setIsBetting(false)}
|
|
||||||
className="sm:w-72"
|
|
||||||
/>
|
|
||||||
) : (
|
|
||||||
<Row className="items-center justify-end gap-4 self-end sm:self-start">
|
<Row className="items-center justify-end gap-4 self-end sm:self-start">
|
||||||
{!wasResolvedTo &&
|
{!wasResolvedTo &&
|
||||||
(showChoice === 'checkbox' ? (
|
(showChoice === 'checkbox' ? (
|
||||||
|
@ -172,16 +139,7 @@ export function AnswerItem(props: {
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<>
|
wasResolvedTo && (
|
||||||
{tradingAllowed(contract) && (
|
|
||||||
<BuyButton
|
|
||||||
className="btn-md flex-initial justify-end self-end !px-8"
|
|
||||||
onClick={() => {
|
|
||||||
setIsBetting(true)
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
{wasResolvedTo && (
|
|
||||||
<Col className="items-end">
|
<Col className="items-end">
|
||||||
<div
|
<div
|
||||||
className={clsx(
|
className={clsx(
|
||||||
|
@ -190,17 +148,13 @@ export function AnswerItem(props: {
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
Chosen{' '}
|
Chosen{' '}
|
||||||
{resolutions
|
{resolutions ? `${Math.round(resolutions[answer.id])}%` : ''}
|
||||||
? `${Math.round(resolutions[answer.id])}%`
|
|
||||||
: ''}
|
|
||||||
</div>
|
</div>
|
||||||
<div className="text-2xl text-gray-500">{probPercent}</div>
|
<div className="text-2xl text-gray-500">{probPercent}</div>
|
||||||
</Col>
|
</Col>
|
||||||
)}
|
)
|
||||||
</>
|
|
||||||
)}
|
)}
|
||||||
</Row>
|
</Row>
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user