2022-05-09 13:04:36 +00:00
|
|
|
import { Contract, tradingAllowed } from 'web/lib/firebase/contracts'
|
2022-04-07 21:15:51 +00:00
|
|
|
import { Col } from '../layout/col'
|
|
|
|
import { Spacer } from '../layout/spacer'
|
2021-12-12 22:14:52 +00:00
|
|
|
import { ContractProbGraph } from './contract-prob-graph'
|
2022-05-09 13:04:36 +00:00
|
|
|
import { useUser } from 'web/hooks/use-user'
|
2022-04-07 21:15:51 +00:00
|
|
|
import { Row } from '../layout/row'
|
|
|
|
import { Linkify } from '../linkify'
|
2021-12-20 05:15:18 +00:00
|
|
|
import clsx from 'clsx'
|
2022-05-19 17:42:03 +00:00
|
|
|
|
2022-04-18 23:02:40 +00:00
|
|
|
import {
|
2022-04-19 02:44:31 +00:00
|
|
|
FreeResponseResolutionOrChance,
|
2022-04-18 23:02:40 +00:00
|
|
|
BinaryResolutionOrChance,
|
2022-05-19 17:42:03 +00:00
|
|
|
NumericResolutionOrExpectation,
|
2022-04-18 23:02:40 +00:00
|
|
|
} from './contract-card'
|
2022-05-09 13:04:36 +00:00
|
|
|
import { Bet } from 'common/bet'
|
|
|
|
import { Comment } from 'common/comment'
|
2022-04-07 21:15:51 +00:00
|
|
|
import BetRow from '../bet-row'
|
|
|
|
import { AnswersGraph } from '../answers/answers-graph'
|
2022-05-19 17:42:03 +00:00
|
|
|
import {
|
|
|
|
DPM,
|
|
|
|
FreeResponse,
|
|
|
|
FullContract,
|
|
|
|
NumericContract,
|
|
|
|
} from 'common/contract'
|
2022-04-07 21:15:51 +00:00
|
|
|
import { ContractDescription } from './contract-description'
|
2022-04-20 03:34:41 +00:00
|
|
|
import { ContractDetails } from './contract-details'
|
2022-05-02 15:23:51 +00:00
|
|
|
import { ShareMarket } from '../share-market'
|
2022-05-19 17:42:03 +00:00
|
|
|
import { NumericGraph } from './numeric-graph'
|
2021-12-16 10:46:41 +00:00
|
|
|
|
2021-12-12 22:14:52 +00:00
|
|
|
export const ContractOverview = (props: {
|
|
|
|
contract: Contract
|
2022-01-15 00:16:25 +00:00
|
|
|
bets: Bet[]
|
|
|
|
comments: Comment[]
|
2021-12-12 22:14:52 +00:00
|
|
|
className?: string
|
|
|
|
}) => {
|
2022-04-18 23:02:40 +00:00
|
|
|
const { contract, bets, className } = props
|
|
|
|
const { question, creatorId, outcomeType, resolution } = contract
|
2021-12-10 14:56:17 +00:00
|
|
|
|
2021-12-14 18:51:30 +00:00
|
|
|
const user = useUser()
|
|
|
|
const isCreator = user?.id === creatorId
|
2022-02-17 23:00:19 +00:00
|
|
|
const isBinary = outcomeType === 'BINARY'
|
2021-12-14 18:51:30 +00:00
|
|
|
|
2021-12-10 14:56:17 +00:00
|
|
|
return (
|
2021-12-20 05:15:18 +00:00
|
|
|
<Col className={clsx('mb-6', className)}>
|
2022-03-21 21:19:08 +00:00
|
|
|
<Col className="gap-4 px-2">
|
|
|
|
<Row className="justify-between gap-4">
|
2022-02-11 18:40:22 +00:00
|
|
|
<div className="text-2xl text-indigo-700 md:text-3xl">
|
2022-02-17 23:00:19 +00:00
|
|
|
<Linkify text={question} />
|
2021-12-14 10:23:32 +00:00
|
|
|
</div>
|
|
|
|
|
2022-04-18 23:02:40 +00:00
|
|
|
{isBinary && (
|
|
|
|
<BinaryResolutionOrChance
|
2022-04-03 23:43:30 +00:00
|
|
|
className="hidden items-end xl:flex"
|
2022-02-17 23:00:19 +00:00
|
|
|
contract={contract}
|
|
|
|
large
|
|
|
|
/>
|
2022-03-21 21:19:08 +00:00
|
|
|
)}
|
2022-05-19 17:42:03 +00:00
|
|
|
|
|
|
|
{outcomeType === 'NUMERIC' && (
|
|
|
|
<NumericResolutionOrExpectation
|
|
|
|
contract={contract as NumericContract}
|
|
|
|
className="hidden items-end xl:flex"
|
|
|
|
/>
|
|
|
|
)}
|
2022-03-21 21:19:08 +00:00
|
|
|
</Row>
|
|
|
|
|
2022-04-18 23:02:40 +00:00
|
|
|
{isBinary ? (
|
|
|
|
<Row className="items-center justify-between gap-4 xl:hidden">
|
|
|
|
<BinaryResolutionOrChance contract={contract} />
|
2022-03-21 21:19:08 +00:00
|
|
|
|
2022-05-11 21:35:50 +00:00
|
|
|
{tradingAllowed(contract) && <BetRow contract={contract} />}
|
2022-04-18 23:02:40 +00:00
|
|
|
</Row>
|
|
|
|
) : (
|
|
|
|
outcomeType === 'FREE_RESPONSE' &&
|
|
|
|
resolution && (
|
2022-04-19 02:44:31 +00:00
|
|
|
<FreeResponseResolutionOrChance
|
2022-04-18 23:02:40 +00:00
|
|
|
contract={contract}
|
|
|
|
truncate="none"
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
)}
|
2022-03-21 21:19:08 +00:00
|
|
|
|
2022-05-19 17:42:03 +00:00
|
|
|
{outcomeType === 'NUMERIC' && (
|
|
|
|
<Row className="items-center justify-between gap-4 xl:hidden">
|
|
|
|
<NumericResolutionOrExpectation
|
|
|
|
contract={contract as NumericContract}
|
|
|
|
/>
|
|
|
|
</Row>
|
|
|
|
)}
|
|
|
|
|
2022-04-13 19:11:49 +00:00
|
|
|
<ContractDetails
|
|
|
|
contract={contract}
|
|
|
|
bets={bets}
|
|
|
|
isCreator={isCreator}
|
|
|
|
/>
|
2022-03-21 21:19:08 +00:00
|
|
|
</Col>
|
2021-12-10 14:56:17 +00:00
|
|
|
<Spacer h={4} />
|
2022-05-19 17:42:03 +00:00
|
|
|
{isBinary && <ContractProbGraph contract={contract} bets={bets} />}{' '}
|
|
|
|
{outcomeType === 'FREE_RESPONSE' && (
|
2022-03-15 22:27:51 +00:00
|
|
|
<AnswersGraph
|
|
|
|
contract={contract as FullContract<DPM, FreeResponse>}
|
|
|
|
bets={bets}
|
|
|
|
/>
|
2022-03-15 19:42:04 +00:00
|
|
|
)}
|
2022-05-19 17:42:03 +00:00
|
|
|
{outcomeType === 'NUMERIC' && (
|
|
|
|
<NumericGraph contract={contract as NumericContract} />
|
|
|
|
)}
|
2022-05-02 15:23:51 +00:00
|
|
|
{(contract.description || isCreator) && <Spacer h={6} />}
|
|
|
|
{isCreator && <ShareMarket className="px-2" contract={contract} />}
|
2022-04-07 21:09:19 +00:00
|
|
|
<ContractDescription
|
|
|
|
className="px-2"
|
|
|
|
contract={contract}
|
|
|
|
isCreator={isCreator}
|
|
|
|
/>
|
2021-12-10 14:56:17 +00:00
|
|
|
</Col>
|
|
|
|
)
|
|
|
|
}
|