move liquidity to info dialog

This commit is contained in:
mantikoros 2022-10-11 16:22:28 -05:00
parent 9d44190b9a
commit 220d0841bd
4 changed files with 45 additions and 6 deletions

View File

@ -0,0 +1,36 @@
import { useState } from 'react'
import clsx from 'clsx'
import { buttonClass } from 'web/components/button'
import { CPMMContract } from 'common/contract'
import { LiquidityModal } from './liquidity-modal'
export function AddLiquidityButton(props: {
contract: CPMMContract
className?: string
}) {
const { contract, className } = props
const [open, setOpen] = useState(false)
const disabled =
contract.isResolved || (contract.closeTime ?? Infinity) < Date.now()
if (disabled) return <></>
return (
<a
className={clsx(
buttonClass('2xs', 'override'),
'cursor-pointer',
'gap-1 border-2 border-blue-400 text-blue-400 hover:bg-blue-400 hover:text-white',
className
)}
onClick={() => setOpen(true)}
target="_blank"
>
<div>💧 Add liquidity</div>
<LiquidityModal contract={contract} isOpen={open} setOpen={setOpen} />
</a>
)
}

View File

@ -20,6 +20,7 @@ import { DuplicateContractButton } from '../duplicate-contract-button'
import { Row } from '../layout/row' import { Row } from '../layout/row'
import { BETTORS, User } from 'common/user' import { BETTORS, User } from 'common/user'
import { Button } from '../button' import { Button } from '../button'
import { AddLiquidityButton } from './add-liquidity-button'
export const contractDetailsButtonClassName = export const contractDetailsButtonClassName =
'group flex items-center rounded-md px-3 py-2 text-sm font-medium cursor-pointer hover:bg-gray-100 text-gray-400 hover:text-gray-500' 'group flex items-center rounded-md px-3 py-2 text-sm font-medium cursor-pointer hover:bg-gray-100 text-gray-400 hover:text-gray-500'
@ -241,6 +242,9 @@ export function ContractInfoDialog(props: {
</table> </table>
<Row className="flex-wrap"> <Row className="flex-wrap">
{mechanism === 'cpmm-1' && (
<AddLiquidityButton contract={contract} className="mr-2" />
)}
<DuplicateContractButton contract={contract} /> <DuplicateContractButton contract={contract} />
</Row> </Row>
</Col> </Col>

View File

@ -9,7 +9,6 @@ import { FollowMarketButton } from 'web/components/follow-market-button'
import { LikeMarketButton } from 'web/components/contract/like-market-button' import { LikeMarketButton } from 'web/components/contract/like-market-button'
import { ContractInfoDialog } from 'web/components/contract/contract-info-dialog' import { ContractInfoDialog } from 'web/components/contract/contract-info-dialog'
import { Tooltip } from '../tooltip' import { Tooltip } from '../tooltip'
import { LiquidityButton } from './liquidity-button'
export function ExtraContractActionsRow(props: { contract: Contract }) { export function ExtraContractActionsRow(props: { contract: Contract }) {
const { contract } = props const { contract } = props
@ -19,10 +18,9 @@ export function ExtraContractActionsRow(props: { contract: Contract }) {
return ( return (
<Row> <Row>
<FollowMarketButton contract={contract} user={user} /> <FollowMarketButton contract={contract} user={user} />
{contract.mechanism === 'cpmm-1' && (
<LiquidityButton contract={contract} user={user} />
)}
<LikeMarketButton contract={contract} user={user} /> <LikeMarketButton contract={contract} user={user} />
<Tooltip text="Share" placement="bottom" noTap noFade> <Tooltip text="Share" placement="bottom" noTap noFade>
<Button <Button
size="sm" size="sm"
@ -39,6 +37,7 @@ export function ExtraContractActionsRow(props: { contract: Contract }) {
/> />
</Button> </Button>
</Tooltip> </Tooltip>
<ContractInfoDialog contract={contract} user={user} /> <ContractInfoDialog contract={contract} user={user} />
</Row> </Row>
) )

View File

@ -23,7 +23,7 @@ export function LiquidityModal(props: {
return ( return (
<Modal open={isOpen} setOpen={setOpen} size="sm"> <Modal open={isOpen} setOpen={setOpen} size="sm">
<Col className="gap-2.5 rounded bg-white p-4 pb-8 sm:gap-4"> <Col className="gap-2.5 rounded bg-white p-4 pb-8 sm:gap-4">
<Title className="!mt-0 !mb-2" text="💧 Add a subsidy" /> <Title className="!mt-0 !mb-2" text="💧 Add liquidity" />
<div>Total liquidity subsidies: {formatMoney(totalLiquidity)}</div> <div>Total liquidity subsidies: {formatMoney(totalLiquidity)}</div>
<AddLiquidityPanel contract={contract as CPMMContract} /> <AddLiquidityPanel contract={contract as CPMMContract} />
@ -91,7 +91,7 @@ function AddLiquidityPanel(props: { contract: CPMMContract }) {
label="M$" label="M$"
error={error} error={error}
disabled={isLoading} disabled={isLoading}
inputClassName="w-16 mr-4" inputClassName="w-28 mr-4"
/> />
<Button size="md" color="blue" onClick={submit} disabled={isLoading}> <Button size="md" color="blue" onClick={submit} disabled={isLoading}>
Add Add