import Link from 'next/link' import _ from 'lodash' import dayjs from 'dayjs' import { useContract } from '../hooks/use-contract' import { useUserBets } from '../hooks/use-user-bets' import { Bet } from '../lib/firebase/bets' import { User } from '../lib/firebase/users' import { formatMoney, formatPercent } from '../lib/util/format' import { Col } from './layout/col' import { ContractDetails } from './contracts-list' export function BetsList(props: { user: User }) { const { user } = props const bets = useUserBets(user?.id ?? '') if (bets === 'loading') { return <> } if (bets.length === 0) return
You have not made any bets yet!
const contractBets = _.groupBy(bets, 'contractId') return ( {Object.keys(contractBets).map((contractId) => ( ))} ) } function ContractBets(props: { contractId: string; bets: Bet[] }) { const { contractId, bets } = props const contract = useContract(contractId) if (contract === 'loading' || contract === null) return <> return (

{contract.question}

    {bets.map((bet) => ( ))}
) } function BetCard(props: { bet: Bet }) { const { bet } = props const { contractId, amount, outcome, createdTime, probBefore, probAfter } = bet return (
  • {formatMoney(amount)} on {outcome}

    {formatPercent(probBefore)} → {formatPercent(probAfter)}

    {dayjs(createdTime).format('MMM D, H:mma')}

  • ) }