Show answer text in resolution for market page, card instead of number.
This commit is contained in:
parent
f88dc56e4b
commit
1f797f491f
|
@ -22,6 +22,7 @@ import { useState } from 'react'
|
||||||
import { getProbability } from '../../../common/calculate'
|
import { getProbability } from '../../../common/calculate'
|
||||||
import { ContractInfoDialog } from './contract-info-dialog'
|
import { ContractInfoDialog } from './contract-info-dialog'
|
||||||
import { Bet } from '../../../common/bet'
|
import { Bet } from '../../../common/bet'
|
||||||
|
import { DPM, FreeResponse, FullContract } from '../../../common/contract'
|
||||||
|
|
||||||
export function ContractCard(props: {
|
export function ContractCard(props: {
|
||||||
contract: Contract
|
contract: Contract
|
||||||
|
@ -30,7 +31,7 @@ export function ContractCard(props: {
|
||||||
className?: string
|
className?: string
|
||||||
}) {
|
}) {
|
||||||
const { contract, showHotVolume, showCloseTime, className } = props
|
const { contract, showHotVolume, showCloseTime, className } = props
|
||||||
const { question } = contract
|
const { question, outcomeType } = contract
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
@ -51,20 +52,42 @@ export function ContractCard(props: {
|
||||||
/>
|
/>
|
||||||
<Spacer h={3} />
|
<Spacer h={3} />
|
||||||
|
|
||||||
<Row className="justify-between gap-4">
|
<Row
|
||||||
|
className={clsx(
|
||||||
|
'justify-between gap-4',
|
||||||
|
outcomeType === 'FREE_RESPONSE' && 'flex-col items-start'
|
||||||
|
)}
|
||||||
|
>
|
||||||
<p
|
<p
|
||||||
className="break-words font-medium text-indigo-700"
|
className="break-words font-medium text-indigo-700"
|
||||||
style={{ /* For iOS safari */ wordBreak: 'break-word' }}
|
style={{ /* For iOS safari */ wordBreak: 'break-word' }}
|
||||||
>
|
>
|
||||||
{question}
|
{question}
|
||||||
</p>
|
</p>
|
||||||
<ResolutionOrChance className="items-center" contract={contract} />
|
<ResolutionOrChance
|
||||||
|
className={clsx(
|
||||||
|
outcomeType === 'FREE_RESPONSE' ? 'items-start' : 'items-center'
|
||||||
|
)}
|
||||||
|
contract={contract}
|
||||||
|
/>
|
||||||
</Row>
|
</Row>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getAnswerResolutionText(
|
||||||
|
contract: FullContract<DPM, FreeResponse>,
|
||||||
|
resolution: string
|
||||||
|
) {
|
||||||
|
const { answers } = contract
|
||||||
|
const chosen = answers?.find((answer) => answer.id === resolution)
|
||||||
|
if (chosen) {
|
||||||
|
return chosen.text.slice(0, 50)
|
||||||
|
}
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
export function ResolutionOrChance(props: {
|
export function ResolutionOrChance(props: {
|
||||||
contract: Contract
|
contract: Contract
|
||||||
large?: boolean
|
large?: boolean
|
||||||
|
@ -86,8 +109,7 @@ export function ResolutionOrChance(props: {
|
||||||
|
|
||||||
const probColor = marketClosed ? 'text-gray-400' : 'text-primary'
|
const probColor = marketClosed ? 'text-gray-400' : 'text-primary'
|
||||||
|
|
||||||
const resolutionText =
|
const resolutionText = {
|
||||||
{
|
|
||||||
YES: 'YES',
|
YES: 'YES',
|
||||||
NO: 'NO',
|
NO: 'NO',
|
||||||
MKT: isBinary
|
MKT: isBinary
|
||||||
|
@ -97,7 +119,15 @@ export function ResolutionOrChance(props: {
|
||||||
: 'MULTI',
|
: 'MULTI',
|
||||||
CANCEL: 'N/A',
|
CANCEL: 'N/A',
|
||||||
'': '',
|
'': '',
|
||||||
}[resolution || ''] ?? `#${resolution}`
|
}[resolution || '']
|
||||||
|
|
||||||
|
const answerText =
|
||||||
|
resolution &&
|
||||||
|
outcomeType === 'FREE_RESPONSE' &&
|
||||||
|
getAnswerResolutionText(
|
||||||
|
contract as FullContract<DPM, FreeResponse>,
|
||||||
|
resolution
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Col className={clsx(large ? 'text-4xl' : 'text-3xl', className)}>
|
<Col className={clsx(large ? 'text-4xl' : 'text-3xl', className)}>
|
||||||
|
@ -108,7 +138,11 @@ export function ResolutionOrChance(props: {
|
||||||
>
|
>
|
||||||
Resolved
|
Resolved
|
||||||
</div>
|
</div>
|
||||||
|
{resolutionText ? (
|
||||||
<div className={resolutionColor}>{resolutionText}</div>
|
<div className={resolutionColor}>{resolutionText}</div>
|
||||||
|
) : (
|
||||||
|
<div className={clsx(resolutionColor, 'text-xl')}>{answerText}</div>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
isBinary && (
|
isBinary && (
|
||||||
|
|
|
@ -20,8 +20,8 @@ export const ContractOverview = (props: {
|
||||||
comments: Comment[]
|
comments: Comment[]
|
||||||
className?: string
|
className?: string
|
||||||
}) => {
|
}) => {
|
||||||
const { contract, bets, comments, className } = props
|
const { contract, bets, className } = props
|
||||||
const { question, resolution, creatorId, outcomeType } = contract
|
const { question, creatorId, outcomeType } = contract
|
||||||
|
|
||||||
const user = useUser()
|
const user = useUser()
|
||||||
const isCreator = user?.id === creatorId
|
const isCreator = user?.id === creatorId
|
||||||
|
@ -35,7 +35,7 @@ export const ContractOverview = (props: {
|
||||||
<Linkify text={question} />
|
<Linkify text={question} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{(isBinary || resolution) && (
|
{isBinary && (
|
||||||
<ResolutionOrChance
|
<ResolutionOrChance
|
||||||
className="hidden items-end xl:flex"
|
className="hidden items-end xl:flex"
|
||||||
contract={contract}
|
contract={contract}
|
||||||
|
@ -44,15 +44,17 @@ export const ContractOverview = (props: {
|
||||||
)}
|
)}
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
|
{isBinary ? (
|
||||||
<Row className="items-center justify-between gap-4 xl:hidden">
|
<Row className="items-center justify-between gap-4 xl:hidden">
|
||||||
{(isBinary || resolution) && (
|
|
||||||
<ResolutionOrChance contract={contract} />
|
<ResolutionOrChance contract={contract} />
|
||||||
)}
|
|
||||||
|
|
||||||
{isBinary && tradingAllowed(contract) && (
|
{tradingAllowed(contract) && (
|
||||||
<BetRow contract={contract} labelClassName="hidden" />
|
<BetRow contract={contract} labelClassName="hidden" />
|
||||||
)}
|
)}
|
||||||
</Row>
|
</Row>
|
||||||
|
) : (
|
||||||
|
<ResolutionOrChance contract={contract} />
|
||||||
|
)}
|
||||||
|
|
||||||
<ContractDetails
|
<ContractDetails
|
||||||
contract={contract}
|
contract={contract}
|
||||||
|
|
|
@ -344,7 +344,7 @@ export function FeedQuestion(props: {
|
||||||
{question}
|
{question}
|
||||||
</SiteLink>
|
</SiteLink>
|
||||||
</Col>
|
</Col>
|
||||||
{(isBinary || resolution) && (
|
{isBinary && (
|
||||||
<ResolutionOrChance className="items-center" contract={contract} />
|
<ResolutionOrChance className="items-center" contract={contract} />
|
||||||
)}
|
)}
|
||||||
</Col>
|
</Col>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user