mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
price refactor
This commit is contained in:
parent
c2a247b605
commit
d0c65a6935
@ -12,6 +12,8 @@ import stylesIndex from './index.module.css'
|
|||||||
import { useFormikContext } from 'formik'
|
import { useFormikContext } from 'formik'
|
||||||
import { PriceOptionsMarket } from '../../../../../@types/MetaData'
|
import { PriceOptionsMarket } from '../../../../../@types/MetaData'
|
||||||
import { DDO } from '@oceanprotocol/lib'
|
import { DDO } from '@oceanprotocol/lib'
|
||||||
|
import Fixed from './Fixed'
|
||||||
|
import Price from './Price'
|
||||||
|
|
||||||
export default function Dynamic({
|
export default function Dynamic({
|
||||||
ddo,
|
ddo,
|
||||||
@ -68,6 +70,12 @@ export default function Dynamic({
|
|||||||
<Wallet />
|
<Wallet />
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
|
<h4 className={styles.title}>
|
||||||
|
Price <Tooltip content={content.tooltips.poolInfo} />
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
<Price ddo={ddo} />
|
||||||
|
|
||||||
<h4 className={styles.title}>
|
<h4 className={styles.title}>
|
||||||
Datatoken Liquidity Pool <Tooltip content={content.tooltips.poolInfo} />
|
Datatoken Liquidity Pool <Tooltip content={content.tooltips.poolInfo} />
|
||||||
</h4>
|
</h4>
|
||||||
|
@ -1,48 +1,3 @@
|
|||||||
.fixed {
|
.fixed {
|
||||||
composes: content from './index.module.css';
|
composes: content from './index.module.css';
|
||||||
}
|
}
|
||||||
|
|
||||||
.form {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (min-width: 55rem) {
|
|
||||||
.form {
|
|
||||||
max-width: 12rem;
|
|
||||||
margin-left: auto;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.grid {
|
|
||||||
margin-left: -2rem;
|
|
||||||
margin-right: -2rem;
|
|
||||||
padding-top: var(--spacer);
|
|
||||||
display: grid;
|
|
||||||
gap: var(--spacer);
|
|
||||||
grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
|
|
||||||
justify-content: center;
|
|
||||||
background: var(--brand-grey-dimmed);
|
|
||||||
border-top: 1px solid var(--brand-grey-lighter);
|
|
||||||
border-bottom: 1px solid var(--brand-grey-lighter);
|
|
||||||
}
|
|
||||||
|
|
||||||
.fixed label {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.datatoken {
|
|
||||||
margin-top: calc(var(--spacer) / 2);
|
|
||||||
color: var(--color-secondary);
|
|
||||||
font-size: var(--font-size-small);
|
|
||||||
font-weight: var(--font-weight-bold);
|
|
||||||
}
|
|
||||||
|
|
||||||
.datatoken h4 {
|
|
||||||
font-size: var(--font-size-base);
|
|
||||||
color: var(--color-secondary);
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.datatoken strong {
|
|
||||||
color: var(--brand-grey-dark);
|
|
||||||
}
|
|
||||||
|
@ -2,12 +2,8 @@ import React, { ReactElement } from 'react'
|
|||||||
import stylesIndex from './index.module.css'
|
import stylesIndex from './index.module.css'
|
||||||
import styles from './Fixed.module.css'
|
import styles from './Fixed.module.css'
|
||||||
import FormHelp from '../../../../atoms/Input/Help'
|
import FormHelp from '../../../../atoms/Input/Help'
|
||||||
import Conversion from '../../../../atoms/Price/Conversion'
|
|
||||||
import { useField } from 'formik'
|
|
||||||
import Input from '../../../../atoms/Input'
|
|
||||||
import Error from './Error'
|
|
||||||
import { DDO } from '@oceanprotocol/lib'
|
import { DDO } from '@oceanprotocol/lib'
|
||||||
import { usePricing } from '@oceanprotocol/react'
|
import Price from './Price'
|
||||||
|
|
||||||
export default function Fixed({
|
export default function Fixed({
|
||||||
ddo,
|
ddo,
|
||||||
@ -16,38 +12,10 @@ export default function Fixed({
|
|||||||
ddo: DDO
|
ddo: DDO
|
||||||
content: any
|
content: any
|
||||||
}): ReactElement {
|
}): ReactElement {
|
||||||
const [field, meta] = useField('price')
|
|
||||||
const { dtName, dtSymbol } = usePricing(ddo)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.fixed}>
|
<div className={styles.fixed}>
|
||||||
<FormHelp className={stylesIndex.help}>{content.info}</FormHelp>
|
<FormHelp className={stylesIndex.help}>{content.info}</FormHelp>
|
||||||
|
<Price ddo={ddo} />
|
||||||
<div className={styles.grid}>
|
|
||||||
<div className={styles.form}>
|
|
||||||
<Input
|
|
||||||
label="Ocean Token"
|
|
||||||
value={field.value}
|
|
||||||
name="price"
|
|
||||||
type="number"
|
|
||||||
prefix="OCEAN"
|
|
||||||
min="1"
|
|
||||||
{...field}
|
|
||||||
additionalComponent={
|
|
||||||
<Conversion
|
|
||||||
price={field.value}
|
|
||||||
className={stylesIndex.conversion}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<Error meta={meta} />
|
|
||||||
</div>
|
|
||||||
<div className={styles.datatoken}>
|
|
||||||
<h4>
|
|
||||||
= <strong>1</strong> {dtName} — {dtSymbol}
|
|
||||||
</h4>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,44 @@
|
|||||||
|
.form {
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 55rem) {
|
||||||
|
.form {
|
||||||
|
max-width: 12rem;
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.grid {
|
||||||
|
margin-left: -2rem;
|
||||||
|
margin-right: -2rem;
|
||||||
|
padding-top: var(--spacer);
|
||||||
|
display: grid;
|
||||||
|
gap: var(--spacer);
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
|
||||||
|
justify-content: center;
|
||||||
|
background: var(--brand-grey-dimmed);
|
||||||
|
border-top: 1px solid var(--brand-grey-lighter);
|
||||||
|
border-bottom: 1px solid var(--brand-grey-lighter);
|
||||||
|
}
|
||||||
|
|
||||||
|
.fixed label {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.datatoken {
|
||||||
|
margin-top: calc(var(--spacer) / 2);
|
||||||
|
color: var(--color-secondary);
|
||||||
|
font-size: var(--font-size-small);
|
||||||
|
font-weight: var(--font-weight-bold);
|
||||||
|
}
|
||||||
|
|
||||||
|
.datatoken h4 {
|
||||||
|
font-size: var(--font-size-base);
|
||||||
|
color: var(--color-secondary);
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.datatoken strong {
|
||||||
|
color: var(--brand-grey-dark);
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
import { usePricing } from '@oceanprotocol/react'
|
||||||
|
import Conversion from '../../../../atoms/Price/Conversion'
|
||||||
|
import { useField } from 'formik'
|
||||||
|
import React, { ReactElement } from 'react'
|
||||||
|
import Input from '../../../../atoms/Input'
|
||||||
|
import styles from './Price.module.css'
|
||||||
|
import Error from './Error'
|
||||||
|
import { DDO } from '@oceanprotocol/lib'
|
||||||
|
|
||||||
|
export default function Price({ ddo }: { ddo: DDO }): ReactElement {
|
||||||
|
const [field, meta] = useField('price')
|
||||||
|
const { dtName, dtSymbol } = usePricing(ddo)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className={styles.grid}>
|
||||||
|
<div className={styles.form}>
|
||||||
|
<Input
|
||||||
|
value={field.value}
|
||||||
|
name="price"
|
||||||
|
type="number"
|
||||||
|
prefix="OCEAN"
|
||||||
|
min="1"
|
||||||
|
{...field}
|
||||||
|
additionalComponent={
|
||||||
|
<Conversion price={field.value} className={styles.conversion} />
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<Error meta={meta} />
|
||||||
|
</div>
|
||||||
|
<div className={styles.datatoken}>
|
||||||
|
<h4>
|
||||||
|
= <strong>1</strong> {dtName} — {dtSymbol}
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
@ -30,7 +30,8 @@ export default function AssetContent({
|
|||||||
|
|
||||||
const isOwner = accountId === ddo.publicKey[0].owner
|
const isOwner = accountId === ddo.publicKey[0].owner
|
||||||
const hasNoPrice = ddo.price.type === ''
|
const hasNoPrice = ddo.price.type === ''
|
||||||
const showPricing = isOwner && hasNoPrice
|
// TODO: JUST FOR DEBUGGING
|
||||||
|
const showPricing = true || (isOwner && hasNoPrice)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<article className={styles.grid}>
|
<article className={styles.grid}>
|
||||||
|
Loading…
Reference in New Issue
Block a user