From 4b116a5b96db0d77b2f338aeea8a0851ec173c3a Mon Sep 17 00:00:00 2001 From: Marshall Polaris Date: Tue, 26 Jul 2022 01:20:13 -0700 Subject: [PATCH] Sell all shares properly on bet panel UI --- web/components/bet-panel.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/web/components/bet-panel.tsx b/web/components/bet-panel.tsx index 4d27918b..aea38c86 100644 --- a/web/components/bet-panel.tsx +++ b/web/components/bet-panel.tsx @@ -771,7 +771,9 @@ export function SellPanel(props: { const betDisabled = isSubmitting || !amount || error // Sell all shares if remaining shares would be < 1 - const sellQuantity = amount === Math.floor(shares) ? shares : amount + const isSellingAllShares = amount === Math.floor(shares) + + const sellQuantity = isSellingAllShares ? shares : amount async function submitSell() { if (!user || !amount) return @@ -780,7 +782,7 @@ export function SellPanel(props: { setIsSubmitting(true) await sellShares({ - shares: sellQuantity, + shares: isSellingAllShares ? undefined : amount, outcome: sharesOutcome, contractId: contract.id, })