diff --git a/web/components/bet-panel.tsx b/web/components/bet-panel.tsx index 99bb1259..677d540c 100644 --- a/web/components/bet-panel.tsx +++ b/web/components/bet-panel.tsx @@ -60,6 +60,13 @@ export function BetPanel(props: { const sharesOutcome = yesShares ? 'YES' : noShares ? 'NO' : undefined + useEffect(() => { + // Switch back to BUY if the user has sold all their shares. + if (tradeType === 'SELL' && sharesOutcome === undefined) { + setTradeType('BUY') + } + }, [tradeType, sharesOutcome]) + return ( {sharesOutcome && mechanism === 'cpmm-1' && ( @@ -326,7 +333,7 @@ function SellPanel(props: { const { contract, shares, sharesOutcome, userBets, user, onSellSuccess } = props - const [amount, setAmount] = useState(Math.floor(shares)) + const [amount, setAmount] = useState(shares) const [error, setError] = useState() const [isSubmitting, setIsSubmitting] = useState(false) const [wasSubmitted, setWasSubmitted] = useState(false) @@ -370,7 +377,7 @@ function SellPanel(props: {