bet panel: error handling
This commit is contained in:
parent
a07d29b881
commit
3ee03ffcba
|
@ -63,12 +63,18 @@ export function BetPanel(props: { contract: Contract; className?: string }) {
|
||||||
amount: betAmount,
|
amount: betAmount,
|
||||||
outcome: betChoice,
|
outcome: betChoice,
|
||||||
contractId: contract.id,
|
contractId: contract.id,
|
||||||
})
|
}).then(r => r.data as any)
|
||||||
|
|
||||||
console.log('placed bet. Result:', result)
|
console.log('placed bet. Result:', result)
|
||||||
|
|
||||||
setIsSubmitting(false)
|
if (result?.status === 'success') {
|
||||||
setWasSubmitted(true)
|
setIsSubmitting(false)
|
||||||
setBetAmount(undefined)
|
setWasSubmitted(true)
|
||||||
|
setBetAmount(undefined)
|
||||||
|
} else {
|
||||||
|
setError(result?.error || 'Error placing bet')
|
||||||
|
setIsSubmitting(false)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const betDisabled = isSubmitting || !betAmount || error
|
const betDisabled = isSubmitting || !betAmount || error
|
||||||
|
@ -144,8 +150,8 @@ export function BetPanel(props: { contract: Contract; className?: string }) {
|
||||||
betDisabled
|
betDisabled
|
||||||
? 'btn-disabled'
|
? 'btn-disabled'
|
||||||
: betChoice === 'YES'
|
: betChoice === 'YES'
|
||||||
? 'btn-primary'
|
? 'btn-primary'
|
||||||
: 'bg-red-400 hover:bg-red-500 border-none',
|
: 'bg-red-400 hover:bg-red-500 border-none',
|
||||||
isSubmitting ? 'loading' : ''
|
isSubmitting ? 'loading' : ''
|
||||||
)}
|
)}
|
||||||
onClick={betDisabled ? undefined : submitBet}
|
onClick={betDisabled ? undefined : submitBet}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user