Correctly set seeds on new contracts

This commit is contained in:
Austin Chen 2021-12-09 23:54:38 -08:00
parent 9bafc2b2e8
commit 4f7d2c3d1b

View File

@ -71,9 +71,16 @@ export function ContractList(props: { contracts: Contract[] }) {
} }
// Allow user to create a new contract // Allow user to create a new contract
// TODO: Extract to a reusable UI, for listing contracts too?
export default function NewContract() { export default function NewContract() {
const creator = useUser() const creator = useUser()
const [contract, setContract] = useState<Contract>({ const [contract, setContract] = useState<Contract>({
id: '',
creatorId: '',
question: '',
description: '',
seedAmounts: { YES: 100, NO: 100 },
// TODO: Set create time to Firestore timestamp // TODO: Set create time to Firestore timestamp
createdTime: Date.now(), createdTime: Date.now(),
lastUpdatedTime: Date.now(), lastUpdatedTime: Date.now(),
@ -101,9 +108,9 @@ export default function NewContract() {
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)...` 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 ( return (
<div className="relative overflow-hidden h-screen bg-cover bg-gray-900"> <div>
<Header /> <Header />
<div className="max-w-4xl my-20 mx-auto"> <div className="max-w-4xl my-20 lg:mx-auto mx-4">
<h1 className="text-2xl text-indigo-300 font-bold mt-6 mb-4"> <h1 className="text-2xl text-indigo-300 font-bold mt-6 mb-4">
Create a new prediction market Create a new prediction market
</h1> </h1>
@ -149,14 +156,27 @@ export default function NewContract() {
></textarea> ></textarea>
</div> </div>
{/* TODO: Save seeds */}
<div className="mt-6 grid grid-cols-1 gap-y-6 gap-x-4 sm:grid-cols-6"> <div className="mt-6 grid grid-cols-1 gap-y-6 gap-x-4 sm:grid-cols-6">
<div className="sm:col-span-3"> <div className="sm:col-span-3">
<div className="form-control"> <div className="form-control">
<label className="label"> <label className="label">
<span className="label-text">Yes Seed</span> <span className="label-text">Yes Seed</span>
</label> </label>
<input type="number" placeholder="100" className="input" /> <input
type="number"
placeholder="100"
className="input"
value={contract.seedAmounts.YES}
onChange={(e) => {
setContract({
...contract,
seedAmounts: {
...contract.seedAmounts,
YES: parseInt(e.target.value),
},
})
}}
/>
</div> </div>
</div> </div>
@ -165,14 +185,28 @@ export default function NewContract() {
<label className="label"> <label className="label">
<span className="label-text">No Seed</span> <span className="label-text">No Seed</span>
</label> </label>
<input type="number" placeholder="100" className="input" /> <input
type="number"
placeholder="100"
className="input"
value={contract.seedAmounts.NO}
onChange={(e) => {
setContract({
...contract,
seedAmounts: {
...contract.seedAmounts,
NO: parseInt(e.target.value),
},
})
}}
/>
</div> </div>
</div> </div>
</div> </div>
{/* TODO: Show a preview of the created market here? */} {/* TODO: Show a preview of the created market here? */}
<div className="flex justify-end pt-3"> <div className="flex justify-end mt-6">
<button <button
type="submit" type="submit"
className="btn btn-primary" className="btn btn-primary"
@ -181,7 +215,7 @@ export default function NewContract() {
saveContract() saveContract()
}} }}
> >
Save Create market
</button> </button>
</div> </div>
</form> </form>