import router from 'next/router' import { useState } from 'react' import { ContractsList } from '../../components/contracts-list' import { Header } from '../../components/header' import { Spacer } from '../../components/layout/spacer' import { Title } from '../../components/title' import { useUser } from '../../hooks/use-user' import { createContract } from '../../lib/service/create-contract' // Allow user to create a new contract export default function NewContract() { const creator = useUser() const [initialProb, setInitialProb] = useState(50) const [question, setQuestion] = useState('') const [description, setDescription] = useState('') const [isSubmitting, setIsSubmitting] = useState(false) async function submit() { // TODO: add more rigorous error handling for question, description if (!creator || !question || !description) return setIsSubmitting(true) const contract = await createContract( question, description, initialProb, creator ) await router.push(`contract/${contract.id}`) } const descriptionPlaceholder = `e.g. This market will resolve to “Yes” if, by June 2, 2021, 11:59:59 PM ET, Paxlovid (also known under PF-07321332)...` return (