Working tree is now the canonical repo. Off-chain play-money + trustless on-chain (FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution, mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
65 lines
1.9 KiB
TypeScript
65 lines
1.9 KiB
TypeScript
'use client'
|
|
import { useEffect, useState } from 'react'
|
|
import { Page } from 'web/components/layout/page'
|
|
import {
|
|
NewQuestionParams,
|
|
NewContractPanel,
|
|
} from 'web/components/new-contract/new-contract-panel'
|
|
import { Title } from 'web/components/widgets/title'
|
|
import { useDefinedSearchParams } from 'web/hooks/use-defined-search-params'
|
|
import { useRedirectIfSignedOut } from 'web/hooks/use-redirect-if-signed-out'
|
|
import { useUser } from 'web/hooks/use-user'
|
|
|
|
export default function Create() {
|
|
useRedirectIfSignedOut()
|
|
|
|
const user = useUser()
|
|
const { searchParams } = useDefinedSearchParams()
|
|
|
|
function getURLParams() {
|
|
try {
|
|
if (!searchParams) return {} as NewQuestionParams
|
|
|
|
// If there's a 'params' query parameter, it contains JSON-encoded question params
|
|
const paramsString = searchParams.get('params')
|
|
if (paramsString) {
|
|
return JSON.parse(paramsString) as NewQuestionParams
|
|
}
|
|
|
|
// Otherwise return empty params (the 'type' parameter is handled separately in NewContractPanel)
|
|
return {} as NewQuestionParams
|
|
} catch (error) {
|
|
console.error('Error parsing URL params:', error)
|
|
return {} as NewQuestionParams
|
|
}
|
|
}
|
|
|
|
const [params, setParams] = useState(getURLParams())
|
|
|
|
useEffect(() => {
|
|
const params = getURLParams()
|
|
if (!params || Object.keys(params).length === 0) return
|
|
setParams(params)
|
|
}, [searchParams])
|
|
|
|
if (!user) return <div />
|
|
|
|
if (user.isBannedFromPosting)
|
|
return (
|
|
<Page trackPageView={'banned from create page'}>
|
|
<div className="mx-auto w-full max-w-2xl">
|
|
<div className="rounded-lg px-6 py-4 sm:py-0">
|
|
<Title>Create a market</Title>
|
|
<p>Sorry, you are currently banned from creating a question.</p>
|
|
</div>
|
|
</div>
|
|
</Page>
|
|
)
|
|
|
|
return (
|
|
<Page trackPageView={'create page'} hideFooter>
|
|
<NewContractPanel params={params} creator={user} />
|
|
</Page>
|
|
)
|
|
}
|