import { Contract, deleteContract, contractPath, tradingAllowed, getBinaryProbPercent, } from '../lib/firebase/contracts' import { Col } from './layout/col' import { Spacer } from './layout/spacer' import { ContractProbGraph } from './contract-prob-graph' import router from 'next/router' import { useUser } from '../hooks/use-user' import { Row } from './layout/row' import { Linkify } from './linkify' import clsx from 'clsx' import { ContractDetails, ResolutionOrChance } from './contract-card' import { ContractFeed } from './contract-feed' import { TweetButton } from './tweet-button' import { Bet } from '../../common/bet' import { Comment } from '../../common/comment' import { RevealableTagsInput, TagsInput } from './tags-input' import BetRow from './bet-row' import { Fold } from '../../common/fold' import { FoldTagList } from './tags-list' export const ContractOverview = (props: { contract: Contract bets: Bet[] comments: Comment[] folds: Fold[] children?: any className?: string }) => { const { contract, bets, comments, folds, children, className } = props const { question, resolution, creatorId, outcomeType } = contract const user = useUser() const isCreator = user?.id === creatorId const isBinary = outcomeType === 'BINARY' const tweetText = getTweetText(contract, isCreator) return (
{(isBinary || resolution) && ( )} {isBinary && tradingAllowed(contract) && ( )} {(isBinary || resolution) && ( )}
{isBinary && } {children} {folds.length === 0 ? ( ) : ( )} {folds.length === 0 ? ( ) : ( )} {folds.length > 0 && ( )} {/* Show a delete button for contracts without any trading */} {isCreator && bets.length === 0 && ( <> )} ) } const getTweetText = (contract: Contract, isCreator: boolean) => { const { question, creatorName, resolution, outcomeType } = contract const isBinary = outcomeType === 'BINARY' const tweetQuestion = isCreator ? question : `${question} Asked by ${creatorName}.` const tweetDescription = resolution ? `Resolved ${resolution}!` : isBinary ? `Currently ${getBinaryProbPercent( contract )} chance, place your bets here:` : `Submit your own answer:` const url = `https://manifold.markets${contractPath(contract)}` return `${tweetQuestion}\n\n${tweetDescription}\n\n${url}` }