// From https://tailwindui.com/components/application-ui/lists/feeds import { useState } from 'react' import { BanIcon, ChatAltIcon, CheckIcon, LockClosedIcon, StarIcon, UserIcon, UsersIcon, XIcon, } from '@heroicons/react/solid' import { useBets } from '../hooks/use-bets' import { Bet } from '../lib/firebase/bets' import { Comment, mapCommentsByBetId } from '../lib/firebase/comments' import dayjs from 'dayjs' import relativeTime from 'dayjs/plugin/relativeTime' import { OutcomeLabel } from './outcome-label' import { Contract, setContract } from '../lib/firebase/contracts' import { useUser } from '../hooks/use-user' import { Linkify } from './linkify' import { Row } from './layout/row' import { createComment } from '../lib/firebase/comments' import { useComments } from '../hooks/use-comments' import { formatMoney } from '../lib/util/format' dayjs.extend(relativeTime) function FeedComment(props: { activityItem: any }) { const { activityItem } = props const { person, text, amount, outcome, createdTime } = activityItem return ( <>

{person.name} {' '} placed M$ {amount} on {' '}

) } function Timestamp(props: { time: number }) { const { time } = props return ( {dayjs(time).fromNow()} ) } function FeedBet(props: { activityItem: any }) { const { activityItem } = props const { id, contractId, amount, outcome, createdTime } = activityItem const user = useUser() const isCreator = user?.id == activityItem.userId const [comment, setComment] = useState('') async function submitComment() { if (!user || !comment) return await createComment(contractId, id, comment, user) } return ( <>
{isCreator ? 'You' : 'A trader'} {' '} placed {formatMoney(amount)} on {' '} {isCreator && ( // Allow user to comment in an textarea if they are the creator