From 4f7d2c3d1b46e2d4706db99e77f9dc2eba005cec Mon Sep 17 00:00:00 2001 From: Austin Chen Date: Thu, 9 Dec 2021 23:54:38 -0800 Subject: [PATCH] Correctly set seeds on new contracts --- web/pages/contract/index.tsx | 48 ++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/web/pages/contract/index.tsx b/web/pages/contract/index.tsx index 7df43346..561be370 100644 --- a/web/pages/contract/index.tsx +++ b/web/pages/contract/index.tsx @@ -71,9 +71,16 @@ export function ContractList(props: { contracts: Contract[] }) { } // Allow user to create a new contract +// TODO: Extract to a reusable UI, for listing contracts too? export default function NewContract() { const creator = useUser() const [contract, setContract] = useState({ + id: '', + creatorId: '', + question: '', + description: '', + seedAmounts: { YES: 100, NO: 100 }, + // TODO: Set create time to Firestore timestamp createdTime: 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)...` return ( -
+
-
+

Create a new prediction market

@@ -149,14 +156,27 @@ export default function NewContract() { >
- {/* TODO: Save seeds */}
- + { + setContract({ + ...contract, + seedAmounts: { + ...contract.seedAmounts, + YES: parseInt(e.target.value), + }, + }) + }} + />
@@ -165,14 +185,28 @@ export default function NewContract() { - + { + setContract({ + ...contract, + seedAmounts: { + ...contract.seedAmounts, + NO: parseInt(e.target.value), + }, + }) + }} + />
{/* TODO: Show a preview of the created market here? */} -
+