Preview a slimmed-down version of /Create
This commit is contained in:
parent
3ba96028f4
commit
302c524dcf
|
@ -8,6 +8,8 @@ import { useUser } from '../hooks/use-user'
|
||||||
import { path } from '../lib/firebase/contracts'
|
import { path } from '../lib/firebase/contracts'
|
||||||
import { createContract } from '../lib/service/create-contract'
|
import { createContract } from '../lib/service/create-contract'
|
||||||
import { Page } from '../components/page'
|
import { Page } from '../components/page'
|
||||||
|
import { Row } from '../components/layout/row'
|
||||||
|
import clsx from 'clsx'
|
||||||
|
|
||||||
// Allow user to create a new contract
|
// Allow user to create a new contract
|
||||||
export default function NewContract() {
|
export default function NewContract() {
|
||||||
|
@ -21,6 +23,7 @@ export default function NewContract() {
|
||||||
const [question, setQuestion] = useState('')
|
const [question, setQuestion] = useState('')
|
||||||
const [description, setDescription] = useState('')
|
const [description, setDescription] = useState('')
|
||||||
const [isSubmitting, setIsSubmitting] = useState(false)
|
const [isSubmitting, setIsSubmitting] = useState(false)
|
||||||
|
const [collapsed, setCollapsed] = useState(true)
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
// TODO: add more rigorous error handling for question
|
// TODO: add more rigorous error handling for question
|
||||||
|
@ -49,53 +52,93 @@ export default function NewContract() {
|
||||||
{/* Create a Tailwind form that takes in all the fields needed for a new contract */}
|
{/* Create a Tailwind form that takes in all the fields needed for a new contract */}
|
||||||
{/* When the form is submitted, create a new contract in the database */}
|
{/* When the form is submitted, create a new contract in the database */}
|
||||||
<form>
|
<form>
|
||||||
<div className="form-control">
|
<div className="flex justify-between gap-4 items-center">
|
||||||
|
<div className="form-control w-full">
|
||||||
<label className="label">
|
<label className="label">
|
||||||
<span className="label-text">Question</span>
|
<span className="label-text">Prediction</span>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
placeholder="e.g. Will the FDA approve Paxlovid before Jun 2nd, 2022?"
|
placeholder="e.g. The FDA will approve Paxlovid before Jun 2nd, 2022"
|
||||||
className="input input-bordered"
|
className="input"
|
||||||
value={question}
|
value={question}
|
||||||
onChange={(e) => setQuestion(e.target.value || '')}
|
onChange={(e) => setQuestion(e.target.value || '')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Spacer h={4} />
|
|
||||||
|
|
||||||
<div className="form-control">
|
<div className="form-control">
|
||||||
<label className="label">
|
<label className="label">
|
||||||
<span className="label-text">Description (optional)</span>
|
<span className="label-text">Chance</span>
|
||||||
</label>
|
</label>
|
||||||
|
<label className="input-group input-group-md w-fit">
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
value={initialProb}
|
||||||
|
className="input input-bordered input-md"
|
||||||
|
min={1}
|
||||||
|
max={99}
|
||||||
|
onChange={(e) => setInitialProb(parseInt(e.target.value))}
|
||||||
|
/>
|
||||||
|
<span>%</span>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mt-2 mb-4">
|
||||||
|
<a
|
||||||
|
href="#"
|
||||||
|
className="text-sm text-gray-400"
|
||||||
|
onClick={() => setCollapsed(!collapsed)}
|
||||||
|
>
|
||||||
|
▼ Advanced
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Collapsible "Advanced" section */}
|
||||||
|
<div
|
||||||
|
tabIndex={0}
|
||||||
|
className={clsx(
|
||||||
|
'cursor-pointer relative',
|
||||||
|
collapsed ? 'collapse-close' : 'collapse-open'
|
||||||
|
)}
|
||||||
|
onClick={() => setCollapsed((collapsed) => !collapsed)}
|
||||||
|
>
|
||||||
|
<Row>
|
||||||
|
<div
|
||||||
|
className="collapse-title p-0 absolute w-0 h-0 min-h-0"
|
||||||
|
style={{ top: -10, right: 4 }}
|
||||||
|
/>
|
||||||
|
</Row>
|
||||||
|
<div className="collapse-content !p-0 m-0 !bg-transparent">
|
||||||
|
<div className="form-control">
|
||||||
|
<label className="label">
|
||||||
|
<span className="label-text">Description</span>
|
||||||
|
</label>
|
||||||
<textarea
|
<textarea
|
||||||
className="textarea h-24 textarea-bordered"
|
className="textarea w-full h-24 textarea-bordered"
|
||||||
placeholder={descriptionPlaceholder}
|
placeholder={descriptionPlaceholder}
|
||||||
value={description}
|
value={description}
|
||||||
|
onClick={(e) => e.stopPropagation()}
|
||||||
onChange={(e) => setDescription(e.target.value || '')}
|
onChange={(e) => setDescription(e.target.value || '')}
|
||||||
></textarea>
|
></textarea>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Spacer h={4} />
|
|
||||||
|
|
||||||
<div className="form-control">
|
<div className="form-control">
|
||||||
<label className="label">
|
<label className="label">
|
||||||
<span className="label-text">
|
<span className="label-text">Resolution date</span>
|
||||||
Initial probability: {initialProb}%
|
|
||||||
</span>
|
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<input
|
<input
|
||||||
type="range"
|
type="date"
|
||||||
className="range range-lg range-primary"
|
className="input"
|
||||||
min="1"
|
onClick={(e) => e.stopPropagation()}
|
||||||
max={99}
|
value="2012-07-22"
|
||||||
value={initialProb}
|
min="2022-01-01"
|
||||||
onChange={(e) => setInitialProb(parseInt(e.target.value))}
|
max="2022-12-31"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<Spacer h={4} />
|
<Spacer h={4} />
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user