diff --git a/web/components/amount-input.tsx b/web/components/amount-input.tsx index 9c72242f..2d85fd54 100644 --- a/web/components/amount-input.tsx +++ b/web/components/amount-input.tsx @@ -113,6 +113,8 @@ export function BuyAmountInput(props: { } else { setError(undefined) } + } else { + setError(undefined) } } diff --git a/web/components/bet-inline.tsx b/web/components/bet-inline.tsx index 9f3c6e5b..632670e7 100644 --- a/web/components/bet-inline.tsx +++ b/web/components/bet-inline.tsx @@ -14,14 +14,18 @@ import { useUnfilledBets } from 'web/hooks/use-bets' import { useUser } from 'web/hooks/use-user' import { SignUpPrompt } from './sign-up-prompt' import { getCpmmProbability } from 'common/calculate-cpmm' +import { Col } from './layout/col' +import { XIcon } from '@heroicons/react/solid' +import { formatMoney } from 'common/util/format' // adapted from bet-panel.ts export function BetInline(props: { contract: CPMMBinaryContract | PseudoNumericContract className?: string setProbAfter: (probAfter: number) => void + onClose: () => void }) { - const { contract, className, setProbAfter: setResult } = props + const { contract, className, setProbAfter, onClose } = props const user = useUser() @@ -40,7 +44,7 @@ export function BetInline(props: { unfilledBets ) const resultProb = getCpmmProbability(newPool, newP) - useEffect(() => setResult(resultProb), [resultProb]) + useEffect(() => setProbAfter(resultProb), [resultProb]) const submitBet = useMutation( () => placeBet({ outcome, amount, contractId: contract.id }), @@ -64,41 +68,53 @@ export function BetInline(props: { const betDisabled = submitBet.isLoading || submitBet.isError || !amount return ( - -
Bet
- - + +
Bet
+ + + {user && ( + )} - amount={amount} - onChange={setAmount} - error="" // handle error ourselves - setError={setError} - /> - {user && ( - + + +
+ {error && ( +
+ {error}{' '} + {error === 'Insufficient balance' && + `(${formatMoney(user?.balance ?? 0)})`} +
)} - -
+ ) } diff --git a/web/pages/embed/[username]/[contractSlug].tsx b/web/pages/embed/[username]/[contractSlug].tsx index 61a0a793..20a3c44b 100644 --- a/web/pages/embed/[username]/[contractSlug].tsx +++ b/web/pages/embed/[username]/[contractSlug].tsx @@ -149,12 +149,12 @@ export function ContractEmbed(props: { contract: Contract; bets: Bet[] }) { {(isBinary || isPseudoNumeric) && betPanelOpen && ( - - - - + setBetPanelOpen(false)} + className="self-center" + /> )}