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'
|
|
|
|
|
import { useState } from 'react'
|
|
|
|
|
import { Button } from 'web/components/button'
|
|
|
|
|
import { CreateChallengeModal } from '../challenges/create-challenge-modal'
|
|
|
|
|
import { User } from 'common/user'
|
|
|
|
|
import { CHALLENGES_ENABLED } from 'common/challenge'
|
|
|
|
|
import { ShareModal } from './share-modal'
|
2022-08-05 20:42:02 +00:00
|
|
|
|
import { withTracking } from 'web/lib/service/analytics'
|
2022-08-05 05:22:45 +00:00
|
|
|
|
|
|
|
|
|
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 [isOpen, setIsOpen] = useState(false)
|
|
|
|
|
const [isShareOpen, setShareOpen] = useState(false)
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Row className="mt-2">
|
|
|
|
|
<Button
|
|
|
|
|
size="lg"
|
|
|
|
|
color="gray-white"
|
|
|
|
|
className={'flex'}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
setShareOpen(true)
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<ShareIcon className={clsx('mr-2 h-[24px] w-5')} aria-hidden="true" />
|
|
|
|
|
Share
|
|
|
|
|
<ShareModal
|
|
|
|
|
isOpen={isShareOpen}
|
|
|
|
|
setOpen={setShareOpen}
|
|
|
|
|
contract={contract}
|
|
|
|
|
user={user}
|
|
|
|
|
/>
|
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
|
|
{showChallenge && (
|
2022-08-05 20:38:12 +00:00
|
|
|
|
<Button
|
|
|
|
|
size="lg"
|
|
|
|
|
color="gray-white"
|
2022-08-05 20:42:02 +00:00
|
|
|
|
onClick={withTracking(
|
|
|
|
|
() => setIsOpen(true),
|
|
|
|
|
'click challenge button'
|
|
|
|
|
)}
|
2022-08-05 20:38:12 +00:00
|
|
|
|
>
|
2022-08-05 05:22:45 +00:00
|
|
|
|
⚔️ Challenge
|
|
|
|
|
<CreateChallengeModal
|
|
|
|
|
isOpen={isOpen}
|
|
|
|
|
setOpen={setIsOpen}
|
|
|
|
|
user={user}
|
|
|
|
|
contract={contract}
|
|
|
|
|
/>
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
|
|
|
|
</Row>
|
|
|
|
|
)
|
|
|
|
|
}
|