Date doc: Toggle to disable creating a prediction market
This commit is contained in:
parent
77e0631ea4
commit
d846b9fb30
|
@ -71,6 +71,7 @@ export const createpost = newEndpoint({}, async (req, auth) => {
|
|||
if (question) {
|
||||
const closeTime = Date.now() + DAY_MS * 30 * 3
|
||||
|
||||
try {
|
||||
const result = await createMarketHelper(
|
||||
{
|
||||
question,
|
||||
|
@ -84,6 +85,9 @@ export const createpost = newEndpoint({}, async (req, auth) => {
|
|||
auth
|
||||
)
|
||||
contractSlug = result.slug
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
const post: Post = removeUndefinedProps({
|
||||
|
|
|
@ -142,6 +142,7 @@ export function DateDocPost(props: {
|
|||
) : (
|
||||
<Content content={content} />
|
||||
)}
|
||||
{contractSlug && (
|
||||
<div className="mt-4 w-full max-w-lg self-center rounded-xl bg-gradient-to-r from-blue-200 via-purple-200 to-indigo-300 p-3">
|
||||
<iframe
|
||||
height="405"
|
||||
|
@ -151,6 +152,7 @@ export function DateDocPost(props: {
|
|||
className="w-full rounded-xl bg-white p-10"
|
||||
></iframe>
|
||||
</div>
|
||||
)}
|
||||
</Col>
|
||||
)
|
||||
}
|
||||
|
|
|
@ -15,6 +15,8 @@ import { MINUTE_MS } from 'common/util/time'
|
|||
import { Col } from 'web/components/layout/col'
|
||||
import { MAX_QUESTION_LENGTH } from 'common/contract'
|
||||
import { NoSEO } from 'web/components/NoSEO'
|
||||
import ShortToggle from 'web/components/widgets/short-toggle'
|
||||
import { removeUndefinedProps } from 'common/util/object'
|
||||
|
||||
export default function CreateDateDocPage() {
|
||||
const user = useUser()
|
||||
|
@ -26,6 +28,7 @@ export default function CreateDateDocPage() {
|
|||
const title = `${user?.name}'s Date Doc`
|
||||
const subtitle = 'Manifold dating docs'
|
||||
const [birthday, setBirthday] = useState<undefined | string>(undefined)
|
||||
const [createMarket, setCreateMarket] = useState(true)
|
||||
const [question, setQuestion] = useState(
|
||||
'Will I find a partner in the next 3 months?'
|
||||
)
|
||||
|
@ -38,7 +41,11 @@ export default function CreateDateDocPage() {
|
|||
|
||||
const birthdayTime = birthday ? dayjs(birthday).valueOf() : undefined
|
||||
const isValid =
|
||||
user && birthday && editor && editor.isEmpty === false && question
|
||||
user &&
|
||||
birthday &&
|
||||
editor &&
|
||||
editor.isEmpty === false &&
|
||||
(question || !createMarket)
|
||||
|
||||
async function saveDateDoc() {
|
||||
if (!user || !editor || !birthdayTime) return
|
||||
|
@ -46,15 +53,15 @@ export default function CreateDateDocPage() {
|
|||
const newPost: Omit<
|
||||
DateDoc,
|
||||
'id' | 'creatorId' | 'createdTime' | 'slug' | 'contractSlug'
|
||||
> & { question: string } = {
|
||||
> & { question?: string } = removeUndefinedProps({
|
||||
title,
|
||||
subtitle,
|
||||
content: editor.getJSON(),
|
||||
bounty: 0,
|
||||
birthday: birthdayTime,
|
||||
type: 'date-doc',
|
||||
question,
|
||||
}
|
||||
question: createMarket ? question : undefined,
|
||||
})
|
||||
|
||||
const result = await createPost(newPost)
|
||||
|
||||
|
@ -106,9 +113,13 @@ export default function CreateDateDocPage() {
|
|||
</Col>
|
||||
|
||||
<Col className="gap-4">
|
||||
<div className="">
|
||||
Finally, we'll create an (unlisted) prediction market!
|
||||
</div>
|
||||
<Row className="items-center gap-4">
|
||||
<ShortToggle
|
||||
on={createMarket}
|
||||
setOn={(on) => setCreateMarket(on)}
|
||||
/>
|
||||
Create an (unlisted) prediction market attached to the date doc
|
||||
</Row>
|
||||
|
||||
<Col className="gap-2">
|
||||
<Textarea
|
||||
|
@ -116,6 +127,7 @@ export default function CreateDateDocPage() {
|
|||
maxLength={MAX_QUESTION_LENGTH}
|
||||
value={question}
|
||||
onChange={(e) => setQuestion(e.target.value || '')}
|
||||
disabled={!createMarket}
|
||||
/>
|
||||
<div className="ml-2 text-gray-500">Cost: M$100</div>
|
||||
</Col>
|
||||
|
|
Loading…
Reference in New Issue
Block a user