2022-08-05 05:22:45 +00:00
|
|
|
import React from 'react'
|
|
|
|
import clsx from 'clsx'
|
|
|
|
|
|
|
|
import { 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'
|
2022-04-18 23:02:40 +00:00
|
|
|
import {
|
|
|
|
BinaryResolutionOrChance,
|
2022-08-04 21:27:02 +00:00
|
|
|
FreeResponseResolutionOrChance,
|
2022-05-19 17:42:03 +00:00
|
|
|
NumericResolutionOrExpectation,
|
2022-07-02 19:37:59 +00:00
|
|
|
PseudoNumericResolutionOrExpectation,
|
2022-04-18 23:02:40 +00:00
|
|
|
} from './contract-card'
|
2022-05-09 13:04:36 +00:00
|
|
|
import { Bet } from 'common/bet'
|
2022-08-19 17:07:48 +00:00
|
|
|
import BetButton from '../bet-button'
|
2022-04-07 21:15:51 +00:00
|
|
|
import { AnswersGraph } from '../answers/answers-graph'
|
2022-07-10 18:05:44 +00:00
|
|
|
import { Contract, CPMMBinaryContract } 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-19 17:42:03 +00:00
|
|
|
import { NumericGraph } from './numeric-graph'
|
2022-08-05 05:22:45 +00:00
|
|
|
import { ShareRow } from './share-row'
|
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[]
|
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-08-04 21:27:02 +00:00
|
|
|
|
2022-02-17 23:00:19 +00:00
|
|
|
const isBinary = outcomeType === 'BINARY'
|
2022-07-02 19:37:59 +00:00
|
|
|
const isPseudoNumeric = outcomeType === 'PSEUDO_NUMERIC'
|
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
|
|
|
|
2022-07-02 19:37:59 +00:00
|
|
|
{isPseudoNumeric && (
|
|
|
|
<PseudoNumericResolutionOrExpectation
|
|
|
|
contract={contract}
|
|
|
|
className="hidden items-end xl:flex"
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
|
2022-05-19 17:42:03 +00:00
|
|
|
{outcomeType === 'NUMERIC' && (
|
|
|
|
<NumericResolutionOrExpectation
|
2022-06-01 02:42:35 +00:00
|
|
|
contract={contract}
|
2022-05-19 17:42:03 +00:00
|
|
|
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-07-10 18:05:44 +00:00
|
|
|
{tradingAllowed(contract) && (
|
2022-08-19 17:07:48 +00:00
|
|
|
<BetButton contract={contract as CPMMBinaryContract} />
|
2022-07-10 18:05:44 +00:00
|
|
|
)}
|
|
|
|
</Row>
|
|
|
|
) : isPseudoNumeric ? (
|
|
|
|
<Row className="items-center justify-between gap-4 xl:hidden">
|
|
|
|
<PseudoNumericResolutionOrExpectation contract={contract} />
|
2022-08-19 17:07:48 +00:00
|
|
|
{tradingAllowed(contract) && <BetButton contract={contract} />}
|
2022-07-02 19:37:59 +00:00
|
|
|
</Row>
|
|
|
|
) : isPseudoNumeric ? (
|
|
|
|
<Row className="items-center justify-between gap-4 xl:hidden">
|
|
|
|
<PseudoNumericResolutionOrExpectation contract={contract} />
|
2022-08-19 17:07:48 +00:00
|
|
|
{tradingAllowed(contract) && <BetButton contract={contract} />}
|
2022-04-18 23:02:40 +00:00
|
|
|
</Row>
|
|
|
|
) : (
|
2022-07-28 02:40:33 +00:00
|
|
|
(outcomeType === 'FREE_RESPONSE' ||
|
|
|
|
outcomeType === 'MULTIPLE_CHOICE') &&
|
2022-04-18 23:02:40 +00:00
|
|
|
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">
|
2022-06-01 02:42:35 +00:00
|
|
|
<NumericResolutionOrExpectation contract={contract} />
|
2022-05-19 17:42:03 +00:00
|
|
|
</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-07-02 19:37:59 +00:00
|
|
|
{(isBinary || isPseudoNumeric) && (
|
|
|
|
<ContractProbGraph contract={contract} bets={bets} />
|
|
|
|
)}{' '}
|
2022-07-28 02:40:33 +00:00
|
|
|
{(outcomeType === 'FREE_RESPONSE' ||
|
|
|
|
outcomeType === 'MULTIPLE_CHOICE') && (
|
2022-06-01 02:42:35 +00:00
|
|
|
<AnswersGraph contract={contract} bets={bets} />
|
2022-05-19 17:42:03 +00:00
|
|
|
)}
|
2022-06-01 02:42:35 +00:00
|
|
|
{outcomeType === 'NUMERIC' && <NumericGraph contract={contract} />}
|
2022-08-05 05:22:45 +00:00
|
|
|
<ShareRow user={user} 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>
|
|
|
|
)
|
|
|
|
}
|