Prevent trading after contract has closed
This commit is contained in:
parent
bb5c74736d
commit
44417a07ad
|
@ -16,6 +16,19 @@ import { Linkify } from './linkify'
|
||||||
import clsx from 'clsx'
|
import clsx from 'clsx'
|
||||||
import { ContractDetails, ResolutionOrChance } from './contract-card'
|
import { ContractDetails, ResolutionOrChance } from './contract-card'
|
||||||
|
|
||||||
|
function ContractCloseTime(props: { contract: Contract }) {
|
||||||
|
const closeTime = props.contract.closeTime
|
||||||
|
if (!closeTime) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div className="text-gray-500 text-sm">
|
||||||
|
Trading {closeTime > Date.now() ? 'closes' : 'closed'} at{' '}
|
||||||
|
{dayjs(closeTime).format('MMM D, h:mma')}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
function ContractDescription(props: {
|
function ContractDescription(props: {
|
||||||
contract: Contract
|
contract: Contract
|
||||||
isCreator: boolean
|
isCreator: boolean
|
||||||
|
@ -127,9 +140,14 @@ export const ContractOverview = (props: {
|
||||||
|
|
||||||
<Spacer h={12} />
|
<Spacer h={12} />
|
||||||
|
|
||||||
|
<ContractCloseTime contract={contract} />
|
||||||
|
|
||||||
|
<Spacer h={4} />
|
||||||
|
|
||||||
{((isCreator && !contract.resolution) || contract.description) && (
|
{((isCreator && !contract.resolution) || contract.description) && (
|
||||||
<label className="text-gray-500 mb-2 text-sm">Description</label>
|
<label className="text-gray-500 mb-2 text-sm">Description</label>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<ContractDescription contract={contract} isCreator={isCreator} />
|
<ContractDescription contract={contract} isCreator={isCreator} />
|
||||||
|
|
||||||
{/* Show a delete button for contracts without any trading */}
|
{/* Show a delete button for contracts without any trading */}
|
||||||
|
|
|
@ -53,6 +53,9 @@ export default function ContractPage(props: {
|
||||||
|
|
||||||
const { creatorId, isResolved, resolution, question } = contract
|
const { creatorId, isResolved, resolution, question } = contract
|
||||||
const isCreator = user?.id === creatorId
|
const isCreator = user?.id === creatorId
|
||||||
|
const allowTrade =
|
||||||
|
!isResolved && (!contract.closeTime || contract.closeTime > Date.now())
|
||||||
|
const allowResolve = !isResolved && isCreator && user
|
||||||
|
|
||||||
const { probPercent } = compute(contract)
|
const { probPercent } = compute(contract)
|
||||||
|
|
||||||
|
@ -61,7 +64,7 @@ export default function ContractPage(props: {
|
||||||
: `${probPercent} chance. ${contract.description}`
|
: `${probPercent} chance. ${contract.description}`
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Page wide={!isResolved}>
|
<Page wide={allowTrade}>
|
||||||
<SEO
|
<SEO
|
||||||
title={question}
|
title={question}
|
||||||
description={description}
|
description={description}
|
||||||
|
@ -74,14 +77,13 @@ export default function ContractPage(props: {
|
||||||
<BetsSection contract={contract} user={user ?? null} />
|
<BetsSection contract={contract} user={user ?? null} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{!isResolved && (
|
{(allowTrade || allowResolve) && (
|
||||||
<>
|
<>
|
||||||
<div className="md:ml-8" />
|
<div className="md:ml-8" />
|
||||||
|
|
||||||
<Col className="flex-1">
|
<Col className="flex-1">
|
||||||
<BetPanel contract={contract} />
|
{allowTrade && <BetPanel contract={contract} />}
|
||||||
|
{allowResolve && (
|
||||||
{isCreator && user && (
|
|
||||||
<ResolutionPanel creator={user} contract={contract} />
|
<ResolutionPanel creator={user} contract={contract} />
|
||||||
)}
|
)}
|
||||||
</Col>
|
</Col>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user