bet row: auto-close dialog after a trade is submitted
This commit is contained in:
parent
d0a56cd1af
commit
3baffd4a35
|
@ -41,13 +41,14 @@ export function BetPanel(props: {
|
||||||
className?: string
|
className?: string
|
||||||
title?: string // Set if BetPanel is on a feed modal
|
title?: string // Set if BetPanel is on a feed modal
|
||||||
selected?: 'YES' | 'NO'
|
selected?: 'YES' | 'NO'
|
||||||
|
onBetSuccess?: () => void
|
||||||
}) {
|
}) {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// warm up cloud function
|
// warm up cloud function
|
||||||
placeBet({}).catch()
|
placeBet({}).catch()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const { contract, className, title, selected } = props
|
const { contract, className, title, selected, onBetSuccess } = props
|
||||||
|
|
||||||
const user = useUser()
|
const user = useUser()
|
||||||
|
|
||||||
|
@ -96,6 +97,7 @@ export function BetPanel(props: {
|
||||||
setIsSubmitting(false)
|
setIsSubmitting(false)
|
||||||
setWasSubmitted(true)
|
setWasSubmitted(true)
|
||||||
setBetAmount(undefined)
|
setBetAmount(undefined)
|
||||||
|
if (onBetSuccess) onBetSuccess()
|
||||||
} else {
|
} else {
|
||||||
setError(result?.error || 'Error placing bet')
|
setError(result?.error || 'Error placing bet')
|
||||||
setIsSubmitting(false)
|
setIsSubmitting(false)
|
||||||
|
|
|
@ -38,6 +38,7 @@ export default function BetRow(props: {
|
||||||
contract={props.contract}
|
contract={props.contract}
|
||||||
title={props.contract.question}
|
title={props.contract.question}
|
||||||
selected={betChoice}
|
selected={betChoice}
|
||||||
|
onBetSuccess={() => setOpen(false)}
|
||||||
/>
|
/>
|
||||||
</Modal>
|
</Modal>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user