import { useState } from 'react' import { BetPanelSwitcher } from './bet-panel' import { Row } from './layout/row' import { YesNoSelector } from './yes-no-selector' import { Binary, CPMM, DPM, FullContract } from '../../common/contract' import { Modal } from './layout/modal' import { SellButton } from './sell-button' import { useUser } from '../hooks/use-user' import { useUserContractBets } from '../hooks/use-user-bets' import { useSaveShares } from './use-save-shares' // Inline version of a bet panel. Opens BetPanel in a new modal. export default function BetRow(props: { contract: FullContract className?: string labelClassName?: string }) { const { className, labelClassName, contract } = props const [open, setOpen] = useState(false) const [betChoice, setBetChoice] = useState<'YES' | 'NO' | undefined>( undefined ) const user = useUser() const userBets = useUserContractBets(user?.id, contract.id) const { yesFloorShares, noFloorShares } = useSaveShares(contract, userBets) return ( <>
{/*
Place a trade
*/} { setOpen(true) setBetChoice(choice) }} replaceNoButton={ yesFloorShares > noFloorShares && yesFloorShares > 0 ? ( ) : undefined } replaceYesButton={ noFloorShares > yesFloorShares && noFloorShares > 0 ? ( ) : undefined } />
setOpen(false)} />
) }