comment bounty dialog, styling
This commit is contained in:
parent
84bc490ed3
commit
efa2e44937
|
@ -1,12 +1,16 @@
|
||||||
|
import clsx from 'clsx'
|
||||||
|
import { useState } from 'react'
|
||||||
|
|
||||||
import { CurrencyDollarIcon } from '@heroicons/react/outline'
|
import { CurrencyDollarIcon } from '@heroicons/react/outline'
|
||||||
import { Contract } from 'common/contract'
|
import { Contract } from 'common/contract'
|
||||||
import { Tooltip } from 'web/components/tooltip'
|
import { Tooltip } from 'web/components/tooltip'
|
||||||
import { formatMoney } from 'common/util/format'
|
import { formatMoney } from 'common/util/format'
|
||||||
import { COMMENT_BOUNTY_AMOUNT } from 'common/economy'
|
import { COMMENT_BOUNTY_AMOUNT } from 'common/economy'
|
||||||
|
import { CommentBountyDialog } from './comment-bounty-dialog'
|
||||||
|
|
||||||
export function BountiedContractBadge() {
|
export function BountiedContractBadge() {
|
||||||
return (
|
return (
|
||||||
<span className="inline-flex items-center gap-1 rounded-full bg-blue-100 px-3 py-0.5 text-sm font-medium text-blue-800">
|
<span className="inline-flex items-center gap-1 rounded-full bg-indigo-300 px-3 py-0.5 text-sm font-medium text-white">
|
||||||
<CurrencyDollarIcon className={'h4 w-4'} /> Bounty
|
<CurrencyDollarIcon className={'h4 w-4'} /> Bounty
|
||||||
</span>
|
</span>
|
||||||
)
|
)
|
||||||
|
@ -18,30 +22,50 @@ export function BountiedContractSmallBadge(props: {
|
||||||
}) {
|
}) {
|
||||||
const { contract, showAmount } = props
|
const { contract, showAmount } = props
|
||||||
const { openCommentBounties } = contract
|
const { openCommentBounties } = contract
|
||||||
if (!openCommentBounties) return <div />
|
|
||||||
|
|
||||||
return (
|
const [open, setOpen] = useState(false)
|
||||||
<Tooltip
|
|
||||||
text={CommentBountiesTooltipText(
|
if (!openCommentBounties && !showAmount) return <></>
|
||||||
contract.creatorName,
|
|
||||||
openCommentBounties
|
const modal = (
|
||||||
)}
|
<CommentBountyDialog open={open} setOpen={setOpen} contract={contract} />
|
||||||
placement="bottom"
|
|
||||||
>
|
|
||||||
<span className="inline-flex items-center gap-1 whitespace-nowrap rounded-full bg-indigo-300 px-2 py-0.5 text-xs font-medium text-white">
|
|
||||||
<CurrencyDollarIcon className={'h3 w-3'} />
|
|
||||||
{showAmount && formatMoney(openCommentBounties)} Bounty
|
|
||||||
</span>
|
|
||||||
</Tooltip>
|
|
||||||
)
|
)
|
||||||
}
|
if (!openCommentBounties)
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{modal}
|
||||||
|
<SmallBadge text="Add bounty" onClick={() => setOpen(true)} />
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
|
||||||
export const CommentBountiesTooltipText = (
|
const tooltip = `${contract.creatorName} may award ${formatMoney(
|
||||||
creator: string,
|
|
||||||
openCommentBounties: number
|
|
||||||
) =>
|
|
||||||
`${creator} may award ${formatMoney(
|
|
||||||
COMMENT_BOUNTY_AMOUNT
|
COMMENT_BOUNTY_AMOUNT
|
||||||
)} for good comments. ${formatMoney(
|
)} for good comments. ${formatMoney(
|
||||||
openCommentBounties
|
openCommentBounties
|
||||||
)} currently available.`
|
)} currently available.`
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Tooltip text={tooltip} placement="bottom">
|
||||||
|
{modal}
|
||||||
|
<SmallBadge
|
||||||
|
text={`${formatMoney(openCommentBounties)} bounty`}
|
||||||
|
onClick={() => setOpen(true)}
|
||||||
|
/>
|
||||||
|
</Tooltip>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
function SmallBadge(props: { text: string; onClick?: () => void }) {
|
||||||
|
const { text, onClick } = props
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
onClick={onClick}
|
||||||
|
className={clsx(
|
||||||
|
'inline-flex items-center gap-1 whitespace-nowrap rounded-full bg-indigo-300 px-2 py-0.5 text-xs font-medium text-white'
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<CurrencyDollarIcon className={'h4 w-4'} />
|
||||||
|
{text}
|
||||||
|
</button>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
|
@ -8,9 +8,16 @@ import clsx from 'clsx'
|
||||||
import { formatMoney } from 'common/util/format'
|
import { formatMoney } from 'common/util/format'
|
||||||
import { COMMENT_BOUNTY_AMOUNT } from 'common/economy'
|
import { COMMENT_BOUNTY_AMOUNT } from 'common/economy'
|
||||||
import { Button } from 'web/components/button'
|
import { Button } from 'web/components/button'
|
||||||
|
import { Title } from '../title'
|
||||||
|
import { Col } from '../layout/col'
|
||||||
|
import { Modal } from '../layout/modal'
|
||||||
|
|
||||||
export function AddCommentBountyPanel(props: { contract: Contract }) {
|
export function CommentBountyDialog(props: {
|
||||||
const { contract } = props
|
contract: Contract
|
||||||
|
open: boolean
|
||||||
|
setOpen: (open: boolean) => void
|
||||||
|
}) {
|
||||||
|
const { contract, open, setOpen } = props
|
||||||
const { id: contractId, slug } = contract
|
const { id: contractId, slug } = contract
|
||||||
|
|
||||||
const user = useUser()
|
const user = useUser()
|
||||||
|
@ -45,30 +52,34 @@ export function AddCommentBountyPanel(props: { contract: Contract }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<Modal open={open} setOpen={setOpen}>
|
||||||
<div className="mb-4 text-gray-500">
|
<Col className="gap-4 rounded bg-white p-6">
|
||||||
Add a {formatMoney(amount)} bounty for good comments that the creator
|
<Title className="!mt-0 !mb-0" text="Comment bounty" />
|
||||||
can award.{' '}
|
|
||||||
{totalAdded > 0 && `(${formatMoney(totalAdded)} currently added)`}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Row className={'items-center gap-2'}>
|
<div className="mb-4 text-gray-500">
|
||||||
<Button
|
Add a {formatMoney(amount)} bounty for good comments that the creator
|
||||||
className={clsx('ml-2', isLoading && 'btn-disabled')}
|
can award.{' '}
|
||||||
onClick={submit}
|
{totalAdded > 0 && `(${formatMoney(totalAdded)} currently added)`}
|
||||||
disabled={isLoading}
|
</div>
|
||||||
color={'blue'}
|
|
||||||
>
|
|
||||||
Add {formatMoney(amount)} bounty
|
|
||||||
</Button>
|
|
||||||
<span className={'text-error'}>{error}</span>
|
|
||||||
</Row>
|
|
||||||
|
|
||||||
{isSuccess && amount && (
|
<Row className={'items-center gap-2'}>
|
||||||
<div>Success! Added {formatMoney(amount)} in bounties.</div>
|
<Button
|
||||||
)}
|
className={clsx('ml-2', isLoading && 'btn-disabled')}
|
||||||
|
onClick={submit}
|
||||||
|
disabled={isLoading}
|
||||||
|
color={'blue'}
|
||||||
|
>
|
||||||
|
Add {formatMoney(amount)} bounty
|
||||||
|
</Button>
|
||||||
|
<span className={'text-error'}>{error}</span>
|
||||||
|
</Row>
|
||||||
|
|
||||||
{isLoading && <div>Processing...</div>}
|
{isSuccess && amount && (
|
||||||
</>
|
<div>Success! Added {formatMoney(amount)} in bounties.</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{isLoading && <div>Processing...</div>}
|
||||||
|
</Col>
|
||||||
|
</Modal>
|
||||||
)
|
)
|
||||||
}
|
}
|
|
@ -123,7 +123,7 @@ const CommentsTabContent = memo(function CommentsTabContent(props: {
|
||||||
const topLevelComments = commentsByParent['_'] ?? []
|
const topLevelComments = commentsByParent['_'] ?? []
|
||||||
|
|
||||||
const sortRow = comments.length > 0 && (
|
const sortRow = comments.length > 0 && (
|
||||||
<Row className="mb-2 items-center">
|
<Row className="mb-4 items-center">
|
||||||
<Button
|
<Button
|
||||||
size={'xs'}
|
size={'xs'}
|
||||||
color={'gray-white'}
|
color={'gray-white'}
|
||||||
|
|
|
@ -16,7 +16,6 @@ import { InfoTooltip } from 'web/components/info-tooltip'
|
||||||
import { BETTORS, PRESENT_BET } from 'common/user'
|
import { BETTORS, PRESENT_BET } from 'common/user'
|
||||||
import { buildArray } from 'common/util/array'
|
import { buildArray } from 'common/util/array'
|
||||||
import { useAdmin } from 'web/hooks/use-admin'
|
import { useAdmin } from 'web/hooks/use-admin'
|
||||||
import { AddCommentBountyPanel } from 'web/components/contract/add-comment-bounty'
|
|
||||||
|
|
||||||
export function LiquidityBountyPanel(props: { contract: Contract }) {
|
export function LiquidityBountyPanel(props: { contract: Contract }) {
|
||||||
const { contract } = props
|
const { contract } = props
|
||||||
|
@ -36,13 +35,11 @@ export function LiquidityBountyPanel(props: { contract: Contract }) {
|
||||||
const isCreator = user?.id === contract.creatorId
|
const isCreator = user?.id === contract.creatorId
|
||||||
const isAdmin = useAdmin()
|
const isAdmin = useAdmin()
|
||||||
|
|
||||||
|
if (!isCreator && !isAdmin && !showWithdrawal) return <></>
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tabs
|
<Tabs
|
||||||
tabs={buildArray(
|
tabs={buildArray(
|
||||||
{
|
|
||||||
title: 'Bounty Comments',
|
|
||||||
content: <AddCommentBountyPanel contract={contract} />,
|
|
||||||
},
|
|
||||||
(isCreator || isAdmin) &&
|
(isCreator || isAdmin) &&
|
||||||
isCPMM && {
|
isCPMM && {
|
||||||
title: (isAdmin ? '[Admin] ' : '') + 'Subsidize',
|
title: (isAdmin ? '[Admin] ' : '') + 'Subsidize',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user