import { DuplicateIcon } from '@heroicons/react/outline'
import clsx from 'clsx'
import { Contract } from 'common/contract'
import { ENV_CONFIG } from 'common/envs/constants'
import { getMappedValue } from 'common/pseudo-numeric'
import { contractPath } from 'web/lib/firebase/contracts'
import { trackCallback } from 'web/lib/service/analytics'
export function DuplicateContractButton(props: {
contract: Contract
className?: string
}) {
const { contract, className } = props
return (
Duplicate
)
}
// Pass along the Uri to create a new contract
function duplicateContractHref(contract: Contract) {
const params = {
q: contract.question,
closeTime: contract.closeTime || 0,
description:
(contract.description ? `${contract.description}\n\n` : '') +
`(Copied from https://${ENV_CONFIG.domain}${contractPath(contract)})`,
outcomeType: contract.outcomeType,
} as Record
if (contract.outcomeType === 'PSEUDO_NUMERIC') {
params.min = contract.min
params.max = contract.max
params.isLogScale = contract.isLogScale
params.initValue = getMappedValue(contract)(contract.initialProbability)
}
return (
`/create?` +
Object.entries(params)
.map(([key, value]) => `${key}=${encodeURIComponent(value)}`)
.join('&')
)
}