Link to user from feed mentions. Show name instead of username in card.
This commit is contained in:
parent
07a7fc219b
commit
1683a3842b
|
@ -151,9 +151,10 @@ function MyContractBets(props: { contract: Contract; bets: Bet[] }) {
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
<Row className="gap-2 text-gray-500 text-sm">
|
<Row className="gap-2 text-gray-500 text-sm">
|
||||||
<div>
|
<UserLink
|
||||||
<UserLink username={contract.creatorUsername} />
|
name={contract.creatorName}
|
||||||
</div>
|
username={contract.creatorUsername}
|
||||||
|
/>
|
||||||
{resolution && (
|
{resolution && (
|
||||||
<>
|
<>
|
||||||
<div>•</div>
|
<div>•</div>
|
||||||
|
|
|
@ -102,15 +102,17 @@ export function AbbrContractDetails(props: {
|
||||||
showHotVolume?: boolean
|
showHotVolume?: boolean
|
||||||
}) {
|
}) {
|
||||||
const { contract, showHotVolume } = props
|
const { contract, showHotVolume } = props
|
||||||
const { volume24Hours } = contract
|
const { volume24Hours, creatorName, creatorUsername } = contract
|
||||||
const { truePool } = contractMetrics(contract)
|
const { truePool } = contractMetrics(contract)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Col className={clsx('text-sm text-gray-500 gap-2')}>
|
<Col className={clsx('text-sm text-gray-500 gap-2')}>
|
||||||
<Row className="gap-2 flex-wrap">
|
<Row className="gap-2 flex-wrap">
|
||||||
<div className="whitespace-nowrap">
|
<UserLink
|
||||||
<UserLink username={contract.creatorUsername} />
|
className="whitespace-nowrap"
|
||||||
</div>
|
name={creatorName}
|
||||||
|
username={creatorUsername}
|
||||||
|
/>
|
||||||
<div>•</div>
|
<div>•</div>
|
||||||
{showHotVolume ? (
|
{showHotVolume ? (
|
||||||
<div className="whitespace-nowrap">
|
<div className="whitespace-nowrap">
|
||||||
|
@ -127,7 +129,8 @@ export function AbbrContractDetails(props: {
|
||||||
|
|
||||||
export function ContractDetails(props: { contract: Contract }) {
|
export function ContractDetails(props: { contract: Contract }) {
|
||||||
const { contract } = props
|
const { contract } = props
|
||||||
const { question, description, closeTime } = contract
|
const { question, description, closeTime, creatorName, creatorUsername } =
|
||||||
|
contract
|
||||||
const { truePool, createdDate, resolvedDate } = contractMetrics(contract)
|
const { truePool, createdDate, resolvedDate } = contractMetrics(contract)
|
||||||
|
|
||||||
const tags = parseTags(`${question} ${description}`).map((tag) => `#${tag}`)
|
const tags = parseTags(`${question} ${description}`).map((tag) => `#${tag}`)
|
||||||
|
@ -135,9 +138,11 @@ export function ContractDetails(props: { contract: Contract }) {
|
||||||
return (
|
return (
|
||||||
<Col className="text-sm text-gray-500 gap-2 sm:flex-row sm:flex-wrap">
|
<Col className="text-sm text-gray-500 gap-2 sm:flex-row sm:flex-wrap">
|
||||||
<Row className="gap-2 flex-wrap">
|
<Row className="gap-2 flex-wrap">
|
||||||
<div className="whitespace-nowrap">
|
<UserLink
|
||||||
<UserLink username={contract.creatorUsername} />
|
className="whitespace-nowrap"
|
||||||
</div>
|
name={creatorName}
|
||||||
|
username={creatorUsername}
|
||||||
|
/>
|
||||||
<div className="">•</div>
|
<div className="">•</div>
|
||||||
<div className="whitespace-nowrap">
|
<div className="whitespace-nowrap">
|
||||||
{resolvedDate ? `${createdDate} - ${resolvedDate}` : createdDate}
|
{resolvedDate ? `${createdDate} - ${resolvedDate}` : createdDate}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import { formatMoney } from '../lib/util/format'
|
||||||
import { ResolutionOrChance } from './contract-card'
|
import { ResolutionOrChance } from './contract-card'
|
||||||
import { SiteLink } from './site-link'
|
import { SiteLink } from './site-link'
|
||||||
import { Col } from './layout/col'
|
import { Col } from './layout/col'
|
||||||
|
import { UserLink } from './user-page'
|
||||||
dayjs.extend(relativeTime)
|
dayjs.extend(relativeTime)
|
||||||
|
|
||||||
function FeedComment(props: { activityItem: any }) {
|
function FeedComment(props: { activityItem: any }) {
|
||||||
|
@ -205,6 +206,8 @@ export function ContractDescription(props: {
|
||||||
|
|
||||||
function FeedQuestion(props: { contract: Contract }) {
|
function FeedQuestion(props: { contract: Contract }) {
|
||||||
const { contract } = props
|
const { contract } = props
|
||||||
|
const { creatorName, creatorUsername, createdTime, question, resolution } =
|
||||||
|
contract
|
||||||
const { probPercent } = contractMetrics(contract)
|
const { probPercent } = contractMetrics(contract)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -218,19 +221,23 @@ function FeedQuestion(props: { contract: Contract }) {
|
||||||
</div>
|
</div>
|
||||||
<div className="min-w-0 flex-1 py-1.5">
|
<div className="min-w-0 flex-1 py-1.5">
|
||||||
<div className="text-sm text-gray-500 mb-2">
|
<div className="text-sm text-gray-500 mb-2">
|
||||||
<span className="text-gray-900">{contract.creatorName}</span> asked{' '}
|
<UserLink
|
||||||
<Timestamp time={contract.createdTime} />
|
className="text-gray-900"
|
||||||
|
name={creatorName}
|
||||||
|
username={creatorUsername}
|
||||||
|
/>{' '}
|
||||||
|
asked <Timestamp time={createdTime} />
|
||||||
</div>
|
</div>
|
||||||
<Col className="items-start sm:flex-row justify-between gap-2 sm:gap-4 mb-4 mr-2">
|
<Col className="items-start sm:flex-row justify-between gap-2 sm:gap-4 mb-4 mr-2">
|
||||||
<SiteLink
|
<SiteLink
|
||||||
href={contractPath(contract)}
|
href={contractPath(contract)}
|
||||||
className="text-lg sm:text-xl text-indigo-700"
|
className="text-lg sm:text-xl text-indigo-700"
|
||||||
>
|
>
|
||||||
{contract.question}
|
{question}
|
||||||
</SiteLink>
|
</SiteLink>
|
||||||
<ResolutionOrChance
|
<ResolutionOrChance
|
||||||
className="items-center"
|
className="items-center"
|
||||||
resolution={contract.resolution}
|
resolution={resolution}
|
||||||
probPercent={probPercent}
|
probPercent={probPercent}
|
||||||
/>
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
|
@ -242,6 +249,7 @@ function FeedQuestion(props: { contract: Contract }) {
|
||||||
|
|
||||||
function FeedDescription(props: { contract: Contract }) {
|
function FeedDescription(props: { contract: Contract }) {
|
||||||
const { contract } = props
|
const { contract } = props
|
||||||
|
const { creatorName, creatorUsername } = contract
|
||||||
const user = useUser()
|
const user = useUser()
|
||||||
const isCreator = user?.id === contract.creatorId
|
const isCreator = user?.id === contract.creatorId
|
||||||
|
|
||||||
|
@ -256,8 +264,12 @@ function FeedDescription(props: { contract: Contract }) {
|
||||||
</div>
|
</div>
|
||||||
<div className="min-w-0 flex-1 py-1.5">
|
<div className="min-w-0 flex-1 py-1.5">
|
||||||
<div className="text-sm text-gray-500">
|
<div className="text-sm text-gray-500">
|
||||||
<span className="text-gray-900">{contract.creatorName}</span> created
|
<UserLink
|
||||||
this market <Timestamp time={contract.createdTime} />
|
className="text-gray-900"
|
||||||
|
name={creatorName}
|
||||||
|
username={creatorUsername}
|
||||||
|
/>{' '}
|
||||||
|
created this market <Timestamp time={contract.createdTime} />
|
||||||
</div>
|
</div>
|
||||||
<ContractDescription contract={contract} isCreator={isCreator} />
|
<ContractDescription contract={contract} isCreator={isCreator} />
|
||||||
</div>
|
</div>
|
||||||
|
@ -280,6 +292,7 @@ function OutcomeIcon(props: { outcome?: 'YES' | 'NO' | 'CANCEL' }) {
|
||||||
|
|
||||||
function FeedResolve(props: { contract: Contract }) {
|
function FeedResolve(props: { contract: Contract }) {
|
||||||
const { contract } = props
|
const { contract } = props
|
||||||
|
const { creatorName, creatorUsername } = contract
|
||||||
const resolution = contract.resolution || 'CANCEL'
|
const resolution = contract.resolution || 'CANCEL'
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -293,8 +306,12 @@ function FeedResolve(props: { contract: Contract }) {
|
||||||
</div>
|
</div>
|
||||||
<div className="min-w-0 flex-1 py-1.5">
|
<div className="min-w-0 flex-1 py-1.5">
|
||||||
<div className="text-sm text-gray-500">
|
<div className="text-sm text-gray-500">
|
||||||
<span className="text-gray-900">{contract.creatorName}</span> resolved
|
<UserLink
|
||||||
this market to <OutcomeLabel outcome={resolution} />{' '}
|
className="text-gray-900"
|
||||||
|
name={creatorName}
|
||||||
|
username={creatorUsername}
|
||||||
|
/>{' '}
|
||||||
|
resolved this market to <OutcomeLabel outcome={resolution} />{' '}
|
||||||
<Timestamp time={contract.resolutionTime || 0} />
|
<Timestamp time={contract.resolutionTime || 0} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -7,12 +7,18 @@ import { SEO } from './SEO'
|
||||||
import { Page } from './page'
|
import { Page } from './page'
|
||||||
import { SiteLink } from './site-link'
|
import { SiteLink } from './site-link'
|
||||||
|
|
||||||
export function UserLink(props: { username: string; className?: string }) {
|
export function UserLink(props: {
|
||||||
const { username, className } = props
|
name: string
|
||||||
|
username: string
|
||||||
|
showUsername?: boolean
|
||||||
|
className?: string
|
||||||
|
}) {
|
||||||
|
const { name, username, showUsername, className } = props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SiteLink href={`/${username}`} className={className}>
|
<SiteLink href={`/${username}`} className={className}>
|
||||||
@{username}
|
{name}
|
||||||
|
{showUsername && ` (@${username})`}
|
||||||
</SiteLink>
|
</SiteLink>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user