// From https://tailwindui.com/components/application-ui/lists/feeds import { Fragment, useState } from 'react' import { ChatAltIcon, TagIcon, UserCircleIcon } from '@heroicons/react/solid' import { useBets } from '../hooks/use-bets' import { Bet, createComment } from '../lib/firebase/bets' import dayjs from 'dayjs' import relativeTime from 'dayjs/plugin/relativeTime' import { Contract } from '../lib/firebase/contracts' import { OutcomeLabel } from './outcome-label' import { useUser } from '../hooks/use-user' import { User } from '../lib/firebase/users' import { Linkify } from './linkify' dayjs.extend(relativeTime) const activity = [ { id: 1, type: 'comment', person: { name: 'Eduardo Benz', href: '#' }, imageUrl: 'https://images.unsplash.com/photo-1520785643438-5bf77931f493?ixlib=rb-=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=8&w=256&h=256&q=80', comment: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Tincidunt nunc ipsum tempor purus vitae id. Morbi in vestibulum nec varius. Et diam cursus quis sed purus nam. ', date: '6d ago', }, { id: 'hifadsdf', type: 'bet', outcome: 'YES', amount: 30, date: '2d ago', }, { id: 3, type: 'tags', person: { name: 'Hilary Mahy', href: '#' }, tags: [ { name: 'Bug', href: '#', color: 'bg-rose-500' }, { name: 'Accessibility', href: '#', color: 'bg-indigo-500' }, ], date: '6h ago', }, { id: 4, type: 'comment', person: { name: 'Jason Meyers', href: '#' }, imageUrl: 'https://images.unsplash.com/photo-1531427186611-ecfd6d936c79?ixlib=rb-=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=8&w=256&h=256&q=80', comment: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Tincidunt nunc ipsum tempor purus vitae id. Morbi in vestibulum nec varius. Et diam cursus quis sed purus nam. Scelerisque amet elit non sit ut tincidunt condimentum. Nisl ultrices eu venenatis diam.', date: '2h ago', }, ] function classNames(...classes) { return classes.filter(Boolean).join(' ') } function FeedComment(props: { activityItem: any }) { const { activityItem } = props const { person, text, date, 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; user: User }) { const { activityItem, user } = props const { id, contractId, amount, outcome, createdTime } = activityItem const isCreator = user.id == activityItem.userId const [comment, setComment] = useState('') async function submitComment() { await createComment(contractId, id, comment, user) } return ( <>
{isCreator ? 'You' : 'Someone'}{' '} placed M$ {amount} on {' '} {isCreator && ( // Allow user to comment in an textarea if they are the creator