diff --git a/functions/src/types/contract.ts b/functions/src/types/contract.ts index 68e74186..15f256fd 100644 --- a/functions/src/types/contract.ts +++ b/functions/src/types/contract.ts @@ -16,7 +16,7 @@ export type Contract = { lastUpdatedTime: number // If the question or description was changed closeTime?: number // When no more trading is allowed - // isResolved: boolean + isResolved: boolean resolutionTime?: 10293849 // When the contract creator resolved the market; 0 if unresolved resolution?: 'YES' | 'NO' | 'CANCEL' // Chosen by creator; must be one of outcomes } \ No newline at end of file diff --git a/web/components/resolved-panel.tsx b/web/components/resolved-panel.tsx new file mode 100644 index 00000000..223476fc --- /dev/null +++ b/web/components/resolved-panel.tsx @@ -0,0 +1,57 @@ +import clsx from 'clsx' +import dayjs from 'dayjs' +import React from 'react' + +import { Contract } 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 { 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. + )} +
+ + ) +} diff --git a/web/lib/firebase/contracts.ts b/web/lib/firebase/contracts.ts index b5b5ea4e..07313abb 100644 --- a/web/lib/firebase/contracts.ts +++ b/web/lib/firebase/contracts.ts @@ -30,7 +30,7 @@ export type Contract = { lastUpdatedTime: number // If the question or description was changed closeTime?: number // When no more trading is allowed - // isResolved: boolean + isResolved: boolean resolutionTime?: 10293849 // When the contract creator resolved the market; 0 if unresolved resolution?: 'YES' | 'NO' | 'CANCEL' // Chosen by creator; must be one of outcomes } diff --git a/web/pages/contract/[contractId].tsx b/web/pages/contract/[contractId].tsx index 83f696a5..248cf6b5 100644 --- a/web/pages/contract/[contractId].tsx +++ b/web/pages/contract/[contractId].tsx @@ -7,6 +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' export default function ContractPage() { const user = useUser() @@ -24,19 +25,29 @@ export default function ContractPage() { return
Contract not found...
} - const isCreator = user?.id === contract.creatorId + const { creatorId, isResolved } = contract + const isCreator = user?.id === creatorId return (
- +
- {isCreator ? ( - + {isResolved ? ( + + ) : isCreator ? ( + ) : ( )}