import { Contract } from 'web/lib/firebase/contracts' import { User } from 'web/lib/firebase/users' import { Col } from '../layout/col' import { SiteLink } from '../site-link' import { ContractCard, ContractCardProbChange } from './contract-card' import { ShowTime } from './contract-details' import { ContractSearch } from '../contract-search' import { useCallback } from 'react' import clsx from 'clsx' import { LoadingIndicator } from '../loading-indicator' import { VisibilityObserver } from '../visibility-observer' import Masonry from 'react-masonry-css' import { CPMMBinaryContract } from 'common/contract' export type CardHighlightOptions = { itemIds?: string[] highlightClassName?: string } export function ContractsGrid(props: { contracts: Contract[] | undefined loadMore?: () => void showTime?: ShowTime onContractClick?: (contract: Contract) => void cardUIOptions?: { hideQuickBet?: boolean hideGroupLink?: boolean noLinkAvatar?: boolean showProbChange?: boolean } highlightOptions?: CardHighlightOptions trackingPostfix?: string breakpointColumns?: { [key: string]: number } }) { const { contracts, showTime, loadMore, onContractClick, cardUIOptions, highlightOptions, trackingPostfix, } = props const { hideQuickBet, hideGroupLink, noLinkAvatar, showProbChange } = cardUIOptions || {} const { itemIds: contractIds, highlightClassName } = highlightOptions || {} const onVisibilityUpdated = useCallback( (visible) => { if (visible && loadMore) { loadMore() } }, [loadMore] ) if (contracts === undefined) { return } if (contracts.length === 0) { return (

No markets found. Why not{' '} create one?

) } return ( {contracts.map((contract) => showProbChange && contract.mechanism === 'cpmm-1' ? ( ) : ( onContractClick(contract) : undefined } noLinkAvatar={noLinkAvatar} hideQuickBet={hideQuickBet} hideGroupLink={hideGroupLink} trackingPostfix={trackingPostfix} className={clsx( 'mb-4 break-inside-avoid-column overflow-hidden', // prevent content from wrapping (needs overflow on firefox) contractIds?.includes(contract.id) && highlightClassName )} /> ) )} {loadMore && ( )} ) } export function CreatorContractsList(props: { user: User | null | undefined creator: User }) { const { user, creator } = props return ( ) }