diff --git a/web/components/bet-row.tsx b/web/components/bet-row.tsx
index e1b99c3a..60e9e11a 100644
--- a/web/components/bet-row.tsx
+++ b/web/components/bet-row.tsx
@@ -1,11 +1,14 @@
import clsx from 'clsx'
import { useState } from 'react'
-import { BetPanelSwitcher } from './bet-panel'
+import { BetPanelSwitcher, useSaveShares } from './bet-panel'
import { Row } from './layout/row'
import { YesNoSelector } from './yes-no-selector'
import { Binary, CPMM, DPM, FullContract } from '../../common/contract'
import { Modal } from './layout/modal'
+import { SellRow } from './sell-row'
+import { useUser } from '../hooks/use-user'
+import { useUserContractBets } from '../hooks/use-user-bets'
// Inline version of a bet panel. Opens BetPanel in a new modal.
export default function BetRow(props: {
@@ -18,11 +21,17 @@ export default function BetRow(props: {
const [betChoice, setBetChoice] = useState<'YES' | 'NO' | undefined>(
undefined
)
+ const user = useUser()
+ const userBets = useUserContractBets(user?.id, props.contract.id)
+ const { yesFloorShares, noFloorShares } = useSaveShares(
+ props.contract,
+ userBets
+ )
return (
<>
-
+
{/*
Place a trade
*/}
@@ -32,6 +41,24 @@ export default function BetRow(props: {
setOpen(true)
setBetChoice(choice)
}}
+ replaceNoButton={
+ yesFloorShares > noFloorShares && yesFloorShares > 0 ? (
+
+ ) : undefined
+ }
+ replaceYesButton={
+ noFloorShares > yesFloorShares && noFloorShares > 0 ? (
+
+ ) : undefined
+ }
/>
diff --git a/web/components/sell-row.tsx b/web/components/sell-row.tsx
index de562a63..bceffa72 100644
--- a/web/components/sell-row.tsx
+++ b/web/components/sell-row.tsx
@@ -10,11 +10,13 @@ import { Modal } from './layout/modal'
import { Title } from './title'
import { SellPanel, useSaveShares } from './bet-panel'
import { useUserContractBets } from '../hooks/use-user-bets'
+import clsx from 'clsx'
export function SellRow(props: {
contract: FullContract
user: User | null | undefined
className?: string
+ buttonOnly?: boolean
}) {
const { className } = props
@@ -22,54 +24,81 @@ export function SellRow(props: {
const [showSellModal, setShowSellModal] = useState(false)
const { mechanism } = props.contract
- const { yesShares, noShares } = useSaveShares(props.contract, userBets)
-
- const shares = yesShares || noShares
- const sharesOutcome = yesShares ? 'YES' : noShares ? 'NO' : undefined
-
- return (
-
- {sharesOutcome && props.user && mechanism === 'cpmm-1' && (
-
-
-
- You have {formatWithCommas(Math.floor(shares))}{' '}
- {' '}
- shares
-
+ const { yesFloorShares, noFloorShares } = useSaveShares(
+ props.contract,
+ userBets
+ )
+ const shares = yesFloorShares || noFloorShares
+ const sharesOutcome = yesFloorShares
+ ? 'YES'
+ : noFloorShares
+ ? 'NO'
+ : undefined
+ if (sharesOutcome && props.user && mechanism === 'cpmm-1') {
+ return (
+
+ {props.buttonOnly ? (
+
+
+ {'(' + shares + ' shares)'}
+
+
+ ) : (
+
+
+
+ You have {formatWithCommas(shares)}{' '}
+ {' '}
+ shares
+
- {showSellModal && (
- }
- user={props.user}
- userBets={userBets ?? []}
- shares={shares}
- sharesOutcome={sharesOutcome}
- setOpen={setShowSellModal}
- />
- )}
-
-
- //
- )}
-
- )
+
+
+
+ )}
+ {showSellModal && (
+
}
+ user={props.user}
+ userBets={userBets ?? []}
+ shares={shares}
+ sharesOutcome={sharesOutcome}
+ setOpen={setShowSellModal}
+ />
+ )}
+
+ )
+ }
+
+ return
}
function SellSharesModal(props: {