diff --git a/web/components/contract-overview.tsx b/web/components/contract-overview.tsx
index 8f025ed2..9a5ff475 100644
--- a/web/components/contract-overview.tsx
+++ b/web/components/contract-overview.tsx
@@ -1,17 +1,31 @@
import React from 'react'
-import { compute, Contract } from '../lib/firebase/contracts'
+import { compute, Contract, deleteContract } from '../lib/firebase/contracts'
import { Col } from './layout/col'
import { Spacer } from './layout/spacer'
import { ContractProbGraph } from './contract-prob-graph'
import { ContractDetails } from './contracts-list'
+import router from 'next/router'
+import { useUser } from '../hooks/use-user'
export const ContractOverview = (props: {
contract: Contract
className?: string
}) => {
const { contract, className } = props
- const { probPercent } = compute(contract)
+ const { resolution, creatorId, isResolved } = contract
+ const { probPercent, volume } = compute(contract)
+ const user = useUser()
+ const isCreator = user?.id === creatorId
+
+ const resolutionColor =
+ resolution === 'YES'
+ ? 'text-primary'
+ : resolution === 'NO'
+ ? 'text-red-400'
+ : resolution === 'CANCEL'
+ ? 'text-yellow-400'
+ : ''
return (
{probPercent}
diff --git a/web/components/resolved-panel.tsx b/web/components/resolved-panel.tsx
deleted file mode 100644
index 35e41896..00000000
--- a/web/components/resolved-panel.tsx
+++ /dev/null
@@ -1,74 +0,0 @@
-import clsx from 'clsx'
-import dayjs from 'dayjs'
-import { useRouter } from 'next/router'
-import React from 'react'
-
-import { Contract, deleteContract } from '../lib/firebase/contracts'
-import { formatMoney } from '../lib/util/format'
-import { Col } from './layout/col'
-import { Spacer } from './layout/spacer'
-
-export function ResolvedPanel(props: {
- contract: Contract
- className?: string
-}) {
- const router = useRouter()
-
- const { contract, className } = props
-
- const { resolution, resolutionTime, pot, seedAmounts } = contract
-
- const total = pot.YES + pot.NO - seedAmounts.YES - seedAmounts.NO
-
- const color =
- resolution === 'YES'
- ? 'text-primary'
- : resolution === 'NO'
- ? 'text-red-400'
- : resolution === 'CANCEL'
- ? 'text-yellow-400'
- : 'text-gray-500'
-
- return (
-
-
- Resolved: {resolution}
-
-
-
-
- {dayjs(resolutionTime).format('MMM D, HH:mma')}
-
-
-
-
- {resolution === 'YES' ? (
- <>Yes bettors have collectively won {formatMoney(total)}.>
- ) : resolution === 'NO' ? (
- <>No bettors have collectively won {formatMoney(total)}.>
- ) : (
- <>All bets have been returned.>
- )}
-
-
- {/* Show a delete button for contracts without any trading */}
- {total === 0 && (
-
- )}
-
- )
-}
diff --git a/web/lib/firebase/contracts.ts b/web/lib/firebase/contracts.ts
index 12be8a0b..ef7a46a0 100644
--- a/web/lib/firebase/contracts.ts
+++ b/web/lib/firebase/contracts.ts
@@ -37,12 +37,13 @@ export type Contract = {
}
export function compute(contract: Contract) {
- const { pot, seedAmounts, createdTime } = contract
+ const { pot, seedAmounts, createdTime, resolutionTime, isResolved } = contract
const volume = pot.YES + pot.NO - seedAmounts.YES - seedAmounts.NO
const prob = pot.YES ** 2 / (pot.YES ** 2 + pot.NO ** 2)
const probPercent = Math.round(prob * 100) + '%'
const createdDate = dayjs(createdTime).format('MMM D')
- return { volume, probPercent, createdDate }
+ const resolvedDate = isResolved ? dayjs(resolutionTime).format('MMM D') : undefined
+ return { volume, probPercent, createdDate, resolvedDate }
}
const db = getFirestore(app)
diff --git a/web/pages/contract/[contractId].tsx b/web/pages/contract/[contractId].tsx
index 0bf354e4..52f9cf4a 100644
--- a/web/pages/contract/[contractId].tsx
+++ b/web/pages/contract/[contractId].tsx
@@ -7,7 +7,7 @@ import { BetPanel } from '../../components/bet-panel'
import { Col } from '../../components/layout/col'
import { useUser } from '../../hooks/use-user'
import { ResolutionPanel } from '../../components/resolution-panel'
-import { ResolvedPanel } from '../../components/resolved-panel'
+import clsx from 'clsx'
export default function ContractPage() {
const user = useUser()
@@ -29,25 +29,32 @@ export default function ContractPage() {
const isCreator = user?.id === creatorId
return (
-
+
-
+
-
+ {!isResolved && (
+ <>
+
- {isResolved ? (
-
- ) : isCreator ? (
-
- ) : (
-
+ {isCreator ? (
+
+ ) : (
+
+ )}
+ >
)}
-
+
)
}