From 38aad405691875eb11d2c67b49d2b14ac41f4f21 Mon Sep 17 00:00:00 2001 From: mantikoros <95266179+mantikoros@users.noreply.github.com> Date: Tue, 12 Jul 2022 17:34:10 -0500 Subject: [PATCH] Simplify bet buttons (#644) * mono-button bet row * "bet yes" => "yes" * prettier --- web/components/bet-panel.tsx | 15 +++++++- web/components/bet-row.tsx | 61 ++++++++++++------------------ web/components/limit-bets.tsx | 4 +- web/components/yes-no-selector.tsx | 4 +- 4 files changed, 42 insertions(+), 42 deletions(-) diff --git a/web/components/bet-panel.tsx b/web/components/bet-panel.tsx index 6279fe2f..91c6fe00 100644 --- a/web/components/bet-panel.tsx +++ b/web/components/bet-panel.tsx @@ -109,9 +109,10 @@ export function SimpleBetPanel(props: { contract: CPMMBinaryContract | PseudoNumericContract className?: string selected?: 'YES' | 'NO' + hasShares?: boolean onBetSuccess?: () => void }) { - const { contract, className, selected, onBetSuccess } = props + const { contract, className, selected, hasShares, onBetSuccess } = props const user = useUser() const [isLimitOrder, setIsLimitOrder] = useState(false) @@ -121,7 +122,17 @@ export function SimpleBetPanel(props: { return ( - + +
{isLimitOrder ? <>Limit order : <>Place your bet} diff --git a/web/components/bet-row.tsx b/web/components/bet-row.tsx index 712d4a2c..f8624130 100644 --- a/web/components/bet-row.tsx +++ b/web/components/bet-row.tsx @@ -2,13 +2,12 @@ import { useState } from 'react' import clsx from 'clsx' import { SimpleBetPanel } from './bet-panel' -import { YesNoSelector } from './yes-no-selector' import { CPMMBinaryContract, PseudoNumericContract } from 'common/contract' import { Modal } from './layout/modal' -import { SellButton } from './sell-button' import { useUser } from 'web/hooks/use-user' import { useUserContractBets } from 'web/hooks/use-user-bets' import { useSaveBinaryShares } from './use-save-binary-shares' +import { Col } from './layout/col' // Inline version of a bet panel. Opens BetPanel in a new modal. export default function BetRow(props: { @@ -19,9 +18,7 @@ export default function BetRow(props: { }) { const { className, btnClassName, betPanelClassName, contract } = props const [open, setOpen] = useState(false) - const [betChoice, setBetChoice] = useState<'YES' | 'NO' | undefined>( - undefined - ) + const user = useUser() const userBets = useUserContractBets(user?.id, contract.id) const { yesShares, noShares, hasYesShares, hasNoShares } = @@ -29,43 +26,33 @@ export default function BetRow(props: { return ( <> - { - setOpen(true) - setBetChoice(choice) - }} - replaceNoButton={ - hasYesShares ? ( - - ) : undefined - } - replaceYesButton={ - hasNoShares ? ( - - ) : undefined - } - /> + + + +
+ {hasYesShares + ? `(${Math.floor(yesShares)} YES)` + : hasNoShares + ? `(${Math.floor(noShares)} NO)` + : ''} +
+ + setOpen(false)} + hasShares={hasYesShares || hasNoShares} /> diff --git a/web/components/limit-bets.tsx b/web/components/limit-bets.tsx index 22ac115e..503b3d17 100644 --- a/web/components/limit-bets.tsx +++ b/web/components/limit-bets.tsx @@ -30,7 +30,9 @@ export function LimitBets(props: { 'gap-2 overflow-hidden rounded bg-white px-4 py-3' )} > - {!hideLabel &&
Your limit orders
} + {!hideLabel && ( +
Your limit orders
+ )} {recentBets.map((bet) => ( diff --git a/web/components/yes-no-selector.tsx b/web/components/yes-no-selector.tsx index cac7bf74..3b3cc21d 100644 --- a/web/components/yes-no-selector.tsx +++ b/web/components/yes-no-selector.tsx @@ -43,7 +43,7 @@ export function YesNoSelector(props: { )} onClick={() => onSelect('YES')} > - {isPseudoNumeric ? 'HIGHER' : 'Bet YES'} + {isPseudoNumeric ? 'HIGHER' : 'YES'} )} {replaceNoButton ? ( @@ -60,7 +60,7 @@ export function YesNoSelector(props: { )} onClick={() => onSelect('NO')} > - {isPseudoNumeric ? 'LOWER' : 'Bet NO'} + {isPseudoNumeric ? 'LOWER' : 'NO'} )}