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 ( -
+
{user?.avatarUrl ? ( @@ -92,13 +97,13 @@ export default function FeedCreate(props: { user?: User }) { onClick={(e) => e.stopPropagation()} onChange={(e) => setQuestion(e.target.value || '')} /> - +
{/* Hide component instead of deleting, so edits to NewContract don't get lost */}
- +
{/* Show a fake "Create Market" button, which gets replaced with the NewContract one*/} diff --git a/web/pages/create.tsx b/web/pages/create.tsx index f8e76a7f..d651a7be 100644 --- a/web/pages/create.tsx +++ b/web/pages/create.tsx @@ -47,8 +47,8 @@ export default function Create() { } // Allow user to create a new contract -export function NewContract(props: { question: string }) { - const question = props.question +export function NewContract(props: { question: string; tag?: string }) { + const { question, tag } = props const creator = useUser() useEffect(() => { @@ -104,6 +104,7 @@ export function NewContract(props: { question: string }) { initialProb, ante, closeTime, + tags: tag ? [tag] : [], }).then((r) => r.data || {}) if (result.status !== 'success') { diff --git a/web/pages/fold/[...slugs]/index.tsx b/web/pages/fold/[...slugs]/index.tsx index a6f95b76..299a9662 100644 --- a/web/pages/fold/[...slugs]/index.tsx +++ b/web/pages/fold/[...slugs]/index.tsx @@ -28,10 +28,11 @@ import { useRouter } from 'next/router' import clsx from 'clsx' import { scoreCreators, scoreTraders } from '../../../lib/firebase/scoring' import { Leaderboard } from '../../../components/leaderboard' -import { formatMoney } from '../../../lib/util/format' +import { formatMoney, toCamelCase } from '../../../lib/util/format' import { EditFoldButton } from '../../../components/edit-fold-button' import Custom404 from '../../404' import { FollowFoldButton } from '../../../components/follow-fold-button' +import FeedCreate from '../../../components/feed-create' export async function getStaticProps(props: { params: { slugs: string[] } }) { const { slugs } = props.params @@ -213,6 +214,13 @@ export default function FoldPage(props: { {(page === 'activity' || page === 'markets') && ( + {user !== null && ( + + )} {page === 'activity' ? ( <>