// From https://tailwindui.com/components/application-ui/lists/feeds import React, { useState } from 'react' import { BanIcon, CheckIcon, LockClosedIcon, XIcon, } from '@heroicons/react/solid' import clsx from 'clsx' import { OutcomeLabel } from '../outcome-label' import { Contract, contractMetrics, contractPath, tradingAllowed, } from 'web/lib/firebase/contracts' import { BinaryResolutionOrChance } from '../contract/contract-card' import { SiteLink } from '../site-link' import { Col } from '../layout/col' import { UserLink } from '../user-page' import BetRow from '../bet-row' import { Avatar } from '../avatar' import { ActivityItem } from './activity-items' import { useSaveSeenContract } from 'web/hooks/use-seen-contracts' import { useUser } from 'web/hooks/use-user' import { trackClick } from 'web/lib/firebase/tracking' import { DAY_MS } from 'common/util/time' import NewContractBadge from '../new-contract-badge' import { RelativeTimestamp } from '../relative-timestamp' import { FeedAnswerCommentGroup } from 'web/components/feed/feed-answer-comment-group' import { FeedCommentThread, CommentInput, } from 'web/components/feed/feed-comments' import { FeedBet } from 'web/components/feed/feed-bets' import { CPMMBinaryContract, NumericContract } from 'common/contract' import { FeedLiquidity } from './feed-liquidity' import { SignUpPrompt } from '../sign-up-prompt' import { User } from 'common/user' import { PlayMoneyDisclaimer } from '../play-money-disclaimer' export function FeedItems(props: { contract: Contract items: ActivityItem[] className?: string betRowClassName?: string user: User | null | undefined }) { const { contract, items, className, betRowClassName, user } = props const { outcomeType } = contract const [elem, setElem] = useState(null) useSaveSeenContract(elem, contract) return (
{items.map((item, activityItemIdx) => (
{activityItemIdx !== items.length - 1 || item.type === 'answergroup' ? (
))}
{!user ? ( ) : ( outcomeType === 'BINARY' && tradingAllowed(contract) && ( ) )}
) } export function FeedItem(props: { item: ActivityItem }) { const { item } = props switch (item.type) { case 'question': return case 'description': return case 'bet': return case 'liquidity': return case 'answergroup': return case 'close': return case 'resolve': return case 'commentInput': return case 'commentThread': return } } export function FeedQuestion(props: { contract: Contract contractPath?: string }) { const { contract } = props const { creatorName, creatorUsername, question, outcomeType, volume, createdTime, isResolved, } = contract const { volumeLabel } = contractMetrics(contract) const isBinary = outcomeType === 'BINARY' const isNew = createdTime > Date.now() - DAY_MS && !isResolved const user = useUser() return (
{' '} asked {/* Currently hidden on mobile; ideally we'd fit this in somewhere. */}
{isNew || volume === 0 ? ( ) : ( {volumeLabel} )}
user && trackClick(user.id, contract.id)} className="text-lg text-indigo-700 sm:text-xl" > {question} {isBinary && ( )}
) } function FeedDescription(props: { contract: Contract }) { const { contract } = props const { creatorName, creatorUsername } = contract return ( <>
{' '} created this market
) } function OutcomeIcon(props: { outcome?: string }) { const { outcome } = props switch (outcome) { case 'YES': return