Small fixes to existing sell shares client

This commit is contained in:
James Grugett 2022-07-09 17:23:11 -05:00
parent c00681abd8
commit 2041e39b45
2 changed files with 12 additions and 3 deletions

View File

@ -46,6 +46,8 @@ import { useUser } from 'web/hooks/use-user'
import { SellSharesModal } from './sell-modal'
import { useUnfilledBets } from 'web/hooks/use-bets'
import { LimitBet } from 'common/bet'
import { useSaveShares } from './use-save-shares'
import { floatingEqual } from 'common/util/math'
type BetSort = 'newest' | 'profit' | 'closeTime' | 'value'
type BetFilter = 'open' | 'sold' | 'closed' | 'resolved' | 'all'
@ -392,6 +394,12 @@ export function BetsSummary(props: {
const [showSellModal, setShowSellModal] = useState(false)
const user = useUser()
const sharesOutcome = floatingEqual(totalShares.YES, 0)
? floatingEqual(totalShares.NO, 0)
? undefined
: 'NO'
: 'YES'
return (
<Row className={clsx('flex-wrap gap-4 sm:flex-nowrap sm:gap-6', className)}>
<Row className="flex-wrap gap-4 sm:gap-6">
@ -471,6 +479,7 @@ export function BetsSummary(props: {
!isClosed &&
!resolution &&
hasShares &&
sharesOutcome &&
user && (
<>
<button
@ -484,8 +493,8 @@ export function BetsSummary(props: {
contract={contract}
user={user}
userBets={bets}
shares={totalShares.YES || totalShares.NO}
sharesOutcome={totalShares.YES ? 'YES' : 'NO'}
shares={totalShares[sharesOutcome]}
sharesOutcome={sharesOutcome}
setOpen={setShowSellModal}
/>
)}

View File

@ -64,7 +64,7 @@ export function SellRow(props: {
contract={contract}
user={user}
userBets={userBets ?? []}
shares={yesShares || noShares}
shares={sharesOutcome === 'YES' ? yesShares : noShares}
sharesOutcome={sharesOutcome}
setOpen={setShowSellModal}
/>