diff --git a/web/components/button.tsx b/web/components/button.tsx index 5c1e15f8..462670bd 100644 --- a/web/components/button.tsx +++ b/web/components/button.tsx @@ -52,7 +52,7 @@ export function Button(props: { color === 'gradient' && 'bg-gradient-to-r from-indigo-500 to-blue-500 text-white hover:from-indigo-700 hover:to-blue-700', color === 'gray-white' && - 'text-greyscale-6 hover:bg-greyscale-2 bg-white', + 'border-none bg-white text-gray-500 shadow-none hover:bg-gray-200', className )} disabled={disabled} diff --git a/web/components/challenges/create-challenge-button.tsx b/web/components/challenges/create-challenge-modal.tsx similarity index 85% rename from web/components/challenges/create-challenge-button.tsx rename to web/components/challenges/create-challenge-modal.tsx index 6eab9bc5..3a0e857a 100644 --- a/web/components/challenges/create-challenge-button.tsx +++ b/web/components/challenges/create-challenge-modal.tsx @@ -2,6 +2,7 @@ import clsx from 'clsx' import dayjs from 'dayjs' import React, { useEffect, useState } from 'react' import { LinkIcon, SwitchVerticalIcon } from '@heroicons/react/outline' +import toast from 'react-hot-toast' import { Col } from '../layout/col' import { Row } from '../layout/row' @@ -16,7 +17,6 @@ import { formatMoney } from 'common/util/format' import { NoLabel, YesLabel } from '../outcome-label' import { QRCode } from '../qr-code' import { copyToClipboard } from 'web/lib/util/copy' -import toast from 'react-hot-toast' type challengeInfo = { amount: number @@ -25,48 +25,41 @@ type challengeInfo = { outcome: 'YES' | 'NO' | number acceptorAmount: number } -export function CreateChallengeButton(props: { + +export function CreateChallengeModal(props: { user: User | null | undefined contract: BinaryContract + isOpen: boolean + setOpen: (open: boolean) => void }) { - const { user, contract } = props - const [open, setOpen] = useState(false) + const { user, contract, isOpen, setOpen } = props const [challengeSlug, setChallengeSlug] = useState('') return ( - <> - setOpen(newOpen)} size={'sm'}> - - {/*// add a sign up to challenge button?*/} - {user && ( - { - const challenge = await createChallenge({ - creator: user, - creatorAmount: newChallenge.amount, - expiresTime: newChallenge.expiresTime, - message: newChallenge.message, - acceptorAmount: newChallenge.acceptorAmount, - outcome: newChallenge.outcome, - contract: contract, - }) - challenge && setChallengeSlug(getChallengeUrl(challenge)) - }} - challengeSlug={challengeSlug} - /> - )} - - - - - + + + {/*// add a sign up to challenge button?*/} + {user && ( + { + const challenge = await createChallenge({ + creator: user, + creatorAmount: newChallenge.amount, + expiresTime: newChallenge.expiresTime, + message: newChallenge.message, + acceptorAmount: newChallenge.acceptorAmount, + outcome: newChallenge.outcome, + contract: contract, + }) + challenge && setChallengeSlug(getChallengeUrl(challenge)) + }} + challengeSlug={challengeSlug} + /> + )} + + ) } diff --git a/web/components/contract/contract-details.tsx b/web/components/contract/contract-details.tsx index 7a7242a0..9d12496d 100644 --- a/web/components/contract/contract-details.tsx +++ b/web/components/contract/contract-details.tsx @@ -5,13 +5,13 @@ import { TrendingUpIcon, UserGroupIcon, } from '@heroicons/react/outline' + import { Row } from '../layout/row' import { formatMoney } from 'common/util/format' import { UserLink } from '../user-page' import { Contract, contractMetrics, - contractPath, updateContract, } from 'web/lib/firebase/contracts' import dayjs from 'dayjs' @@ -24,11 +24,9 @@ import { Bet } from 'common/bet' import NewContractBadge from '../new-contract-badge' import { UserFollowButton } from '../follow-button' import { DAY_MS } from 'common/util/time' -import { ShareIconButton } from 'web/components/share-icon-button' import { useUser } from 'web/hooks/use-user' import { Editor } from '@tiptap/react' import { exhibitExts } from 'common/util/parse' -import { ENV_CONFIG } from 'common/envs/constants' import { Button } from 'web/components/button' import { Modal } from 'web/components/layout/modal' import { Col } from 'web/components/layout/col' @@ -228,14 +226,6 @@ export function ContractDetails(props: {
{volumeLabel}
- {!disabled && } diff --git a/web/components/contract/contract-overview.tsx b/web/components/contract/contract-overview.tsx index 28eabb04..b95bb02b 100644 --- a/web/components/contract/contract-overview.tsx +++ b/web/components/contract/contract-overview.tsx @@ -1,12 +1,13 @@ -import { contractUrl, tradingAllowed } from 'web/lib/firebase/contracts' +import React from 'react' +import clsx from 'clsx' + +import { tradingAllowed } from 'web/lib/firebase/contracts' import { Col } from '../layout/col' import { Spacer } from '../layout/spacer' import { ContractProbGraph } from './contract-prob-graph' import { useUser } from 'web/hooks/use-user' import { Row } from '../layout/row' import { Linkify } from '../linkify' -import clsx from 'clsx' - import { BinaryResolutionOrChance, FreeResponseResolutionOrChance, @@ -20,12 +21,7 @@ import { Contract, CPMMBinaryContract } from 'common/contract' import { ContractDescription } from './contract-description' import { ContractDetails } from './contract-details' import { NumericGraph } from './numeric-graph' -import { CreateChallengeButton } from 'web/components/challenges/create-challenge-button' -import React from 'react' -import { copyToClipboard } from 'web/lib/util/copy' -import toast from 'react-hot-toast' -import { LinkIcon } from '@heroicons/react/outline' -import { CHALLENGES_ENABLED } from 'common/challenge' +import { ShareRow } from './share-row' export const ContractOverview = (props: { contract: Contract @@ -40,7 +36,6 @@ export const ContractOverview = (props: { const isBinary = outcomeType === 'BINARY' const isPseudoNumeric = outcomeType === 'PSEUDO_NUMERIC' - const showChallenge = user && isBinary && !resolution && CHALLENGES_ENABLED return ( @@ -123,47 +118,12 @@ export const ContractOverview = (props: { )} {outcomeType === 'NUMERIC' && } - {/* {(contract.description || isCreator) && } */} + - {/**/} - {/* {showChallenge && (*/} - {/* */} - {/*
⚔️ Challenge a friend ⚔️
*/} - {/* */} - {/* */} - {/* )}*/} - {/* {isCreator && (*/} - {/* */} - {/*
Share your market
*/} - {/* */} - {/* */} - {/* )}*/} - {/*
*/} - - {showChallenge && ( - - - - )} - {isCreator && ( - - - - )} - ) } diff --git a/web/components/contract/share-row.tsx b/web/components/contract/share-row.tsx new file mode 100644 index 00000000..a94c6a02 --- /dev/null +++ b/web/components/contract/share-row.tsx @@ -0,0 +1,68 @@ +import { LinkIcon } from '@heroicons/react/outline' +import clsx from 'clsx' +import toast from 'react-hot-toast' + +import { Row } from '../layout/row' +import { Contract, contractPath } from 'web/lib/firebase/contracts' +import { useState } from 'react' +import { ENV_CONFIG } from 'common/envs/constants' +import { Button } from 'web/components/button' +import { copyToClipboard } from 'web/lib/util/copy' +import { track } from 'web/lib/service/analytics' +import { CreateChallengeModal } from '../challenges/create-challenge-modal' +import { User } from 'common/user' +import { CHALLENGES_ENABLED } from 'common/challenge' + +export function ShareRow(props: { + contract: Contract + user: User | undefined | null +}) { + const { user, contract } = props + const { outcomeType, resolution } = contract + + const showChallenge = + user && outcomeType === 'BINARY' && !resolution && CHALLENGES_ENABLED + + const copyPayload = `https://${ENV_CONFIG.domain}${contractPath(contract)}${ + user?.username && contract.creatorUsername !== user?.username + ? '?referrer=' + user?.username + : '' + }` + + const linkIcon = ( +