Update contract title with resolution or percent chance

This commit is contained in:
jahooma 2022-01-01 22:52:55 -06:00
parent b74a0c02c5
commit 8c644da10d

View File

@ -11,7 +11,11 @@ import { useBets } from '../../hooks/use-bets'
import { Title } from '../../components/title' import { Title } from '../../components/title'
import { Spacer } from '../../components/layout/spacer' import { Spacer } from '../../components/layout/spacer'
import { User } from '../../lib/firebase/users' import { User } from '../../lib/firebase/users'
import { Contract, getContractFromSlug } from '../../lib/firebase/contracts' import {
compute,
Contract,
getContractFromSlug,
} from '../../lib/firebase/contracts'
import { SEO } from '../../components/SEO' import { SEO } from '../../components/SEO'
import { Page } from '../../components/page' import { Page } from '../../components/page'
@ -47,13 +51,18 @@ export default function ContractPage(props: {
return <div>Contract not found...</div> return <div>Contract not found...</div>
} }
const { creatorId, isResolved } = contract const { creatorId, isResolved, resolution, question } = contract
const isCreator = user?.id === creatorId const isCreator = user?.id === creatorId
const { probPercent } = compute(contract)
const title = resolution
? `Resolved ${resolution}: ${question}`
: `${probPercent} chance: ${question}`
return ( return (
<Page wide={!isResolved}> <Page wide={!isResolved}>
<SEO <SEO
title={contract.question} title={title}
description={contract.description} description={contract.description}
url={`/${props.username}/${props.slug}`} url={`/${props.username}/${props.slug}`}
/> />