hide liquidity panel (#904)

This commit is contained in:
mantikoros 2022-09-20 15:57:27 -05:00 committed by GitHub
parent 8920241c39
commit 379e736e51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -14,6 +14,8 @@ import { Col } from './layout/col'
import { track } from 'web/lib/service/analytics' import { track } from 'web/lib/service/analytics'
import { InfoTooltip } from './info-tooltip' import { InfoTooltip } from './info-tooltip'
import { BETTORS, PRESENT_BET } from 'common/user' import { BETTORS, PRESENT_BET } from 'common/user'
import { buildArray } from 'common/util/array'
import { useAdmin } from 'web/hooks/use-admin'
export function LiquidityPanel(props: { contract: CPMMContract }) { export function LiquidityPanel(props: { contract: CPMMContract }) {
const { contract } = props const { contract } = props
@ -28,16 +30,19 @@ export function LiquidityPanel(props: { contract: CPMMContract }) {
setShowWithdrawal(true) setShowWithdrawal(true)
}, [showWithdrawal, lpShares]) }, [showWithdrawal, lpShares])
const isCreator = user?.id === contract.creatorId
const isAdmin = useAdmin()
if (!showWithdrawal && !isAdmin && !isCreator) return <></>
return ( return (
<Tabs <Tabs
tabs={[ tabs={buildArray(
{ (isCreator || isAdmin) && {
title: 'Subsidize', title: (isAdmin ? '[Admin] ' : '') + 'Subsidize',
content: <AddLiquidityPanel contract={contract} />, content: <AddLiquidityPanel contract={contract} />,
}, },
...(showWithdrawal showWithdrawal && {
? [
{
title: 'Withdraw', title: 'Withdraw',
content: ( content: (
<WithdrawLiquidityPanel <WithdrawLiquidityPanel
@ -46,13 +51,11 @@ export function LiquidityPanel(props: { contract: CPMMContract }) {
/> />
), ),
}, },
]
: []),
{ {
title: 'Pool', title: 'Pool',
content: <ViewLiquidityPanel contract={contract} />, content: <ViewLiquidityPanel contract={contract} />,
}, }
]} )}
/> />
) )
} }