import Link from 'next/link' import { Col } from '../components/layout/col' import { Row } from '../components/layout/row' import { useEffect, useState } from 'react' import { compute, Contract, listContracts, path, } from '../lib/firebase/contracts' import { formatMoney } from '../lib/util/format' import { User } from '../lib/firebase/users' import { UserLink } from './user-page' export function ContractDetails(props: { contract: Contract }) { const { contract } = props const { volume, createdDate, resolvedDate } = compute(contract) return (
{resolvedDate ? `${createdDate} - ${resolvedDate}` : createdDate}
{formatMoney(volume)} bet
) } function ContractCard(props: { contract: Contract }) { const { contract } = props const { probPercent } = compute(contract) const resolutionColor = { YES: 'text-primary', NO: 'text-red-400', CANCEL: 'text-yellow-400', '': '', // Empty if unresolved }[contract.resolution || ''] const resolutionText = { YES: 'YES', NO: 'NO', CANCEL: 'N/A', '': '', }[contract.resolution || ''] return (
  • {/* Left side of card */}

    {contract.question}

    {/* Right side of card */} {resolutionText || (
    {probPercent}
    chance
    )}
  • ) } export function ContractsGrid(props: { contracts: Contract[] }) { const { contracts } = props return ( ) } export function ContractsList(props: { creator: User }) { const { creator } = props const [contracts, setContracts] = useState([]) useEffect(() => { if (creator?.id) { // TODO: stream changes from firestore listContracts(creator.id).then(setContracts) } }, [creator]) return }