Make duplicating better: description, closetime, logscale
Known issue: some markets like https://manifold.markets/FFSX/rojo-ronald-jones don't duplicate because too much stuff in JSON...?
This commit is contained in:
parent
0cd61eb214
commit
7736f1e3c1
|
@ -33,22 +33,29 @@ export function DuplicateContractButton(props: {
|
||||||
|
|
||||||
// Pass along the Uri to create a new contract
|
// Pass along the Uri to create a new contract
|
||||||
function duplicateContractHref(contract: Contract) {
|
function duplicateContractHref(contract: Contract) {
|
||||||
|
const descriptionString = JSON.stringify(contract.description)
|
||||||
|
// Don't set a closeTime that's in the past
|
||||||
|
const closeTime =
|
||||||
|
(contract?.closeTime ?? 0) <= Date.now() ? 0 : contract.closeTime
|
||||||
const params = {
|
const params = {
|
||||||
q: contract.question,
|
q: contract.question,
|
||||||
closeTime: contract.closeTime || 0,
|
closeTime,
|
||||||
description:
|
description: descriptionString,
|
||||||
(contract.description ? `${contract.description}\n\n` : '') +
|
|
||||||
`(Copied from https://${ENV_CONFIG.domain}${contractPath(contract)})`,
|
|
||||||
outcomeType: contract.outcomeType,
|
outcomeType: contract.outcomeType,
|
||||||
} as Record<string, any>
|
} as Record<string, any>
|
||||||
|
|
||||||
if (contract.outcomeType === 'PSEUDO_NUMERIC') {
|
if (contract.outcomeType === 'PSEUDO_NUMERIC') {
|
||||||
params.min = contract.min
|
params.min = contract.min
|
||||||
params.max = contract.max
|
params.max = contract.max
|
||||||
params.isLogScale = contract.isLogScale
|
if (contract.isLogScale) {
|
||||||
|
// Conditional, because `?isLogScale=false` evaluates to `true`
|
||||||
|
params.isLogScale = true
|
||||||
|
}
|
||||||
params.initValue = getMappedValue(contract)(contract.initialProbability)
|
params.initValue = getMappedValue(contract)(contract.initialProbability)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Support multiple choice markets?
|
||||||
|
|
||||||
if (contract.groupLinks && contract.groupLinks.length > 0) {
|
if (contract.groupLinks && contract.groupLinks.length > 0) {
|
||||||
params.groupId = contract.groupLinks[0].groupId
|
params.groupId = contract.groupLinks[0].groupId
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,6 +207,7 @@ export function NewContract(props: {
|
||||||
max: MAX_DESCRIPTION_LENGTH,
|
max: MAX_DESCRIPTION_LENGTH,
|
||||||
placeholder: descriptionPlaceholder,
|
placeholder: descriptionPlaceholder,
|
||||||
disabled: isSubmitting,
|
disabled: isSubmitting,
|
||||||
|
defaultValue: JSON.parse(params?.description ?? '{}'),
|
||||||
})
|
})
|
||||||
|
|
||||||
const isEditorFilled = editor != null && !editor.isEmpty
|
const isEditorFilled = editor != null && !editor.isEmpty
|
||||||
|
|
Loading…
Reference in New Issue
Block a user