bet row: auto-close dialog after a trade is submitted

This commit is contained in:
mantikoros 2022-02-05 12:26:11 -06:00
parent d0a56cd1af
commit 3baffd4a35
2 changed files with 4 additions and 1 deletions

View File

@ -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)

View File

@ -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>