1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

add remove screen functionality

This commit is contained in:
Matthias Kretschmann 2020-08-19 15:59:50 +02:00
parent ef874fd837
commit db5783c356
Signed by: m
GPG Key ID: 606EEEF3C479A91F
3 changed files with 48 additions and 9 deletions

View File

@ -3,7 +3,6 @@ import styles from './Add.module.css'
import stylesIndex from './index.module.css'
import Button from '../../../atoms/Button'
import Input from '../../../atoms/Input'
import { Ocean } from '@oceanprotocol/lib'
import { useOcean } from '@oceanprotocol/react'
export default function Add({
@ -16,17 +15,16 @@ export default function Add({
poolAddress: string
}): ReactElement {
const { ocean, accountId } = useOcean()
const [amount, setAmount] = useState<string>()
function handleAmountChange(e: ChangeEvent<HTMLInputElement>) {
setAmount(e.target.value)
}
async function handleAddLiquidity() {
await ocean.pool.addOceanLiquidity(accountId, poolAddress, amount)
}
function handleAmountChange(e: ChangeEvent<HTMLInputElement>) {
setAmount(e.target.value)
}
return (
<div className={styles.add}>
<Button

View File

@ -1,13 +1,35 @@
import React, { ReactElement } from 'react'
import React, { ReactElement, useState, ChangeEvent } from 'react'
import styles from './Remove.module.css'
import stylesIndex from './index.module.css'
import Button from '../../../atoms/Button'
import Input from '../../../atoms/Input'
import { useOcean } from '@oceanprotocol/react'
export default function Remove({
setShowRemove
setShowRemove,
poolAddress
}: {
setShowRemove: (show: boolean) => void
poolAddress: string
}): ReactElement {
const { ocean, accountId } = useOcean()
const [amount, setAmount] = useState<string>()
const maximumPoolShares = '?'
async function handleRemoveLiquidity() {
await ocean.pool.removeOceanLiquidity(
accountId,
poolAddress,
amount,
maximumPoolShares
)
}
function handleAmountChange(e: ChangeEvent<HTMLInputElement>) {
setAmount(e.target.value)
}
return (
<div className={styles.remove}>
<Button
@ -18,7 +40,26 @@ export default function Remove({
>
Back
</Button>
<h3 className={stylesIndex.title}>Remove Liquidity</h3>
<Input
name="ocean"
label="OCEAN"
type="number"
placeholder="0"
onChange={handleAmountChange}
/>
{/* <Input name="dt" label={dtSymbol} type="number" placeholder="0" /> */}
<p>You will receive:</p>
<Button
style="primary"
size="small"
onClick={() => handleRemoveLiquidity()}
>
Remove
</Button>
</div>
)
}

View File

@ -85,7 +85,7 @@ export default function Pool({ ddo }: { ddo: DDO }): ReactElement {
poolAddress={poolAddress}
/>
) : showRemove ? (
<Remove setShowRemove={setShowRemove} />
<Remove setShowRemove={setShowRemove} poolAddress={poolAddress} />
) : (
<>
<div className={styles.dataToken}>