mobile betting in embeds
This commit is contained in:
		
							parent
							
								
									17d1b8575c
								
							
						
					
					
						commit
						161c7ee699
					
				|  | @ -79,11 +79,21 @@ export default function BetButton(props: { | ||||||
|   ) |   ) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export function BinaryMobileBetting(props: { contract: BinaryContract }) { | export function BinaryMobileBetting(props: { | ||||||
|   const { contract } = props |   contract: BinaryContract | ||||||
|  |   hideSellRow?: boolean | ||||||
|  | }) { | ||||||
|  |   const { contract, hideSellRow } = props | ||||||
|   const user = useUser() |   const user = useUser() | ||||||
|  | 
 | ||||||
|   if (user) { |   if (user) { | ||||||
|     return <SignedInBinaryMobileBetting contract={contract} user={user} /> |     return ( | ||||||
|  |       <SignedInBinaryMobileBetting | ||||||
|  |         contract={contract} | ||||||
|  |         user={user} | ||||||
|  |         hideSellRow={hideSellRow} | ||||||
|  |       /> | ||||||
|  |     ) | ||||||
|   } else { |   } else { | ||||||
|     return <BetSignUpPrompt className="w-full" /> |     return <BetSignUpPrompt className="w-full" /> | ||||||
|   } |   } | ||||||
|  | @ -92,8 +102,9 @@ export function BinaryMobileBetting(props: { contract: BinaryContract }) { | ||||||
| export function SignedInBinaryMobileBetting(props: { | export function SignedInBinaryMobileBetting(props: { | ||||||
|   contract: BinaryContract |   contract: BinaryContract | ||||||
|   user: User |   user: User | ||||||
|  |   hideSellRow?: boolean | ||||||
| }) { | }) { | ||||||
|   const { contract, user } = props |   const { contract, user, hideSellRow } = props | ||||||
|   const unfilledBets = useUnfilledBets(contract.id) ?? [] |   const unfilledBets = useUnfilledBets(contract.id) ?? [] | ||||||
| 
 | 
 | ||||||
|   return ( |   return ( | ||||||
|  | @ -108,6 +119,8 @@ export function SignedInBinaryMobileBetting(props: { | ||||||
|             mobileView={true} |             mobileView={true} | ||||||
|           /> |           /> | ||||||
|         </Col> |         </Col> | ||||||
|  | 
 | ||||||
|  |         {!hideSellRow && ( | ||||||
|           <SellRow |           <SellRow | ||||||
|             contract={contract} |             contract={contract} | ||||||
|             user={user} |             user={user} | ||||||
|  | @ -115,6 +128,7 @@ export function SignedInBinaryMobileBetting(props: { | ||||||
|               'border-greyscale-3 bg-greyscale-1 rounded-md border-2 px-4 py-2' |               'border-greyscale-3 bg-greyscale-1 rounded-md border-2 px-4 py-2' | ||||||
|             } |             } | ||||||
|           /> |           /> | ||||||
|  |         )} | ||||||
|       </Col> |       </Col> | ||||||
|     </> |     </> | ||||||
|   ) |   ) | ||||||
|  |  | ||||||
|  | @ -1,9 +1,6 @@ | ||||||
| import { Bet } from 'common/bet' | import { Bet } from 'common/bet' | ||||||
| import { Contract } from 'common/contract' | import { Contract } from 'common/contract' | ||||||
| import { DOMAIN } from 'common/envs/constants' | import { DOMAIN } from 'common/envs/constants' | ||||||
| import { useState } from 'react' |  | ||||||
| import { BetInline } from 'web/components/bet-inline' |  | ||||||
| import { Button } from 'web/components/button' |  | ||||||
| import { | import { | ||||||
|   BinaryResolutionOrChance, |   BinaryResolutionOrChance, | ||||||
|   FreeResponseResolutionOrChance, |   FreeResponseResolutionOrChance, | ||||||
|  | @ -27,6 +24,7 @@ import { | ||||||
|   tradingAllowed, |   tradingAllowed, | ||||||
| } from 'web/lib/firebase/contracts' | } from 'web/lib/firebase/contracts' | ||||||
| import Custom404 from '../../404' | import Custom404 from '../../404' | ||||||
|  | import { BinaryMobileBetting } from 'web/components/bet-button' | ||||||
| 
 | 
 | ||||||
| export const getStaticProps = fromPropz(getStaticPropz) | export const getStaticProps = fromPropz(getStaticPropz) | ||||||
| export async function getStaticPropz(props: { | export async function getStaticPropz(props: { | ||||||
|  | @ -81,19 +79,13 @@ export function ContractEmbed(props: { contract: Contract; bets: Bet[] }) { | ||||||
| 
 | 
 | ||||||
|   const { setElem, height: graphHeight } = useMeasureSize() |   const { setElem, height: graphHeight } = useMeasureSize() | ||||||
| 
 | 
 | ||||||
|   const [betPanelOpen, setBetPanelOpen] = useState(false) |  | ||||||
| 
 |  | ||||||
|   const [probAfter, setProbAfter] = useState<number>() |  | ||||||
| 
 |  | ||||||
|   return ( |   return ( | ||||||
|     <Col className="h-[100vh] w-full bg-white"> |     <Col className="h-[100vh] w-full bg-white"> | ||||||
|       <Row className="justify-between gap-4 px-2"> |       <Row className="mt-1 justify-between gap-4 px-2"> | ||||||
|         <div className="text-xl text-indigo-700 md:text-2xl"> |         <div className="text-xl text-indigo-700 md:text-2xl"> | ||||||
|           <SiteLink href={href}>{question}</SiteLink> |           <SiteLink href={href}>{question}</SiteLink> | ||||||
|         </div> |         </div> | ||||||
|         {isBinary && ( |         {isBinary && <BinaryResolutionOrChance contract={contract} />} | ||||||
|           <BinaryResolutionOrChance contract={contract} probAfter={probAfter} /> |  | ||||||
|         )} |  | ||||||
| 
 | 
 | ||||||
|         {isPseudoNumeric && ( |         {isPseudoNumeric && ( | ||||||
|           <PseudoNumericResolutionOrExpectation contract={contract} /> |           <PseudoNumericResolutionOrExpectation contract={contract} /> | ||||||
|  | @ -107,33 +99,21 @@ export function ContractEmbed(props: { contract: Contract; bets: Bet[] }) { | ||||||
|           <NumericResolutionOrExpectation contract={contract} /> |           <NumericResolutionOrExpectation contract={contract} /> | ||||||
|         )} |         )} | ||||||
|       </Row> |       </Row> | ||||||
|       <Spacer h={3} /> |  | ||||||
|       <Row className="items-center justify-between gap-4 px-2"> |       <Row className="items-center justify-between gap-4 px-2"> | ||||||
|         <MarketSubheader contract={contract} disabled /> |         <MarketSubheader contract={contract} disabled /> | ||||||
| 
 |  | ||||||
|         {(isBinary || isPseudoNumeric) && |  | ||||||
|           tradingAllowed(contract) && |  | ||||||
|           !betPanelOpen && ( |  | ||||||
|             <Button color="gradient" onClick={() => setBetPanelOpen(true)}> |  | ||||||
|               Predict |  | ||||||
|             </Button> |  | ||||||
|           )} |  | ||||||
|       </Row> |       </Row> | ||||||
| 
 | 
 | ||||||
|       <Spacer h={2} /> |       <Spacer h={2} /> | ||||||
| 
 | 
 | ||||||
|       {(isBinary || isPseudoNumeric) && betPanelOpen && ( |  | ||||||
|         <BetInline |  | ||||||
|           contract={contract as any} |  | ||||||
|           setProbAfter={setProbAfter} |  | ||||||
|           onClose={() => setBetPanelOpen(false)} |  | ||||||
|           className="self-center" |  | ||||||
|         /> |  | ||||||
|       )} |  | ||||||
| 
 |  | ||||||
|       <div className="mx-1 mb-2 min-h-0 flex-1" ref={setElem}> |       <div className="mx-1 mb-2 min-h-0 flex-1" ref={setElem}> | ||||||
|         <ContractChart contract={contract} bets={bets} height={graphHeight} /> |         <ContractChart contract={contract} bets={bets} height={graphHeight} /> | ||||||
|       </div> |       </div> | ||||||
|  | 
 | ||||||
|  |       <Row className="mx-8 mb-2 items-center justify-between gap-4"> | ||||||
|  |         {isBinary && tradingAllowed(contract) && ( | ||||||
|  |           <BinaryMobileBetting contract={contract} hideSellRow /> | ||||||
|  |         )} | ||||||
|  |       </Row> | ||||||
|     </Col> |     </Col> | ||||||
|   ) |   ) | ||||||
| } | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user