2022-08-05 05:22:45 +00:00
|
|
|
|
import clsx from 'clsx'
|
|
|
|
|
import { ShareIcon } from '@heroicons/react/outline'
|
|
|
|
|
|
|
|
|
|
import { Row } from '../layout/row'
|
|
|
|
|
import { Contract } from 'web/lib/firebase/contracts'
|
2022-08-30 23:13:25 +00:00
|
|
|
|
import React, { useState } from 'react'
|
2022-08-05 05:22:45 +00:00
|
|
|
|
import { Button } from 'web/components/button'
|
2022-09-01 21:42:50 +00:00
|
|
|
|
import { useUser } from 'web/hooks/use-user'
|
2022-08-05 05:22:45 +00:00
|
|
|
|
import { ShareModal } from './share-modal'
|
2022-08-24 21:09:28 +00:00
|
|
|
|
import { FollowMarketButton } from 'web/components/follow-market-button'
|
2022-08-30 15:38:59 +00:00
|
|
|
|
import { LikeMarketButton } from 'web/components/contract/like-market-button'
|
2022-08-30 23:13:25 +00:00
|
|
|
|
import { ContractInfoDialog } from 'web/components/contract/contract-info-dialog'
|
|
|
|
|
import { Col } from 'web/components/layout/col'
|
2022-09-01 16:02:41 +00:00
|
|
|
|
import { withTracking } from 'web/lib/service/analytics'
|
|
|
|
|
import { CreateChallengeModal } from 'web/components/challenges/create-challenge-modal'
|
2022-09-01 16:11:08 +00:00
|
|
|
|
import { CHALLENGES_ENABLED } from 'common/challenge'
|
2022-08-05 05:22:45 +00:00
|
|
|
|
|
2022-09-01 21:42:50 +00:00
|
|
|
|
export function ExtraContractActionsRow(props: { contract: Contract }) {
|
|
|
|
|
const { contract } = props
|
2022-09-01 16:02:41 +00:00
|
|
|
|
const { outcomeType, resolution } = contract
|
2022-09-01 21:42:50 +00:00
|
|
|
|
const user = useUser()
|
2022-08-05 05:22:45 +00:00
|
|
|
|
const [isShareOpen, setShareOpen] = useState(false)
|
2022-09-01 16:02:41 +00:00
|
|
|
|
const [openCreateChallengeModal, setOpenCreateChallengeModal] =
|
|
|
|
|
useState(false)
|
|
|
|
|
const showChallenge =
|
|
|
|
|
user && outcomeType === 'BINARY' && !resolution && CHALLENGES_ENABLED
|
2022-08-05 05:22:45 +00:00
|
|
|
|
|
|
|
|
|
return (
|
2022-08-30 23:13:25 +00:00
|
|
|
|
<Row className={'mt-0.5 justify-around sm:mt-2 lg:justify-start'}>
|
2022-08-24 23:07:22 +00:00
|
|
|
|
<Button
|
|
|
|
|
size="lg"
|
|
|
|
|
color="gray-white"
|
|
|
|
|
className={'flex'}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
setShareOpen(true)
|
|
|
|
|
}}
|
|
|
|
|
>
|
2022-08-30 23:13:25 +00:00
|
|
|
|
<Col className={'items-center sm:flex-row'}>
|
|
|
|
|
<ShareIcon
|
|
|
|
|
className={clsx('h-[24px] w-5 sm:mr-2')}
|
|
|
|
|
aria-hidden="true"
|
|
|
|
|
/>
|
|
|
|
|
<span>Share</span>
|
|
|
|
|
</Col>
|
|
|
|
|
|
2022-08-24 23:07:22 +00:00
|
|
|
|
<ShareModal
|
|
|
|
|
isOpen={isShareOpen}
|
|
|
|
|
setOpen={setShareOpen}
|
|
|
|
|
contract={contract}
|
|
|
|
|
user={user}
|
|
|
|
|
/>
|
|
|
|
|
</Button>
|
2022-09-01 16:02:41 +00:00
|
|
|
|
{showChallenge && (
|
|
|
|
|
<Button
|
|
|
|
|
size="lg"
|
|
|
|
|
color="gray-white"
|
|
|
|
|
className={'flex hidden max-w-xs self-center sm:inline-block'}
|
|
|
|
|
onClick={withTracking(
|
|
|
|
|
() => setOpenCreateChallengeModal(true),
|
|
|
|
|
'click challenge button'
|
|
|
|
|
)}
|
|
|
|
|
>
|
|
|
|
|
<span>⚔️ Challenge</span>
|
|
|
|
|
<CreateChallengeModal
|
|
|
|
|
isOpen={openCreateChallengeModal}
|
|
|
|
|
setOpen={setOpenCreateChallengeModal}
|
|
|
|
|
user={user}
|
|
|
|
|
contract={contract}
|
|
|
|
|
/>
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
2022-08-05 05:22:45 +00:00
|
|
|
|
|
2022-08-24 21:09:28 +00:00
|
|
|
|
<FollowMarketButton contract={contract} user={user} />
|
2022-08-30 23:13:25 +00:00
|
|
|
|
{user?.id !== contract.creatorId && (
|
2022-08-30 15:38:59 +00:00
|
|
|
|
<LikeMarketButton contract={contract} user={user} />
|
2022-08-30 23:13:25 +00:00
|
|
|
|
)}
|
|
|
|
|
<Col className={'justify-center md:hidden'}>
|
|
|
|
|
<ContractInfoDialog contract={contract} />
|
|
|
|
|
</Col>
|
2022-08-05 05:22:45 +00:00
|
|
|
|
</Row>
|
|
|
|
|
)
|
|
|
|
|
}
|