From 45d7bdd0cde291a21e3c444535874fc33c32a25f Mon Sep 17 00:00:00 2001 From: Milli Date: Wed, 25 May 2022 21:37:16 +0200 Subject: [PATCH] Added combined resolution and required buttons to market creation --- web/pages/create.tsx | 103 ++++++++++++++++++++++++++++++------------- 1 file changed, 72 insertions(+), 31 deletions(-) diff --git a/web/pages/create.tsx b/web/pages/create.tsx index d39fc095..64fdaa3c 100644 --- a/web/pages/create.tsx +++ b/web/pages/create.tsx @@ -11,13 +11,14 @@ import { FIXED_ANTE, MINIMUM_ANTE } from 'common/antes' import { InfoTooltip } from 'web/components/info-tooltip' import { Page } from 'web/components/page' import { Row } from 'web/components/layout/row' -import { MAX_DESCRIPTION_LENGTH, outcomeType, resolutionType } from 'common/contract' +import { MAX_DESCRIPTION_LENGTH, outcomeType, resolution, resolutionType } from 'common/contract' import { formatMoney } from 'common/util/format' import { useHasCreatedContractToday } from 'web/hooks/use-has-created-contract-today' import { removeUndefinedProps } from 'common/util/object' import { CATEGORIES } from 'common/categories' import { ChoicesToggleGroup } from 'web/components/choices-toggle-group' import { CalculatorIcon } from '@heroicons/react/outline' +import { write } from 'fs' export default function Create() { const [question, setQuestion] = useState('') @@ -65,6 +66,7 @@ export function NewContract(props: { question: string; tag?: string }) { const [outcomeType, setOutcomeType] = useState('BINARY') const [resolutionType, setResolutionType] = useState('MANUAL') + const [automaticResolution, setAutomaticResolution] = useState('YES') const [initialProb, setInitialProb] = useState(50) const [minString, setMinString] = useState('') const [maxString, setMaxString] = useState('') @@ -89,8 +91,8 @@ export function NewContract(props: { question: string; tag?: string }) { // const [anteError, setAnteError] = useState() // By default, close the market a week from today - const weekFromToday = dayjs().add(7, 'day').format('YYYY-MM-DDT23:59') - const [closeDate, setCloseDate] = useState(weekFromToday) + const [closeDate, setCloseDate] = useState(weekFrom(dayjs())) + const [resolutionDate, setResolutionDate] = useState(weekFrom(closeDate)) const [isSubmitting, setIsSubmitting] = useState(false) @@ -122,6 +124,10 @@ export function NewContract(props: { question: string; tag?: string }) { min < max && max - min > 0.01)) + function weekFrom(date: string | dayjs.Dayjs | undefined) { + return dayjs(date).add(7, 'day').format('YYYY-MM-DDT23:59') + } + function setCloseDateInDays(days: number) { setShowCalendar(days === 0) const newCloseDate = dayjs().add(days, 'day').format('YYYY-MM-DDT23:59') @@ -367,36 +373,71 @@ export function NewContract(props: { question: string; tag?: string }) { - - -