From 7bc43682b81036453aea676a72e33e4f52279621 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Tue, 22 Feb 2022 21:38:53 -0600 Subject: [PATCH] Move tweet button into contract details --- web/components/contract-card.tsx | 27 +++++++++++++++++++++++--- web/components/contract-overview.tsx | 29 +--------------------------- 2 files changed, 25 insertions(+), 31 deletions(-) diff --git a/web/components/contract-card.tsx b/web/components/contract-card.tsx index 4682486d..55bf303a 100644 --- a/web/components/contract-card.tsx +++ b/web/components/contract-card.tsx @@ -19,6 +19,7 @@ import { fromNow } from '../lib/util/time' import { Avatar } from './avatar' import { Spacer } from './layout/spacer' import { useState } from 'react' +import { TweetButton } from './tweet-button' export function ContractCard(props: { contract: Contract @@ -165,12 +166,13 @@ function AbbrContractDetails(props: { export function ContractDetails(props: { contract: Contract isCreator?: boolean - children?: any }) { - const { contract, isCreator, children } = props + const { contract, isCreator } = props const { closeTime, creatorName, creatorUsername } = contract const { truePool, createdDate, resolvedDate } = contractMetrics(contract) + const tweetText = getTweetText(contract, !!isCreator) + return ( @@ -224,7 +226,7 @@ export function ContractDetails(props: {
{formatMoney(truePool)} pool
- {children} + ) @@ -316,3 +318,22 @@ function EditableCloseDate(props: { ) } + +const getTweetText = (contract: Contract, isCreator: boolean) => { + const { question, creatorName, resolution, outcomeType } = contract + const isBinary = outcomeType === 'BINARY' + + const tweetQuestion = isCreator + ? question + : `${question} Asked by ${creatorName}.` + const tweetDescription = resolution + ? `Resolved ${resolution}!` + : isBinary + ? `Currently ${getBinaryProbPercent( + contract + )} chance, place your bets here:` + : `Submit your own answer:` + const url = `https://manifold.markets${contractPath(contract)}` + + return `${tweetQuestion}\n\n${tweetDescription}\n\n${url}` +} diff --git a/web/components/contract-overview.tsx b/web/components/contract-overview.tsx index 9d33be93..fcdf3372 100644 --- a/web/components/contract-overview.tsx +++ b/web/components/contract-overview.tsx @@ -1,9 +1,7 @@ import { Contract, deleteContract, - contractPath, tradingAllowed, - getBinaryProbPercent, } from '../lib/firebase/contracts' import { Col } from './layout/col' import { Spacer } from './layout/spacer' @@ -15,7 +13,6 @@ import { Linkify } from './linkify' import clsx from 'clsx' import { ContractDetails, ResolutionOrChance } from './contract-card' import { ContractFeed } from './contract-feed' -import { TweetButton } from './tweet-button' import { Bet } from '../../common/bet' import { Comment } from '../../common/comment' import { RevealableTagsInput, TagsInput } from './tags-input' @@ -38,8 +35,6 @@ export const ContractOverview = (props: { const isCreator = user?.id === creatorId const isBinary = outcomeType === 'BINARY' - const tweetText = getTweetText(contract, isCreator) - return ( @@ -66,9 +61,7 @@ export const ContractOverview = (props: { )} - - - + {(isBinary || resolution) && ( @@ -78,7 +71,6 @@ export const ContractOverview = (props: { contract={contract} large /> - )} @@ -137,22 +129,3 @@ export const ContractOverview = (props: { ) } - -const getTweetText = (contract: Contract, isCreator: boolean) => { - const { question, creatorName, resolution, outcomeType } = contract - const isBinary = outcomeType === 'BINARY' - - const tweetQuestion = isCreator - ? question - : `${question} Asked by ${creatorName}.` - const tweetDescription = resolution - ? `Resolved ${resolution}!` - : isBinary - ? `Currently ${getBinaryProbPercent( - contract - )} chance, place your bets here:` - : `Submit your own answer:` - const url = `https://manifold.markets${contractPath(contract)}` - - return `${tweetQuestion}\n\n${tweetDescription}\n\n${url}` -}