💔💔💔

This commit is contained in:
Ian Philips 2022-08-24 15:09:28 -06:00 committed by mantikoros
parent 2e0957d739
commit c753313546
3 changed files with 24 additions and 33 deletions

View File

@ -22,7 +22,6 @@ import { ContractDescription } from './contract-description'
import { ContractDetails } from './contract-details' import { ContractDetails } from './contract-details'
import { NumericGraph } from './numeric-graph' import { NumericGraph } from './numeric-graph'
import { ShareRow } from './share-row' import { ShareRow } from './share-row'
import { FollowMarketButton } from 'web/components/follow-market-button'
export const ContractOverview = (props: { export const ContractOverview = (props: {
contract: Contract contract: Contract
@ -45,18 +44,7 @@ export const ContractOverview = (props: {
<div className="text-2xl text-indigo-700 md:text-3xl"> <div className="text-2xl text-indigo-700 md:text-3xl">
<Linkify text={question} /> <Linkify text={question} />
</div> </div>
{(outcomeType === 'FREE_RESPONSE' ||
outcomeType === 'MULTIPLE_CHOICE') &&
!resolution && (
<div className={'xl:hidden'}>
<FollowMarketButton contract={contract} user={user} />
</div>
)}
<Row className={'hidden gap-3 xl:flex'}> <Row className={'hidden gap-3 xl:flex'}>
<div className={'mt-2'}>
<FollowMarketButton contract={contract} user={user} />
</div>
{isBinary && ( {isBinary && (
<BinaryResolutionOrChance <BinaryResolutionOrChance
className="items-end" className="items-end"
@ -84,21 +72,15 @@ export const ContractOverview = (props: {
{isBinary ? ( {isBinary ? (
<Row className="items-center justify-between gap-4 xl:hidden"> <Row className="items-center justify-between gap-4 xl:hidden">
<BinaryResolutionOrChance contract={contract} /> <BinaryResolutionOrChance contract={contract} />
<Row className={'items-start gap-2'}>
<FollowMarketButton contract={contract} user={user} />
{tradingAllowed(contract) && ( {tradingAllowed(contract) && (
<BetButton contract={contract as CPMMBinaryContract} /> <BetButton contract={contract as CPMMBinaryContract} />
)} )}
</Row> </Row>
</Row>
) : isPseudoNumeric ? ( ) : isPseudoNumeric ? (
<Row className="items-center justify-between gap-4 xl:hidden"> <Row className="items-center justify-between gap-4 xl:hidden">
<PseudoNumericResolutionOrExpectation contract={contract} /> <PseudoNumericResolutionOrExpectation contract={contract} />
<Row className={'items-start gap-2'}>
<FollowMarketButton contract={contract} user={user} />
{tradingAllowed(contract) && <BetButton contract={contract} />} {tradingAllowed(contract) && <BetButton contract={contract} />}
</Row> </Row>
</Row>
) : ( ) : (
(outcomeType === 'FREE_RESPONSE' || (outcomeType === 'FREE_RESPONSE' ||
outcomeType === 'MULTIPLE_CHOICE') && outcomeType === 'MULTIPLE_CHOICE') &&

View File

@ -10,6 +10,7 @@ import { User } from 'common/user'
import { CHALLENGES_ENABLED } from 'common/challenge' import { CHALLENGES_ENABLED } from 'common/challenge'
import { ShareModal } from './share-modal' import { ShareModal } from './share-modal'
import { withTracking } from 'web/lib/service/analytics' import { withTracking } from 'web/lib/service/analytics'
import { FollowMarketButton } from 'web/components/follow-market-button'
export function ShareRow(props: { export function ShareRow(props: {
contract: Contract contract: Contract
@ -62,6 +63,7 @@ export function ShareRow(props: {
/> />
</Button> </Button>
)} )}
<FollowMarketButton contract={contract} user={user} />
</Row> </Row>
) )
} }

View File

@ -5,7 +5,7 @@ import {
unFollowContract, unFollowContract,
} from 'web/lib/firebase/contracts' } from 'web/lib/firebase/contracts'
import toast from 'react-hot-toast' import toast from 'react-hot-toast'
import { CheckIcon, HeartIcon } from '@heroicons/react/outline' import { CheckIcon, EyeIcon, EyeOffIcon } from '@heroicons/react/outline'
import clsx from 'clsx' import clsx from 'clsx'
import { User } from 'common/user' import { User } from 'common/user'
import { useContractFollows } from 'web/hooks/use-follows' import { useContractFollows } from 'web/hooks/use-follows'
@ -13,6 +13,7 @@ import { firebaseLogin, updateUser } from 'web/lib/firebase/users'
import { track } from 'web/lib/service/analytics' import { track } from 'web/lib/service/analytics'
import { FollowMarketModal } from 'web/components/contract/follow-market-modal' import { FollowMarketModal } from 'web/components/contract/follow-market-modal'
import { useState } from 'react' import { useState } from 'react'
import { Row } from 'web/components/layout/row'
export const FollowMarketButton = (props: { export const FollowMarketButton = (props: {
contract: Contract contract: Contract
@ -30,7 +31,7 @@ export const FollowMarketButton = (props: {
if (!user) return firebaseLogin() if (!user) return firebaseLogin()
if (followers?.includes(user.id)) { if (followers?.includes(user.id)) {
await unFollowContract(contract.id, user.id) await unFollowContract(contract.id, user.id)
toast('Notifications from this market are now silenced.', { toast("You'll no longer receive notifications from this market", {
icon: <CheckIcon className={'text-primary h-5 w-5'} />, icon: <CheckIcon className={'text-primary h-5 w-5'} />,
}) })
track('Unfollow Market', { track('Unfollow Market', {
@ -38,7 +39,7 @@ export const FollowMarketButton = (props: {
}) })
} else { } else {
await followContract(contract.id, user.id) await followContract(contract.id, user.id)
toast('You are now following this market!', { toast("You'll now receive notifications from this market!", {
icon: <CheckIcon className={'text-primary h-5 w-5'} />, icon: <CheckIcon className={'text-primary h-5 w-5'} />,
}) })
track('Follow Market', { track('Follow Market', {
@ -54,15 +55,21 @@ export const FollowMarketButton = (props: {
}} }}
> >
{followers?.includes(user?.id ?? 'nope') ? ( {followers?.includes(user?.id ?? 'nope') ? (
<HeartIcon <Row className={'gap-2'}>
className={clsx('h-6 w-6 fill-red-600 stroke-red-600 xl:h-7 xl:w-7')} <EyeOffIcon
aria-hidden="true"
/>
) : (
<HeartIcon
className={clsx('h-6 w-6 xl:h-7 xl:w-7')} className={clsx('h-6 w-6 xl:h-7 xl:w-7')}
aria-hidden="true" aria-hidden="true"
/> />
Unfollow
</Row>
) : (
<Row className={'gap-2'}>
<EyeIcon
className={clsx('h-6 w-6 xl:h-7 xl:w-7')}
aria-hidden="true"
/>
Follow
</Row>
)} )}
<FollowMarketModal <FollowMarketModal
open={open} open={open}