import React, { useEffect, useRef, useState } from 'react' import { tradingAllowed } from 'web/lib/firebase/contracts' import { Col } from '../layout/col' import { ContractChart } from 'web/components/charts/contract' import { useUser } from 'web/hooks/use-user' import { Row } from '../layout/row' import { Linkify } from '../linkify' import { BinaryResolutionOrChance, FreeResponseResolutionOrChance, NumericResolutionOrExpectation, PseudoNumericResolutionOrExpectation, } from './contract-card' import { Bet } from 'common/bet' import BetButton, { BinaryMobileBetting } from '../bet-button' import { Contract, CPMMContract, FreeResponseContract, MultipleChoiceContract, NumericContract, PseudoNumericContract, BinaryContract, } from 'common/contract' import { ContractDetails } from './contract-details' const OverviewQuestion = (props: { text: string }) => ( ) const BetWidget = (props: { contract: CPMMContract }) => { const user = useUser() return ( {!user && (
(with play money!)
)} ) } const SizedContractChart = (props: { contract: Contract bets: Bet[] fullHeight: number mobileHeight: number }) => { const { contract, bets, fullHeight, mobileHeight } = props const containerRef = useRef(null) const [chartWidth, setChartWidth] = useState() const [chartHeight, setChartHeight] = useState() useEffect(() => { const handleResize = () => { setChartHeight(window.innerWidth < 800 ? mobileHeight : fullHeight) setChartWidth(containerRef.current?.clientWidth) } handleResize() window.addEventListener('resize', handleResize) return () => { window.removeEventListener('resize', handleResize) } }, [fullHeight, mobileHeight]) return (
{chartWidth != null && chartHeight != null && ( )}
) } const NumericOverview = (props: { contract: NumericContract; bets: Bet[] }) => { const { contract, bets } = props return ( ) } const BinaryOverview = (props: { contract: BinaryContract; bets: Bet[] }) => { const { contract, bets } = props return ( {tradingAllowed(contract) && ( )} ) } const ChoiceOverview = (props: { contract: FreeResponseContract | MultipleChoiceContract bets: Bet[] }) => { const { contract, bets } = props const { question, resolution } = contract return ( {resolution && ( )} ) } const PseudoNumericOverview = (props: { contract: PseudoNumericContract bets: Bet[] }) => { const { contract, bets } = props return ( {tradingAllowed(contract) && } ) } export const ContractOverview = (props: { contract: Contract bets: Bet[] }) => { const { contract, bets } = props switch (contract.outcomeType) { case 'BINARY': return case 'NUMERIC': return case 'PSEUDO_NUMERIC': return case 'FREE_RESPONSE': case 'MULTIPLE_CHOICE': return } }