Fix error state conditions
- Reset amount input on success - Reset success state on user input
This commit is contained in:
parent
b49999c077
commit
731b7a7776
|
@ -61,11 +61,19 @@ export function BetInline(props: {
|
||||||
outcome,
|
outcome,
|
||||||
isLimitOrder: false,
|
isLimitOrder: false,
|
||||||
})
|
})
|
||||||
|
setAmount(undefined)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
const betDisabled = submitBet.isLoading || submitBet.isError || !amount
|
// reset error / success state on user change
|
||||||
|
useEffect(() => {
|
||||||
|
amount && submitBet.reset()
|
||||||
|
}, [outcome, amount])
|
||||||
|
|
||||||
|
const tooFewFunds = error === 'Insufficient balance'
|
||||||
|
|
||||||
|
const betDisabled = submitBet.isLoading || tooFewFunds || !amount
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Col className={clsx('items-center', className)}>
|
<Col className={clsx('items-center', className)}>
|
||||||
|
@ -110,9 +118,7 @@ export function BetInline(props: {
|
||||||
</Row>
|
</Row>
|
||||||
{error && (
|
{error && (
|
||||||
<div className="text-error my-1 text-sm">
|
<div className="text-error my-1 text-sm">
|
||||||
{error}{' '}
|
{error} {tooFewFunds && `(${formatMoney(user?.balance ?? 0)})`}
|
||||||
{error === 'Insufficient balance' &&
|
|
||||||
`(${formatMoney(user?.balance ?? 0)})`}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</Col>
|
</Col>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user