import {
compute,
Contract,
deleteContract,
path,
} 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 dayjs from 'dayjs'
import { Linkify } from './linkify'
import clsx from 'clsx'
import { ContractDetails, ResolutionOrChance } from './contract-card'
import { ContractFeed } from './contract-feed'
import { TweetButton } from './tweet-button'
function ContractCloseTime(props: { contract: Contract }) {
const closeTime = props.contract.closeTime
if (!closeTime) {
return null
}
return (
Trading {closeTime > Date.now() ? 'closes' : 'closed'} at{' '}
{dayjs(closeTime).format('MMM D, h:mma')}
)
}
export const ContractOverview = (props: {
contract: Contract
className?: string
}) => {
const { contract, className } = props
const { resolution, creatorId, creatorName } = contract
const { probPercent, truePool } = compute(contract)
const user = useUser()
const isCreator = user?.id === creatorId
const tweetQuestion = isCreator
? contract.question
: `${creatorName}: ${contract.question}`
const tweetDescription = resolution
? isCreator
? `Resolved ${resolution}!`
: `Resolved ${resolution} by ${creatorName}:`
: `Currently ${probPercent} chance, place your bets here:`
const url = `https://mantic.markets${path(contract)}`
const tweetText = `${tweetQuestion}\n\n${tweetDescription}\n\n${url}`
return (
{/* Show a delete button for contracts without any trading */}
{isCreator && truePool === 0 && (
<>
>
)}
)
}