diff --git a/common/new-contract.ts b/common/new-contract.ts index a4617f99..9ee82c9f 100644 --- a/common/new-contract.ts +++ b/common/new-contract.ts @@ -12,12 +12,15 @@ export function getNewContract( description: string, initialProb: number, ante: number, - closeTime: number + closeTime: number, + extraTags: string[] ) { const { sharesYes, sharesNo, poolYes, poolNo, phantomYes, phantomNo } = calcStartPool(initialProb, ante) - const tags = parseTags(`${question} ${description}`) + const tags = parseTags( + `${extraTags.map((tag) => `#${tag}`).join(' ')} ${question} ${description}` + ) const lowercaseTags = tags.map((tag) => tag.toLowerCase()) const contract: Contract = { diff --git a/functions/src/create-contract.ts b/functions/src/create-contract.ts index 42021e21..8ab38b88 100644 --- a/functions/src/create-contract.ts +++ b/functions/src/create-contract.ts @@ -18,6 +18,7 @@ export const createContract = functions initialProb: number ante: number closeTime: number + tags?: string[] }, context ) => { @@ -27,7 +28,7 @@ export const createContract = functions const creator = await getUser(userId) if (!creator) return { status: 'error', message: 'User not found' } - const { question, description, initialProb, ante, closeTime } = data + const { question, description, initialProb, ante, closeTime, tags } = data if (!question || !initialProb) return { status: 'error', message: 'Missing contract attributes' } @@ -65,7 +66,8 @@ export const createContract = functions description, initialProb, ante, - closeTime + closeTime, + tags ?? [] ) if (ante) await chargeUser(creator.id, ante) diff --git a/web/components/feed-create.tsx b/web/components/feed-create.tsx index 23ab70a0..25ffc965 100644 --- a/web/components/feed-create.tsx +++ b/web/components/feed-create.tsx @@ -9,6 +9,7 @@ import { ContractsGrid } from './contracts-list' import { Contract } from '../../common/contract' import { TagsList } from './tags-list' import { Col } from './layout/col' +import clsx from 'clsx' export function FeedPromo(props: { hotContracts: Contract[] }) { const { hotContracts } = props @@ -54,8 +55,12 @@ export function FeedPromo(props: { hotContracts: Contract[] }) { ) } -export default function FeedCreate(props: { user?: User }) { - const { user } = props +export default function FeedCreate(props: { + user?: User + tag?: string + className?: string +}) { + const { user, tag, className } = props const [question, setQuestion] = useState('') const placeholders = [ @@ -72,7 +77,7 @@ export default function FeedCreate(props: { user?: User }) { const placeholder = placeholders[daysSinceEpoch % placeholders.length] return ( -