2022-08-05 05:22:45 +00:00
|
|
|
import { tradingAllowed } from 'web/lib/firebase/contracts'
|
2022-04-07 21:15:51 +00:00
|
|
|
import { Col } from '../layout/col'
|
2022-09-30 23:57:48 +00:00
|
|
|
import { ContractChart } from 'web/components/charts/contract'
|
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-09-27 00:28:54 +00:00
|
|
|
import BetButton, { BinaryMobileBetting } from '../bet-button'
|
2022-09-01 21:42:50 +00:00
|
|
|
import {
|
|
|
|
Contract,
|
|
|
|
CPMMContract,
|
|
|
|
FreeResponseContract,
|
|
|
|
MultipleChoiceContract,
|
|
|
|
NumericContract,
|
|
|
|
PseudoNumericContract,
|
2022-09-27 00:28:54 +00:00
|
|
|
BinaryContract,
|
2022-09-01 21:42:50 +00:00
|
|
|
} from 'common/contract'
|
2022-09-16 00:41:25 +00:00
|
|
|
import { ContractDetails } from './contract-details'
|
2022-10-03 09:49:19 +00:00
|
|
|
import { ContractReportResolution } from './contract-report-resolution'
|
2022-10-03 16:31:07 +00:00
|
|
|
import { SizedContainer } from 'web/components/sized-container'
|
2021-12-16 10:46:41 +00:00
|
|
|
|
2022-09-01 21:42:50 +00:00
|
|
|
const OverviewQuestion = (props: { text: string }) => (
|
2022-09-16 00:41:25 +00:00
|
|
|
<Linkify className="text-lg text-indigo-700 sm:text-2xl" text={props.text} />
|
2022-09-01 21:42:50 +00:00
|
|
|
)
|
2021-12-10 14:56:17 +00:00
|
|
|
|
2022-09-01 21:42:50 +00:00
|
|
|
const BetWidget = (props: { contract: CPMMContract }) => {
|
2021-12-14 18:51:30 +00:00
|
|
|
const user = useUser()
|
2022-09-01 21:42:50 +00:00
|
|
|
return (
|
2022-09-11 02:57:50 +00:00
|
|
|
<Col>
|
|
|
|
<BetButton contract={props.contract} />
|
|
|
|
{!user && (
|
|
|
|
<div className="mt-1 text-center text-sm text-gray-500">
|
|
|
|
(with play money!)
|
|
|
|
</div>
|
|
|
|
)}
|
2022-09-01 21:42:50 +00:00
|
|
|
</Col>
|
|
|
|
)
|
|
|
|
}
|
2021-12-14 18:51:30 +00:00
|
|
|
|
2022-09-30 23:57:48 +00:00
|
|
|
const SizedContractChart = (props: {
|
|
|
|
contract: Contract
|
|
|
|
bets: Bet[]
|
|
|
|
fullHeight: number
|
|
|
|
mobileHeight: number
|
|
|
|
}) => {
|
2022-10-03 16:31:07 +00:00
|
|
|
const { fullHeight, mobileHeight, contract, bets } = props
|
2022-09-30 23:57:48 +00:00
|
|
|
return (
|
2022-10-03 16:31:07 +00:00
|
|
|
<SizedContainer fullHeight={fullHeight} mobileHeight={mobileHeight}>
|
|
|
|
{(width, height) => (
|
2022-09-30 23:57:48 +00:00
|
|
|
<ContractChart
|
2022-10-03 16:31:07 +00:00
|
|
|
width={width}
|
|
|
|
height={height}
|
2022-09-30 23:57:48 +00:00
|
|
|
contract={contract}
|
|
|
|
bets={bets}
|
|
|
|
/>
|
|
|
|
)}
|
2022-10-03 16:31:07 +00:00
|
|
|
</SizedContainer>
|
2022-09-30 23:57:48 +00:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
const NumericOverview = (props: { contract: NumericContract; bets: Bet[] }) => {
|
|
|
|
const { contract, bets } = props
|
2021-12-10 14:56:17 +00:00
|
|
|
return (
|
2022-09-01 21:42:50 +00:00
|
|
|
<Col className="gap-1 md:gap-2">
|
2022-08-24 23:09:07 +00:00
|
|
|
<Col className="gap-3 px-2 sm:gap-4">
|
2022-09-01 21:42:50 +00:00
|
|
|
<ContractDetails contract={contract} />
|
|
|
|
<Row className="justify-between gap-4">
|
|
|
|
<OverviewQuestion text={contract.question} />
|
|
|
|
<NumericResolutionOrExpectation
|
|
|
|
contract={contract}
|
|
|
|
className="hidden items-end xl:flex"
|
|
|
|
/>
|
|
|
|
</Row>
|
|
|
|
<NumericResolutionOrExpectation
|
|
|
|
className="items-center justify-between gap-4 xl:hidden"
|
2022-08-30 23:13:25 +00:00
|
|
|
contract={contract}
|
|
|
|
/>
|
2022-09-01 21:42:50 +00:00
|
|
|
</Col>
|
2022-09-30 23:57:48 +00:00
|
|
|
<SizedContractChart
|
|
|
|
contract={contract}
|
|
|
|
bets={bets}
|
|
|
|
fullHeight={250}
|
|
|
|
mobileHeight={150}
|
|
|
|
/>
|
2022-09-01 21:42:50 +00:00
|
|
|
</Col>
|
|
|
|
)
|
|
|
|
}
|
2022-07-02 19:37:59 +00:00
|
|
|
|
2022-09-01 21:42:50 +00:00
|
|
|
const BinaryOverview = (props: { contract: BinaryContract; bets: Bet[] }) => {
|
|
|
|
const { contract, bets } = props
|
|
|
|
return (
|
|
|
|
<Col className="gap-1 md:gap-2">
|
2022-09-16 00:41:25 +00:00
|
|
|
<Col className="gap-1 px-2">
|
2022-09-01 21:42:50 +00:00
|
|
|
<ContractDetails contract={contract} />
|
|
|
|
<Row className="justify-between gap-4">
|
|
|
|
<OverviewQuestion text={contract.question} />
|
2022-10-03 09:49:19 +00:00
|
|
|
<Row>
|
|
|
|
<BinaryResolutionOrChance
|
|
|
|
className="flex items-end"
|
|
|
|
contract={contract}
|
|
|
|
large
|
|
|
|
/>
|
|
|
|
{contract.isResolved && (
|
|
|
|
<ContractReportResolution contract={contract} />
|
|
|
|
)}
|
|
|
|
</Row>
|
2022-03-21 21:19:08 +00:00
|
|
|
</Row>
|
2022-09-01 21:42:50 +00:00
|
|
|
</Col>
|
2022-09-30 23:57:48 +00:00
|
|
|
<SizedContractChart
|
|
|
|
contract={contract}
|
|
|
|
bets={bets}
|
|
|
|
fullHeight={250}
|
|
|
|
mobileHeight={150}
|
|
|
|
/>
|
2022-09-27 00:28:54 +00:00
|
|
|
<Row className="items-center justify-between gap-4 xl:hidden">
|
|
|
|
{tradingAllowed(contract) && (
|
|
|
|
<BinaryMobileBetting contract={contract} />
|
|
|
|
)}
|
|
|
|
</Row>
|
2022-09-01 21:42:50 +00:00
|
|
|
</Col>
|
|
|
|
)
|
|
|
|
}
|
2022-03-21 21:19:08 +00:00
|
|
|
|
2022-09-01 21:42:50 +00:00
|
|
|
const ChoiceOverview = (props: {
|
|
|
|
contract: FreeResponseContract | MultipleChoiceContract
|
|
|
|
bets: Bet[]
|
|
|
|
}) => {
|
|
|
|
const { contract, bets } = props
|
|
|
|
const { question, resolution } = contract
|
|
|
|
return (
|
|
|
|
<Col className="gap-1 md:gap-2">
|
|
|
|
<Col className="gap-3 px-2 sm:gap-4">
|
|
|
|
<ContractDetails contract={contract} />
|
|
|
|
<OverviewQuestion text={question} />
|
|
|
|
{resolution && (
|
2022-10-03 09:49:19 +00:00
|
|
|
<Row>
|
|
|
|
<FreeResponseResolutionOrChance
|
|
|
|
contract={contract}
|
|
|
|
truncate="none"
|
|
|
|
/>
|
|
|
|
<ContractReportResolution contract={contract} />
|
|
|
|
</Row>
|
2022-05-19 17:42:03 +00:00
|
|
|
)}
|
2022-03-21 21:19:08 +00:00
|
|
|
</Col>
|
2022-09-30 23:57:48 +00:00
|
|
|
<SizedContractChart
|
|
|
|
contract={contract}
|
|
|
|
bets={bets}
|
|
|
|
fullHeight={350}
|
|
|
|
mobileHeight={250}
|
|
|
|
/>
|
2022-09-01 21:42:50 +00:00
|
|
|
</Col>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
const PseudoNumericOverview = (props: {
|
|
|
|
contract: PseudoNumericContract
|
|
|
|
bets: Bet[]
|
|
|
|
}) => {
|
|
|
|
const { contract, bets } = props
|
|
|
|
return (
|
|
|
|
<Col className="gap-1 md:gap-2">
|
|
|
|
<Col className="gap-3 px-2 sm:gap-4">
|
|
|
|
<ContractDetails contract={contract} />
|
|
|
|
<Row className="justify-between gap-4">
|
|
|
|
<OverviewQuestion text={contract.question} />
|
|
|
|
<PseudoNumericResolutionOrExpectation
|
2022-08-30 23:13:25 +00:00
|
|
|
contract={contract}
|
2022-09-01 21:42:50 +00:00
|
|
|
className="hidden items-end xl:flex"
|
2022-08-30 23:13:25 +00:00
|
|
|
/>
|
2022-09-01 21:42:50 +00:00
|
|
|
</Row>
|
|
|
|
<Row className="items-center justify-between gap-4 xl:hidden">
|
|
|
|
<PseudoNumericResolutionOrExpectation contract={contract} />
|
|
|
|
{tradingAllowed(contract) && <BetWidget contract={contract} />}
|
|
|
|
</Row>
|
|
|
|
</Col>
|
2022-09-30 23:57:48 +00:00
|
|
|
<SizedContractChart
|
|
|
|
contract={contract}
|
|
|
|
bets={bets}
|
|
|
|
fullHeight={250}
|
|
|
|
mobileHeight={150}
|
|
|
|
/>
|
2021-12-10 14:56:17 +00:00
|
|
|
</Col>
|
|
|
|
)
|
|
|
|
}
|
2022-09-01 21:42:50 +00:00
|
|
|
|
|
|
|
export const ContractOverview = (props: {
|
|
|
|
contract: Contract
|
|
|
|
bets: Bet[]
|
|
|
|
}) => {
|
|
|
|
const { contract, bets } = props
|
|
|
|
switch (contract.outcomeType) {
|
|
|
|
case 'BINARY':
|
|
|
|
return <BinaryOverview contract={contract} bets={bets} />
|
|
|
|
case 'NUMERIC':
|
2022-09-30 23:57:48 +00:00
|
|
|
return <NumericOverview contract={contract} bets={bets} />
|
2022-09-01 21:42:50 +00:00
|
|
|
case 'PSEUDO_NUMERIC':
|
|
|
|
return <PseudoNumericOverview contract={contract} bets={bets} />
|
|
|
|
case 'FREE_RESPONSE':
|
|
|
|
case 'MULTIPLE_CHOICE':
|
|
|
|
return <ChoiceOverview contract={contract} bets={bets} />
|
|
|
|
}
|
|
|
|
}
|