diff --git a/web/components/contract-feed.tsx b/web/components/contract-feed.tsx
index e25241d7..b81bc4b7 100644
--- a/web/components/contract-feed.tsx
+++ b/web/components/contract-feed.tsx
@@ -1,6 +1,12 @@
// From https://tailwindui.com/components/application-ui/lists/feeds
import { Fragment } from 'react'
import { ChatAltIcon, TagIcon, UserCircleIcon } from '@heroicons/react/solid'
+import { useBets } from '../hooks/use-bets'
+import { Bet } from '../lib/firebase/bets'
+import dayjs from 'dayjs'
+import relativeTime from 'dayjs/plugin/relativeTime'
+import { Contract } from '../lib/firebase/contracts'
+dayjs.extend(relativeTime)
const activity = [
{
@@ -14,10 +20,10 @@ const activity = [
date: '6d ago',
},
{
- id: 2,
- type: 'assignment',
- person: { name: 'Hilary Mahy', href: '#' },
- assigned: { name: 'Kristin Watson', href: '#' },
+ id: 'hifadsdf',
+ type: 'bet',
+ outcome: 'YES',
+ amount: 30,
date: '2d ago',
},
{
@@ -83,8 +89,9 @@ function FeedComment(props: { activityItem: any }) {
)
}
-function FeedAssignment(props: { activityItem: any }) {
+function FeedBet(props: { activityItem: any }) {
const { activityItem } = props
+ const { amount, outcome, createdTime } = activityItem
return (
<>
@@ -99,20 +106,14 @@ function FeedAssignment(props: { activityItem: any }) {
>
@@ -171,14 +172,34 @@ function FeedTags(props: { activityItem: any }) {
)
}
-export function ContractFeed() {
+function toFeedBet(bet: Bet) {
+ return {
+ id: bet.id,
+ type: 'bet',
+ amount: bet.amount,
+ outcome: bet.outcome,
+ createdTime: bet.createdTime,
+ date: dayjs(bet.createdTime).fromNow(),
+ }
+}
+
+export function ContractFeed(props: { contract: Contract }) {
+ const { contract } = props
+ const { id } = contract
+
+ let bets = useBets(id)
+ if (bets === 'loading') bets = []
+
+ // const allItems = [...bets.map(toFeedBet), ...activity]
+ const allItems = bets.map(toFeedBet)
+
return (
- {activity.map((activityItem, activityItemIdx) => (
+ {allItems.map((activityItem, activityItemIdx) => (
-
- {activityItemIdx !== activity.length - 1 ? (
+ {activityItemIdx !== allItems.length - 1 ? (
{activityItem.type === 'comment' ? (
- ) : activityItem.type === 'assignment' ? (
-
+ ) : activityItem.type === 'bet' ? (
+
) : activityItem.type === 'tags' ? (
) : null}
diff --git a/web/components/contract-overview.tsx b/web/components/contract-overview.tsx
index 114ba9b9..80cace20 100644
--- a/web/components/contract-overview.tsx
+++ b/web/components/contract-overview.tsx
@@ -15,6 +15,7 @@ import dayjs from 'dayjs'
import { Linkify } from './linkify'
import clsx from 'clsx'
import { ContractDetails, ResolutionOrChance } from './contract-card'
+import { ContractFeed } from './contract-feed'
function ContractCloseTime(props: { contract: Contract }) {
const closeTime = props.contract.closeTime
@@ -150,6 +151,10 @@ export const ContractOverview = (props: {
+
+
+
+
{/* Show a delete button for contracts without any trading */}
{isCreator && truePool === 0 && (
<>