Added radio buttons to market creation (non functional)
This commit is contained in:
parent
c3be126337
commit
645e891b73
|
@ -28,6 +28,7 @@ export type FullContract<
|
|||
isResolved: boolean
|
||||
resolutionTime?: number // When the contract creator resolved the market
|
||||
resolution?: string
|
||||
resolutionType: 'manual' | 'combined' | 'automatic'
|
||||
|
||||
closeEmailsSent?: number
|
||||
|
||||
|
@ -97,7 +98,9 @@ export type Numeric = {
|
|||
}
|
||||
|
||||
export type outcomeType = 'BINARY' | 'MULTI' | 'FREE_RESPONSE' | 'NUMERIC'
|
||||
export type resolutionType = 'MANUAL' | 'COMBINED' | 'AUTOMATIC'
|
||||
export const OUTCOME_TYPES = ['BINARY', 'MULTI', 'FREE_RESPONSE', 'NUMERIC']
|
||||
export const RESOLUTION_TYPES = ['MANUAL', 'COMBINED', 'AUTOMATIC']
|
||||
|
||||
export const MAX_QUESTION_LENGTH = 480
|
||||
export const MAX_DESCRIPTION_LENGTH = 10000
|
||||
|
|
|
@ -8,6 +8,7 @@ import {
|
|||
FreeResponse,
|
||||
Numeric,
|
||||
outcomeType,
|
||||
resolutionType,
|
||||
} from './contract'
|
||||
import { User } from './user'
|
||||
import { parseTags } from './util/parse'
|
||||
|
@ -25,6 +26,7 @@ export function getNewContract(
|
|||
ante: number,
|
||||
closeTime: number,
|
||||
extraTags: string[],
|
||||
resolutionType: resolutionType,
|
||||
|
||||
// used for numeric markets
|
||||
bucketCount: number,
|
||||
|
|
|
@ -12,6 +12,7 @@ import {
|
|||
MAX_TAG_LENGTH,
|
||||
Numeric,
|
||||
OUTCOME_TYPES,
|
||||
RESOLUTION_TYPES
|
||||
} from '../../common/contract'
|
||||
import { slugify } from '../../common/util/slugify'
|
||||
import { randomString } from '../../common/util/random'
|
||||
|
@ -44,6 +45,7 @@ export const createContract = newEndpoint(['POST'], async (req, _res) => {
|
|||
min,
|
||||
max,
|
||||
manaLimitPerUser,
|
||||
resolutionType,
|
||||
} = req.body || {}
|
||||
|
||||
if (!question || typeof question != 'string')
|
||||
|
@ -87,6 +89,11 @@ export const createContract = newEndpoint(['POST'], async (req, _res) => {
|
|||
)
|
||||
throw new APIError(400, 'Invalid initial probability')
|
||||
|
||||
resolutionType = resolutionType ?? 'MANUAL'
|
||||
|
||||
if (!RESOLUTION_TYPES.includes(resolutionType))
|
||||
throw new APIError(400, 'Invalid resolutionType')
|
||||
|
||||
// Uses utc time on server:
|
||||
const yesterday = new Date()
|
||||
yesterday.setUTCDate(yesterday.getUTCDate() - 1)
|
||||
|
@ -138,7 +145,8 @@ export const createContract = newEndpoint(['POST'], async (req, _res) => {
|
|||
NUMERIC_BUCKET_COUNT,
|
||||
min ?? 0,
|
||||
max ?? 0,
|
||||
manaLimitPerUser ?? 0
|
||||
manaLimitPerUser ?? 0,
|
||||
resolutionType,
|
||||
)
|
||||
|
||||
if (!isFree && ante) await chargeUser(creator.id, ante, true)
|
||||
|
|
|
@ -11,7 +11,7 @@ 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 } from 'common/contract'
|
||||
import { MAX_DESCRIPTION_LENGTH, outcomeType, 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'
|
||||
|
@ -64,6 +64,7 @@ export function NewContract(props: { question: string; tag?: string }) {
|
|||
}, [])
|
||||
|
||||
const [outcomeType, setOutcomeType] = useState<outcomeType>('BINARY')
|
||||
const [resolutionType, setResolutionType] = useState<resolutionType>('MANUAL')
|
||||
const [initialProb, setInitialProb] = useState(50)
|
||||
const [minString, setMinString] = useState('')
|
||||
const [maxString, setMaxString] = useState('')
|
||||
|
@ -365,6 +366,48 @@ export function NewContract(props: { question: string; tag?: string }) {
|
|||
)}
|
||||
</div>
|
||||
|
||||
<Spacer h={4} />
|
||||
<label className="label mt-1">
|
||||
<span className="my-1">Resolution type</span>
|
||||
</label>
|
||||
<Row className="form-control gap-2">
|
||||
<label className="label cursor-pointer gap-2">
|
||||
<input
|
||||
className="radio"
|
||||
type="radio"
|
||||
name="res"
|
||||
checked={resolutionType === 'MANUAL'}
|
||||
value="MANUAL"
|
||||
onChange={() => setResolutionType('MANUAL')}
|
||||
disabled={isSubmitting}
|
||||
/>
|
||||
<span className="label-text">Manual</span>
|
||||
</label>
|
||||
|
||||
<label className="label cursor-pointer gap-2">
|
||||
<input
|
||||
className="radio"
|
||||
type="radio"
|
||||
name="res"
|
||||
checked={resolutionType === 'COMBINED'}
|
||||
value="COMBINED"
|
||||
onChange={() => setResolutionType('COMBINED')}
|
||||
disabled={isSubmitting}
|
||||
/>
|
||||
<span className="label-text">Combined (experimental)</span>
|
||||
</label>
|
||||
<label className="label cursor-pointer gap-2">
|
||||
<input
|
||||
className="radio"
|
||||
type="radio"
|
||||
name="res"
|
||||
checked={resolutionType === 'AUTOMATIC'}
|
||||
value="AUTOMATIC"
|
||||
onChange={() => setResolutionType('AUTOMATIC')}
|
||||
/>
|
||||
<span className="label-text">Automatic (experimental)</span>
|
||||
</label>
|
||||
</Row>
|
||||
<Spacer h={4} />
|
||||
|
||||
<div className="form-control mb-1 items-start">
|
||||
|
|
Loading…
Reference in New Issue
Block a user