import { useState } from 'react' import clsx from 'clsx' import { SimpleBetPanel } from './bet-panel' import { YesNoSelector } from './yes-no-selector' import { CPMMBinaryContract, PseudoNumericContract } from 'common/contract' import { Modal } from './layout/modal' import { SellButton } from './sell-button' import { useUser } from 'web/hooks/use-user' import { useUserContractBets } from 'web/hooks/use-user-bets' import { useSaveBinaryShares } from './use-save-binary-shares' // Inline version of a bet panel. Opens BetPanel in a new modal. export default function BetRow(props: { contract: CPMMBinaryContract | PseudoNumericContract className?: string btnClassName?: string betPanelClassName?: string }) { const { className, btnClassName, betPanelClassName, 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 { yesShares, noShares, hasYesShares, hasNoShares } = useSaveBinaryShares(contract, userBets) return ( <> { setOpen(true) setBetChoice(choice) }} replaceNoButton={ hasYesShares ? ( ) : undefined } replaceYesButton={ hasNoShares ? ( ) : undefined } /> setOpen(false)} /> ) }