@@ -81,14 +84,14 @@ export default function Dynamic({
diff --git a/src/components/molecules/FormFields/Price/Error.tsx b/src/components/organisms/AssetContent/Price/Error.tsx
similarity index 100%
rename from src/components/molecules/FormFields/Price/Error.tsx
rename to src/components/organisms/AssetContent/Price/Error.tsx
diff --git a/src/components/molecules/FormFields/Price/Fees.module.css b/src/components/organisms/AssetContent/Price/Fees.module.css
similarity index 100%
rename from src/components/molecules/FormFields/Price/Fees.module.css
rename to src/components/organisms/AssetContent/Price/Fees.module.css
diff --git a/src/components/molecules/FormFields/Price/Fees.tsx b/src/components/organisms/AssetContent/Price/Fees.tsx
similarity index 89%
rename from src/components/molecules/FormFields/Price/Fees.tsx
rename to src/components/organisms/AssetContent/Price/Fees.tsx
index 5537ea38a..5009ffa8c 100644
--- a/src/components/molecules/FormFields/Price/Fees.tsx
+++ b/src/components/organisms/AssetContent/Price/Fees.tsx
@@ -1,7 +1,6 @@
import React, { ReactElement } from 'react'
import Tooltip from '../../../atoms/Tooltip'
import styles from './Fees.module.css'
-import { useSiteMetadata } from '../../../../hooks/useSiteMetadata'
import { useField } from 'formik'
import Input from '../../../atoms/Input'
import Error from './Error'
@@ -11,8 +10,7 @@ export default function Fees({
}: {
tooltips: { [key: string]: string }
}): ReactElement {
- const { appConfig } = useSiteMetadata()
- const [field, meta] = useField('price.swapFee')
+ const [field, meta] = useField('swapFee')
return (
<>
diff --git a/src/components/molecules/FormFields/Price/Fixed.module.css b/src/components/organisms/AssetContent/Price/Fixed.module.css
similarity index 100%
rename from src/components/molecules/FormFields/Price/Fixed.module.css
rename to src/components/organisms/AssetContent/Price/Fixed.module.css
diff --git a/src/components/molecules/FormFields/Price/Fixed.tsx b/src/components/organisms/AssetContent/Price/Fixed.tsx
similarity index 93%
rename from src/components/molecules/FormFields/Price/Fixed.tsx
rename to src/components/organisms/AssetContent/Price/Fixed.tsx
index 8ec57ea25..ca46042f6 100644
--- a/src/components/molecules/FormFields/Price/Fixed.tsx
+++ b/src/components/organisms/AssetContent/Price/Fixed.tsx
@@ -8,7 +8,7 @@ import Input from '../../../atoms/Input'
import Error from './Error'
export default function Fixed({ content }: { content: any }): ReactElement {
- const [field, meta] = useField('price.price')
+ const [field, meta] = useField('price')
return (
@@ -19,7 +19,7 @@ export default function Fixed({ content }: { content: any }): ReactElement {
()
+ const { values, setFieldValue } = useFormikContext()
+ const { price, weightOnDataToken, type } = values as PriceOptionsMarket
function handleTabChange(tabName: string) {
const type = tabName.toLowerCase()
- helpers.setValue({ ...field.value, type })
+ setFieldValue('type', type)
}
- // Always update everything when amountOcean changes
+ // Always update everything when price changes
useEffect(() => {
- const tokensToMint = Number(price) * Number(field.value.weightOnDataToken)
- setTokensToMint(tokensToMint)
- helpers.setValue({ ...field.value, tokensToMint })
+ const dtAmount = Number(price) * Number(weightOnDataToken)
+ setFieldValue('dtAmount', dtAmount)
}, [price])
const tabs = [
@@ -69,9 +66,7 @@ export default function Price(props: InputProps): ReactElement {
title: content.dynamic.title,
content: (
)
@@ -83,11 +78,11 @@ export default function Price(props: InputProps): ReactElement {
{debug === true && (
- {JSON.stringify(field.value, null, 2)}
+ {JSON.stringify(values, null, 2)}
)}
diff --git a/src/components/organisms/AssetContent/Pricing.tsx b/src/components/organisms/AssetContent/Pricing.tsx
index c3232263e..f779f6fc1 100644
--- a/src/components/organisms/AssetContent/Pricing.tsx
+++ b/src/components/organisms/AssetContent/Pricing.tsx
@@ -7,6 +7,7 @@ import { usePricing } from '@oceanprotocol/react'
import { PriceOptionsMarket } from '../../../@types/MetaData'
import Alert from '../../atoms/Alert'
import styles from './Pricing.module.css'
+import Price from './Price'
export default function Pricing({ ddo }: { ddo: DDO }): ReactElement {
const { createPricing } = usePricing(ddo)
@@ -32,27 +33,7 @@ export default function Pricing({ ddo }: { ddo: DDO }): ReactElement {
setSubmitting(false)
}}
>
- {() => (
- <>
-
- {({
- field,
- form
- }: {
- field: FieldInputProps
- form: any
- }) => (
-
- )}
-
- >
- )}
+ {(props) =>
}
) : (
({
price: Yup.number().min(1, 'Must be greater than 0').required('Required'),
- tokensToMint: Yup.number()
- .min(1, 'Must be greater than 0')
- .required('Required'),
+ dtAmount: Yup.number().min(1, 'Must be greater than 0').required('Required'),
type: Yup.string()
.matches(/fixed|dynamic/g)
.required('Required'),
@@ -20,7 +18,7 @@ export const validationSchema = Yup.object().shape({
export const initialValues: Partial = {
price: 1,
type: 'dynamic',
- tokensToMint: 1,
+ dtAmount: 1,
weightOnDataToken: '9', // 90% on data token
swapFee: 0.1 // in %
}