Turn small embeds into contract cards
- kinda worried about loading time here, since Next can't cache
This commit is contained in:
parent
4fc7813a7b
commit
cae35bc05e
|
@ -6,6 +6,7 @@ import { BetInline } from 'web/components/bet-inline'
|
||||||
import { Button } from 'web/components/button'
|
import { Button } from 'web/components/button'
|
||||||
import {
|
import {
|
||||||
BinaryResolutionOrChance,
|
BinaryResolutionOrChance,
|
||||||
|
ContractCard,
|
||||||
FreeResponseResolutionOrChance,
|
FreeResponseResolutionOrChance,
|
||||||
NumericResolutionOrExpectation,
|
NumericResolutionOrExpectation,
|
||||||
PseudoNumericResolutionOrExpectation,
|
PseudoNumericResolutionOrExpectation,
|
||||||
|
@ -27,6 +28,7 @@ import {
|
||||||
tradingAllowed,
|
tradingAllowed,
|
||||||
} from 'web/lib/firebase/contracts'
|
} from 'web/lib/firebase/contracts'
|
||||||
import Custom404 from '../../404'
|
import Custom404 from '../../404'
|
||||||
|
import { useWindowSize } from 'web/hooks/use-window-size'
|
||||||
|
|
||||||
export const getStaticProps = fromPropz(getStaticPropz)
|
export const getStaticProps = fromPropz(getStaticPropz)
|
||||||
export async function getStaticPropz(props: {
|
export async function getStaticPropz(props: {
|
||||||
|
@ -64,16 +66,31 @@ export default function ContractEmbedPage(props: {
|
||||||
return <ContractEmbed contract={contract} bets={bets} />
|
return <ContractEmbed contract={contract} bets={bets} />
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ContractEmbed(props: { contract: Contract; bets: Bet[] }) {
|
interface EmbedProps {
|
||||||
const { contract, bets } = props
|
contract: Contract
|
||||||
const { question, outcomeType } = contract
|
bets: Bet[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export function ContractEmbed(props: EmbedProps) {
|
||||||
|
const { contract } = props
|
||||||
useTracking('view market embed', {
|
useTracking('view market embed', {
|
||||||
slug: contract.slug,
|
slug: contract.slug,
|
||||||
contractId: contract.id,
|
contractId: contract.id,
|
||||||
creatorId: contract.creatorId,
|
creatorId: contract.creatorId,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const { height = 0 } = useWindowSize()
|
||||||
|
|
||||||
|
return height < 250 ? (
|
||||||
|
<ContractCard contract={contract} className="h-screen" />
|
||||||
|
) : (
|
||||||
|
<ContractSmolView {...props} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function ContractSmolView({ contract, bets }: EmbedProps) {
|
||||||
|
const { question, outcomeType } = contract
|
||||||
|
|
||||||
const isBinary = outcomeType === 'BINARY'
|
const isBinary = outcomeType === 'BINARY'
|
||||||
const isPseudoNumeric = outcomeType === 'PSEUDO_NUMERIC'
|
const isPseudoNumeric = outcomeType === 'PSEUDO_NUMERIC'
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user