Working tree is now the canonical repo. Off-chain play-money + trustless on-chain (FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution, mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
import { Contract, CreateableOutcomeType } from 'common/contract'
|
|
import { Col } from 'web/components/layout/col'
|
|
import { Row } from 'web/components/layout/row'
|
|
import { IconButton } from 'web/components/buttons/button'
|
|
import { XIcon } from '@heroicons/react/outline'
|
|
import { ContractMention } from 'web/components/contract/contract-mention'
|
|
import Link from 'next/link'
|
|
import { linkClass } from 'web/components/widgets/site-link'
|
|
const DUPES_TO_SHOW = 3
|
|
|
|
export const SimilarContractsSection = (props: {
|
|
similarContracts: Contract[]
|
|
setSimilarContracts: (c: Contract[]) => void
|
|
setDismissedSimilarContractTitles: (
|
|
func: (titles: string[]) => string[]
|
|
) => void
|
|
outcomeType: CreateableOutcomeType
|
|
question: string
|
|
}) => {
|
|
const {
|
|
similarContracts,
|
|
outcomeType,
|
|
question,
|
|
setSimilarContracts,
|
|
setDismissedSimilarContractTitles,
|
|
} = props
|
|
|
|
return (
|
|
<Col className={'space-y-1 '}>
|
|
<Row className={'justify-between px-1'}>
|
|
<Link
|
|
className={linkClass}
|
|
href={'/browse?q=' + encodeURIComponent(question)}
|
|
>
|
|
{similarContracts.length > DUPES_TO_SHOW
|
|
? `${DUPES_TO_SHOW}+`
|
|
: similarContracts.length}{' '}
|
|
Existing {outcomeType == 'POLL' ? 'poll(s)' : 'question(s)'}
|
|
</Link>
|
|
<IconButton
|
|
size={'2xs'}
|
|
aria-label="Dismiss similar questions"
|
|
onClick={() => {
|
|
setSimilarContracts([])
|
|
setDismissedSimilarContractTitles((titles) =>
|
|
titles.concat(question.toLowerCase().trim())
|
|
)
|
|
}}
|
|
>
|
|
<XIcon className="text-ink-500 h-4 w-4" />
|
|
</IconButton>
|
|
</Row>
|
|
{similarContracts.slice(0, DUPES_TO_SHOW).map((contract) => (
|
|
<Row key={contract.id} className="text-ink-700 pl-1 text-sm">
|
|
<ContractMention contract={contract} />
|
|
</Row>
|
|
))}
|
|
</Col>
|
|
)
|
|
}
|