Tweaks for trades page

This commit is contained in:
James Grugett 2022-02-16 00:08:05 -06:00
parent 26bb872113
commit 0f066d7e8e

View File

@ -177,10 +177,13 @@ export function BetsList(props: { user: User }) {
function MyContractBets(props: { contract: Contract; bets: Bet[] }) { function MyContractBets(props: { contract: Contract; bets: Bet[] }) {
const { bets, contract } = props const { bets, contract } = props
const { resolution } = contract const { resolution, outcomeType } = contract
const [collapsed, setCollapsed] = useState(true) const [collapsed, setCollapsed] = useState(true)
const isBinary = outcomeType === 'BINARY'
const probPercent = getBinaryProbPercent(contract) const probPercent = getBinaryProbPercent(contract)
return ( return (
<div <div
tabIndex={0} tabIndex={0}
@ -210,14 +213,18 @@ function MyContractBets(props: { contract: Contract; bets: Bet[] }) {
</Row> </Row>
<Row className="items-center gap-2 text-sm text-gray-500"> <Row className="items-center gap-2 text-sm text-gray-500">
{resolution ? ( {isBinary && (
<div> <>
Resolved <OutcomeLabel outcome={resolution} /> {resolution ? (
</div> <div>
) : ( Resolved <OutcomeLabel outcome={resolution} />
<div className="text-primary text-lg">{probPercent}</div> </div>
) : (
<div className="text-primary text-lg">{probPercent}</div>
)}
<div></div>
</>
)} )}
<div></div>
<UserLink <UserLink
name={contract.creatorName} name={contract.creatorName}
username={contract.creatorUsername} username={contract.creatorUsername}
@ -260,8 +267,8 @@ export function MyBetsSummary(props: {
className?: string className?: string
}) { }) {
const { bets, contract, onlyMKT, className } = props const { bets, contract, onlyMKT, className } = props
const { resolution } = contract const { resolution, outcomeType } = contract
calculateCancelPayout const isBinary = outcomeType === 'BINARY'
const excludeSales = bets.filter((b) => !b.isSold && !b.sale) const excludeSales = bets.filter((b) => !b.isSold && !b.sale)
const betsTotal = _.sumBy(excludeSales, (bet) => bet.amount) const betsTotal = _.sumBy(excludeSales, (bet) => bet.amount)
@ -345,10 +352,16 @@ export function MyBetsSummary(props: {
</Col> </Col>
<Col> <Col>
<div className="whitespace-nowrap text-sm text-gray-500"> <div className="whitespace-nowrap text-sm text-gray-500">
Payout at{' '} {isBinary ? (
<span className="text-blue-400"> <>
{formatPercent(getProbability(contract.totalShares))} Payout at{' '}
</span> <span className="text-blue-400">
{formatPercent(getProbability(contract.totalShares))}
</span>
</>
) : (
<>Current payout</>
)}
</div> </div>
<div className="whitespace-nowrap"> <div className="whitespace-nowrap">
{formatMoney(marketWinnings)} {formatMoney(marketWinnings)}