From 161c7ee69927c2085606ebb00c6c5dde35b4bb40 Mon Sep 17 00:00:00 2001 From: mantikoros Date: Fri, 30 Sep 2022 20:06:08 -0500 Subject: [PATCH] mobile betting in embeds --- web/components/bet-button.tsx | 36 ++++++++++++------ web/pages/embed/[username]/[contractSlug].tsx | 38 +++++-------------- 2 files changed, 34 insertions(+), 40 deletions(-) diff --git a/web/components/bet-button.tsx b/web/components/bet-button.tsx index 808b450f..95039412 100644 --- a/web/components/bet-button.tsx +++ b/web/components/bet-button.tsx @@ -79,11 +79,21 @@ export default function BetButton(props: { ) } -export function BinaryMobileBetting(props: { contract: BinaryContract }) { - const { contract } = props +export function BinaryMobileBetting(props: { + contract: BinaryContract + hideSellRow?: boolean +}) { + const { contract, hideSellRow } = props const user = useUser() + if (user) { - return + return ( + + ) } else { return } @@ -92,8 +102,9 @@ export function BinaryMobileBetting(props: { contract: BinaryContract }) { export function SignedInBinaryMobileBetting(props: { contract: BinaryContract user: User + hideSellRow?: boolean }) { - const { contract, user } = props + const { contract, user, hideSellRow } = props const unfilledBets = useUnfilledBets(contract.id) ?? [] return ( @@ -108,13 +119,16 @@ export function SignedInBinaryMobileBetting(props: { mobileView={true} /> - + + {!hideSellRow && ( + + )} ) diff --git a/web/pages/embed/[username]/[contractSlug].tsx b/web/pages/embed/[username]/[contractSlug].tsx index e925a1f6..f32ee325 100644 --- a/web/pages/embed/[username]/[contractSlug].tsx +++ b/web/pages/embed/[username]/[contractSlug].tsx @@ -1,9 +1,6 @@ import { Bet } from 'common/bet' import { Contract } from 'common/contract' import { DOMAIN } from 'common/envs/constants' -import { useState } from 'react' -import { BetInline } from 'web/components/bet-inline' -import { Button } from 'web/components/button' import { BinaryResolutionOrChance, FreeResponseResolutionOrChance, @@ -27,6 +24,7 @@ import { tradingAllowed, } from 'web/lib/firebase/contracts' import Custom404 from '../../404' +import { BinaryMobileBetting } from 'web/components/bet-button' export const getStaticProps = fromPropz(getStaticPropz) export async function getStaticPropz(props: { @@ -81,19 +79,13 @@ export function ContractEmbed(props: { contract: Contract; bets: Bet[] }) { const { setElem, height: graphHeight } = useMeasureSize() - const [betPanelOpen, setBetPanelOpen] = useState(false) - - const [probAfter, setProbAfter] = useState() - return ( - +
{question}
- {isBinary && ( - - )} + {isBinary && } {isPseudoNumeric && ( @@ -107,33 +99,21 @@ export function ContractEmbed(props: { contract: Contract; bets: Bet[] }) { )}
- - - {(isBinary || isPseudoNumeric) && - tradingAllowed(contract) && - !betPanelOpen && ( - - )} - {(isBinary || isPseudoNumeric) && betPanelOpen && ( - setBetPanelOpen(false)} - className="self-center" - /> - )} -
+ + + {isBinary && tradingAllowed(contract) && ( + + )} + ) }