import React, { useState } from 'react' import { Contract } from '../lib/firebase/contracts' import { Col } from './layout/col' import { Row } from './layout/row' import { Spacer } from './layout/spacer' import { YesNoSelector } from './yes-no-selector' export function BetPanel(props: { contract: Contract; className?: string }) { const { contract, className } = props const [betChoice, setBetChoice] = useState<'YES' | 'NO'>('YES') const [betAmount, setBetAmount] = useState(undefined) function onBetChange(str: string) { const amount = parseInt(str) setBetAmount(isNaN(amount) ? undefined : amount) } return (
Pick outcome
Bet amount
onBetChange(e.target.value)} />
points
{!!betAmount && ( <>
Average price
{betChoice === 'YES' ? 0.57 : 0.43} points
Estimated winnings
{Math.floor(betAmount / (betChoice === 'YES' ? 0.57 : 0.43))} points
)} ) }