import { Binary, CPMM, DPM, FullContract } from '../../common/contract' import { User } from '../../common/user' import { useUserContractBets } from '../hooks/use-user-bets' import { useState } from 'react' import { useSaveShares } from './use-save-shares' import { Col } from './layout/col' import clsx from 'clsx' import { SellSharesModal } from './sell-modal' export function SellButton(props: { contract: FullContract user: User | null | undefined }) { const { contract, user } = props const userBets = useUserContractBets(user?.id, contract.id) const [showSellModal, setShowSellModal] = useState(false) const { mechanism } = contract const { yesFloorShares, noFloorShares, yesShares, noShares } = useSaveShares( contract, userBets ) const floorShares = yesFloorShares || noFloorShares const sharesOutcome = yesFloorShares ? 'YES' : noFloorShares ? 'NO' : undefined if (sharesOutcome && user && mechanism === 'cpmm-1') { return (
{'(' + floorShares + ' shares)'}
{showSellModal && ( } user={user} userBets={userBets ?? []} shares={yesShares || noShares} sharesOutcome={sharesOutcome} setOpen={setShowSellModal} /> )} ) } return
}