Show number of traders in "More" panel
This commit is contained in:
parent
75b39cbf6f
commit
624d99fc1d
|
@ -21,6 +21,7 @@ import { Spacer } from '../layout/spacer'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { getProbability } from '../../../common/calculate'
|
import { getProbability } from '../../../common/calculate'
|
||||||
import { ContractInfoDialog } from './contract-info-dialog'
|
import { ContractInfoDialog } from './contract-info-dialog'
|
||||||
|
import { Bet } from '../../../common/bet'
|
||||||
|
|
||||||
export function ContractCard(props: {
|
export function ContractCard(props: {
|
||||||
contract: Contract
|
contract: Contract
|
||||||
|
@ -171,10 +172,11 @@ function AbbrContractDetails(props: {
|
||||||
|
|
||||||
export function ContractDetails(props: {
|
export function ContractDetails(props: {
|
||||||
contract: Contract
|
contract: Contract
|
||||||
|
bets: Bet[]
|
||||||
isCreator?: boolean
|
isCreator?: boolean
|
||||||
hideShareButtons?: boolean
|
hideShareButtons?: boolean
|
||||||
}) {
|
}) {
|
||||||
const { contract, isCreator, hideShareButtons } = props
|
const { contract, bets, isCreator, hideShareButtons } = props
|
||||||
const { closeTime, creatorName, creatorUsername } = contract
|
const { closeTime, creatorName, creatorUsername } = contract
|
||||||
const { volumeLabel, createdDate, resolvedDate } = contractMetrics(contract)
|
const { volumeLabel, createdDate, resolvedDate } = contractMetrics(contract)
|
||||||
|
|
||||||
|
@ -233,7 +235,9 @@ export function ContractDetails(props: {
|
||||||
<div className="whitespace-nowrap">{volumeLabel}</div>
|
<div className="whitespace-nowrap">{volumeLabel}</div>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
{!hideShareButtons && <ContractInfoDialog contract={contract} />}
|
{!hideShareButtons && (
|
||||||
|
<ContractInfoDialog contract={contract} bets={bets} />
|
||||||
|
)}
|
||||||
</Row>
|
</Row>
|
||||||
</Col>
|
</Col>
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,6 +3,7 @@ import clsx from 'clsx'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
|
import { Bet } from '../../../common/bet'
|
||||||
|
|
||||||
import { Contract } from '../../../common/contract'
|
import { Contract } from '../../../common/contract'
|
||||||
import { formatMoney } from '../../../common/util/format'
|
import { formatMoney } from '../../../common/util/format'
|
||||||
|
@ -22,8 +23,8 @@ import { FoldTagList } from '../tags-list'
|
||||||
import { Title } from '../title'
|
import { Title } from '../title'
|
||||||
import { TweetButton } from '../tweet-button'
|
import { TweetButton } from '../tweet-button'
|
||||||
|
|
||||||
export function ContractInfoDialog(props: { contract: Contract }) {
|
export function ContractInfoDialog(props: { contract: Contract; bets: Bet[] }) {
|
||||||
const { contract } = props
|
const { contract, bets } = props
|
||||||
|
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
|
|
||||||
|
@ -36,6 +37,7 @@ export function ContractInfoDialog(props: { contract: Contract }) {
|
||||||
const formatTime = (dt: number) => dayjs(dt).format('MMM DD, YYYY hh:mm a z')
|
const formatTime = (dt: number) => dayjs(dt).format('MMM DD, YYYY hh:mm a z')
|
||||||
|
|
||||||
const { createdTime, closeTime, resolutionTime } = contract
|
const { createdTime, closeTime, resolutionTime } = contract
|
||||||
|
const tradersCount = _.uniqBy(bets, 'userId').length
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
@ -82,6 +84,11 @@ export function ContractInfoDialog(props: { contract: Contract }) {
|
||||||
<td>{formatMoney(contract.volume)}</td>
|
<td>{formatMoney(contract.volume)}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Traders</td>
|
||||||
|
<td>{tradersCount}</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
{contract.mechanism === 'cpmm-1' && (
|
{contract.mechanism === 'cpmm-1' && (
|
||||||
<tr>
|
<tr>
|
||||||
<td>Liquidity</td>
|
<td>Liquidity</td>
|
||||||
|
|
|
@ -56,7 +56,11 @@ export const ContractOverview = (props: {
|
||||||
)}
|
)}
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
<ContractDetails contract={contract} isCreator={isCreator} />
|
<ContractDetails
|
||||||
|
contract={contract}
|
||||||
|
bets={bets}
|
||||||
|
isCreator={isCreator}
|
||||||
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
|
|
||||||
<Spacer h={4} />
|
<Spacer h={4} />
|
||||||
|
|
|
@ -113,6 +113,7 @@ function ContractEmbed(props: { contract: Contract; bets: Bet[] }) {
|
||||||
<Row className="items-center justify-between gap-4 px-2">
|
<Row className="items-center justify-between gap-4 px-2">
|
||||||
<ContractDetails
|
<ContractDetails
|
||||||
contract={contract}
|
contract={contract}
|
||||||
|
bets={bets}
|
||||||
isCreator={false}
|
isCreator={false}
|
||||||
hideShareButtons
|
hideShareButtons
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user