made changes to shareButton
This commit is contained in:
parent
3d505a6dd9
commit
fe8f835ab2
|
@ -11,6 +11,7 @@ import { UserLink } from '../user-page'
|
|||
import {
|
||||
Contract,
|
||||
contractMetrics,
|
||||
contractPath,
|
||||
contractPool,
|
||||
updateContract,
|
||||
} from 'web/lib/firebase/contracts'
|
||||
|
@ -33,6 +34,7 @@ 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'
|
||||
|
||||
export type ShowTime = 'resolve-date' | 'close-date'
|
||||
|
||||
|
@ -222,9 +224,12 @@ export function ContractDetails(props: {
|
|||
<div className="whitespace-nowrap">{volumeLabel}</div>
|
||||
</Row>
|
||||
<ShareIconButton
|
||||
contract={contract}
|
||||
copyPayload={`https://${ENV_CONFIG.domain}${contractPath(contract)}${
|
||||
user?.username && contract.creatorUsername !== user?.username
|
||||
? '?referrer=' + user?.username
|
||||
: ''
|
||||
}`}
|
||||
toastClassName={'sm:-left-40 -left-24 min-w-[250%]'}
|
||||
username={user?.username}
|
||||
/>
|
||||
|
||||
{!disabled && <ContractInfoDialog contract={contract} bets={bets} />}
|
||||
|
|
|
@ -9,6 +9,7 @@ import { ShareIconButton } from './share-icon-button'
|
|||
import { DotsHorizontalIcon } from '@heroicons/react/solid'
|
||||
import { contractDetailsButtonClassName } from './contract/contract-info-dialog'
|
||||
import { useUserById } from 'web/hooks/use-user'
|
||||
import getManalinkUrl from 'web/get-manalink-url'
|
||||
export type ManalinkInfo = {
|
||||
expiresTime: number | null
|
||||
maxUses: number | null
|
||||
|
@ -129,12 +130,12 @@ export function ManalinkCardFromView(props: {
|
|||
{formatMoney(amount)}
|
||||
</div>
|
||||
<ShareIconButton
|
||||
manalink={link}
|
||||
toastClassName={'-left-48 min-w-[250%]'}
|
||||
buttonClassName={'transition-colors'}
|
||||
onCopyButtonClassName={
|
||||
'bg-gray-200 text-gray-600 transition-none hover:bg-gray-200 hover:text-gray-600'
|
||||
}
|
||||
copyPayload={getManalinkUrl(link.slug)}
|
||||
/>
|
||||
<button
|
||||
onClick={() => setDetails(!details)}
|
||||
|
|
|
@ -2,9 +2,7 @@ import React, { useState } from 'react'
|
|||
import { ShareIcon } from '@heroicons/react/outline'
|
||||
import clsx from 'clsx'
|
||||
|
||||
import { Contract } from 'common/contract'
|
||||
import { copyToClipboard } from 'web/lib/util/copy'
|
||||
import { contractPath } from 'web/lib/firebase/contracts'
|
||||
import { ENV_CONFIG } from 'common/envs/constants'
|
||||
import { ToastClipboard } from 'web/components/toast-clipboard'
|
||||
import { track } from 'web/lib/service/analytics'
|
||||
|
@ -14,16 +12,6 @@ import { groupPath } from 'web/lib/firebase/groups'
|
|||
import { Manalink } from 'common/manalink'
|
||||
import getManalinkUrl from 'web/get-manalink-url'
|
||||
|
||||
function copyContractWithReferral(contract: Contract, username?: string) {
|
||||
const postFix =
|
||||
username && contract.creatorUsername !== username
|
||||
? '?referrer=' + username
|
||||
: ''
|
||||
copyToClipboard(
|
||||
`https://${ENV_CONFIG.domain}${contractPath(contract)}${postFix}`
|
||||
)
|
||||
}
|
||||
|
||||
// Note: if a user arrives at a /group endpoint with a ?referral= query, they'll be added to the group automatically
|
||||
function copyGroupWithReferral(group: Group, username?: string) {
|
||||
const postFix = username ? '?referrer=' + username : ''
|
||||
|
@ -37,26 +25,20 @@ function copyManalink(manalink: Manalink) {
|
|||
}
|
||||
|
||||
export function ShareIconButton(props: {
|
||||
contract?: Contract
|
||||
group?: Group
|
||||
manalink?: Manalink
|
||||
buttonClassName?: string
|
||||
onCopyButtonClassName?: string
|
||||
toastClassName?: string
|
||||
username?: string
|
||||
children?: React.ReactNode
|
||||
iconClassName?: string
|
||||
copyPayload: string
|
||||
}) {
|
||||
const {
|
||||
contract,
|
||||
manalink,
|
||||
buttonClassName,
|
||||
onCopyButtonClassName,
|
||||
toastClassName,
|
||||
username,
|
||||
group,
|
||||
children,
|
||||
iconClassName,
|
||||
copyPayload,
|
||||
} = props
|
||||
const [showToast, setShowToast] = useState(false)
|
||||
|
||||
|
@ -69,9 +51,7 @@ export function ShareIconButton(props: {
|
|||
showToast ? onCopyButtonClassName : ''
|
||||
)}
|
||||
onClick={() => {
|
||||
if (contract) copyContractWithReferral(contract, username)
|
||||
if (group) copyGroupWithReferral(group, username)
|
||||
if (manalink) copyManalink(manalink)
|
||||
copyToClipboard(copyPayload)
|
||||
track('copy share link')
|
||||
setShowToast(true)
|
||||
setTimeout(() => setShowToast(false), 2000)
|
||||
|
|
|
@ -54,6 +54,7 @@ import { useTipTxns } from 'web/hooks/use-tip-txns'
|
|||
import { JoinOrLeaveGroupButton } from 'web/components/groups/groups-button'
|
||||
import { searchInAny } from 'common/util/parse'
|
||||
import { useWindowSize } from 'web/hooks/use-window-size'
|
||||
import { ENV_CONFIG } from 'common/envs/constants'
|
||||
|
||||
export const getStaticProps = fromPropz(getStaticPropz)
|
||||
export async function getStaticPropz(props: { params: { slugs: string[] } }) {
|
||||
|
@ -401,8 +402,9 @@ function GroupOverview(props: {
|
|||
<Row className={'flex-wrap items-center gap-1'}>
|
||||
<span className={'text-gray-500'}>Share</span>
|
||||
<ShareIconButton
|
||||
group={group}
|
||||
username={user.username}
|
||||
copyPayload={`https://${ENV_CONFIG.domain}${groupPath(
|
||||
group.slug
|
||||
)}${user?.username ? '?referrer=' + user?.username : ''}`}
|
||||
buttonClassName={'hover:bg-gray-300 mt-1 !text-gray-700'}
|
||||
>
|
||||
<span className={'mx-2'}>
|
||||
|
|
Loading…
Reference in New Issue
Block a user