import { FieldValue, serverTimestamp } from '@firebase/firestore' import { useEffect, useState } from 'react' import { Header } from '../../components/header' import { useUser } from '../../hooks/use-user' import { Contract, deleteContract, listContracts, setContract as pushContract, } from '../../lib/firebase/contracts' function ContractCard(props: { contract: Contract }) { const { contract } = props return (
  • {contract.question}

    {contract.outcomeType}

    {/*

    {/*

    {/*
  • ) } // Allow user to create a new contract export default function NewContract() { const creator = useUser() const [contract, setContract] = useState({ // creatorId: creator?.id || '', // TODO: Set create time to Firestore timestamp createdTime: Date.now(), lastUpdatedTime: Date.now(), } as Contract) const [contracts, setContracts] = useState([]) useEffect(() => { if (creator?.id) { setContract({ ...contract, creatorId: creator.id }) listContracts(creator?.id).then(setContracts) } }, [creator?.id]) async function saveContract() { await pushContract(contract) // Update local contract list setContracts([...contracts, { ...contract }]) } function saveField(field: keyof Contract) { return (changeEvent: React.ChangeEvent) => setContract({ ...contract, [field]: changeEvent.target.value }) } 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 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 */}
    {/* TODO: Show a preview of the created market here? */}
    {/* Show a separate card for each contract */}
      {contracts.map((contract) => ( ))}
    ) }