prettier
This commit is contained in:
parent
a19e6326a3
commit
f3dfd81666
|
@ -106,7 +106,8 @@ export function ContractDetails(props: {
|
|||
disabled?: boolean
|
||||
}) {
|
||||
const { contract, bets, isCreator, disabled } = props
|
||||
const { closeTime, autoResolutionTime, creatorName, creatorUsername } = contract
|
||||
const { closeTime, autoResolutionTime, creatorName, creatorUsername } =
|
||||
contract
|
||||
const { volumeLabel, resolvedDate } = contractMetrics(contract)
|
||||
|
||||
return (
|
||||
|
@ -167,7 +168,13 @@ export function ContractDetails(props: {
|
|||
<div className="whitespace-nowrap">{volumeLabel}</div>
|
||||
</Row>
|
||||
|
||||
{!disabled && <ContractInfoDialog contract={contract} bets={bets} isCreator={isCreator ?? false}/>}
|
||||
{!disabled && (
|
||||
<ContractInfoDialog
|
||||
contract={contract}
|
||||
bets={bets}
|
||||
isCreator={isCreator ?? false}
|
||||
/>
|
||||
)}
|
||||
</Row>
|
||||
)
|
||||
}
|
||||
|
@ -215,14 +222,18 @@ function EditableCloseDate(props: {
|
|||
const newAutoResolutionTime = newCloseTime + 7 * DAY_MS
|
||||
let newDescription = `${description}\n\nClose date updated to ${formattedCloseDate}`
|
||||
|
||||
const update : Partial<Contract> = {
|
||||
closeTime: newCloseTime
|
||||
const update: Partial<Contract> = {
|
||||
closeTime: newCloseTime,
|
||||
}
|
||||
|
||||
if (newAutoResolutionTime >= autoResolutionTime) {
|
||||
update.autoResolutionTime = newAutoResolutionTime
|
||||
const formattedNewAutoResolutionTime = dayjs(newAutoResolutionTime).format('YYYY-MM-DD h:mm a')
|
||||
newDescription = newDescription.concat(`\nAuto resolution date updated to ${formattedNewAutoResolutionTime}`)
|
||||
const formattedNewAutoResolutionTime = dayjs(
|
||||
newAutoResolutionTime
|
||||
).format('YYYY-MM-DD h:mm a')
|
||||
newDescription = newDescription.concat(
|
||||
`\nAuto resolution date updated to ${formattedNewAutoResolutionTime}`
|
||||
)
|
||||
}
|
||||
|
||||
update.description = newDescription
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
import { DotsHorizontalIcon, PencilIcon, CheckIcon } from '@heroicons/react/outline'
|
||||
import {
|
||||
DotsHorizontalIcon,
|
||||
PencilIcon,
|
||||
CheckIcon,
|
||||
} from '@heroicons/react/outline'
|
||||
import clsx from 'clsx'
|
||||
import dayjs from 'dayjs'
|
||||
import { uniqBy } from 'lodash'
|
||||
|
@ -25,12 +29,22 @@ import { TweetButton } from '../tweet-button'
|
|||
|
||||
const formatTime = (dt: number) => dayjs(dt).format('MMM DD, YYYY hh:mm a z')
|
||||
|
||||
export function ContractInfoDialog(props: { contract: Contract; bets: Bet[]; isCreator: boolean }) {
|
||||
export function ContractInfoDialog(props: {
|
||||
contract: Contract
|
||||
bets: Bet[]
|
||||
isCreator: boolean
|
||||
}) {
|
||||
const { contract, bets, isCreator } = props
|
||||
|
||||
const [open, setOpen] = useState(false)
|
||||
|
||||
const { createdTime, closeTime, resolutionTime, autoResolutionTime, autoResolution } = contract
|
||||
const {
|
||||
createdTime,
|
||||
closeTime,
|
||||
resolutionTime,
|
||||
autoResolutionTime,
|
||||
autoResolution,
|
||||
} = contract
|
||||
const tradersCount = uniqBy(bets, 'userId').length
|
||||
|
||||
return (
|
||||
|
@ -89,9 +103,9 @@ export function ContractInfoDialog(props: { contract: Contract; bets: Bet[]; isC
|
|||
isCreator={isCreator}
|
||||
/>
|
||||
<tr>
|
||||
<td>Auto resolution</td>
|
||||
<td>{contract.autoResolution}</td>
|
||||
</tr>
|
||||
<td>Auto resolution</td>
|
||||
<td>{contract.autoResolution}</td>
|
||||
</tr>
|
||||
</>
|
||||
)}
|
||||
|
||||
|
@ -176,10 +190,10 @@ export function EditableResolutionTime(props: {
|
|||
const onSave = () => {
|
||||
const newTime = dayjs(timeString).valueOf()
|
||||
if (newTime === time) setIsEditing(false)
|
||||
else if ( contract.closeTime && newTime > (contract.closeTime ?? Date.now)) {
|
||||
else if (contract.closeTime && newTime > (contract.closeTime ?? Date.now)) {
|
||||
const formattedTime = dayjs(time).format('YYYY-MM-DD h:mm a')
|
||||
const newDescription = `${contract.description}\n\nAuto resolution date updated to ${formattedTime}`
|
||||
|
||||
|
||||
updateContract(contract.id, {
|
||||
autoResolutionTime: newTime,
|
||||
description: newDescription,
|
||||
|
@ -193,17 +207,19 @@ export function EditableResolutionTime(props: {
|
|||
<tr>
|
||||
<td>
|
||||
Market autoresolves
|
||||
{isCreator && (
|
||||
isEditing ? (
|
||||
{isCreator &&
|
||||
(isEditing ? (
|
||||
<button className="btn btn-xs btn-ghost" onClick={onSave}>
|
||||
<CheckIcon className="inline h-4 w-4" />
|
||||
</button>
|
||||
):(
|
||||
<button className="btn btn-xs btn-ghost"
|
||||
onClick={() => setIsEditing(true)} >
|
||||
) : (
|
||||
<button
|
||||
className="btn btn-xs btn-ghost"
|
||||
onClick={() => setIsEditing(true)}
|
||||
>
|
||||
<PencilIcon className="inline h-4 w-4" />
|
||||
</button>
|
||||
))}
|
||||
))}
|
||||
</td>
|
||||
<td>
|
||||
{isEditing ? (
|
||||
|
@ -218,7 +234,9 @@ export function EditableResolutionTime(props: {
|
|||
/>
|
||||
</div>
|
||||
) : (
|
||||
<div className="form-control mr-1 items-start">{formatTime(time)}</div>
|
||||
<div className="form-control mr-1 items-start">
|
||||
{formatTime(time)}
|
||||
</div>
|
||||
)}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -3,7 +3,12 @@ import { ReactNode } from 'react'
|
|||
import { Answer } from 'common/answer'
|
||||
import { getProbability } from 'common/calculate'
|
||||
import { getValueFromBucket } from 'common/calculate-dpm'
|
||||
import { BinaryContract, Contract, FreeResponseContract, resolution } from 'common/contract'
|
||||
import {
|
||||
BinaryContract,
|
||||
Contract,
|
||||
FreeResponseContract,
|
||||
resolution,
|
||||
} from 'common/contract'
|
||||
import { formatPercent } from 'common/util/format'
|
||||
import { ClientRender } from './client-render'
|
||||
|
||||
|
@ -35,9 +40,7 @@ export function OutcomeLabel(props: {
|
|||
)
|
||||
}
|
||||
|
||||
export function BinaryOutcomeLabel(props: {
|
||||
outcome: resolution
|
||||
}) {
|
||||
export function BinaryOutcomeLabel(props: { outcome: resolution }) {
|
||||
const { outcome } = props
|
||||
|
||||
if (outcome === 'YES') return <YesLabel />
|
||||
|
|
|
@ -42,7 +42,8 @@ export function contractUrl(contract: Contract) {
|
|||
}
|
||||
|
||||
export function contractMetrics(contract: Contract) {
|
||||
const { createdTime, resolutionTime, isResolved, autoResolutionTime } = contract
|
||||
const { createdTime, resolutionTime, isResolved, autoResolutionTime } =
|
||||
contract
|
||||
|
||||
const createdDate = dayjs(createdTime).format('MMM D')
|
||||
const autoResolutionDate = dayjs(autoResolutionTime).format('MMM D')
|
||||
|
|
Loading…
Reference in New Issue
Block a user