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

free price tweaks

This commit is contained in:
Matthias Kretschmann 2021-11-26 13:05:53 +00:00
parent 5dca006832
commit 7c98659c86
Signed by: m
GPG Key ID: 606EEEF3C479A91F
4 changed files with 35 additions and 34 deletions

View File

@ -2,7 +2,8 @@
position: relative;
}
.form * {
.form *,
.form label {
margin-bottom: 0;
}
@ -59,3 +60,9 @@
.conversion strong {
color: var(--color-secondary);
}
.free {
text-align: center;
margin: calc(var(--spacer) / 2) 0;
font-size: var(--font-size-base);
}

View File

@ -19,31 +19,33 @@ export default function Price({
return (
<div className={styles.price}>
<div className={styles.grid}>
<div className={styles.form}>
{field.value === 0 ? (
<Input value="0" type="number" prefix="OCEAN" readOnly {...field} />
) : (
<Input type="number" prefix="OCEAN" {...field} />
{values.pricing.type === 'free' ? (
<h4 className={styles.free}>Free</h4>
) : (
<>
<div className={styles.grid}>
<div className={styles.form}>
<Input type="number" prefix="OCEAN" {...field} />
<Error meta={meta} />
</div>
<div className={styles.datatoken}>
<h4>
= <strong>1</strong> {dataTokenOptions.symbol}{' '}
<Conversion price={field.value} className={styles.conversion} />
</h4>
</div>
</div>
{firstPrice && (
<aside className={styles.firstPrice}>
Expected first price:{' '}
<PriceUnit
price={Number(firstPrice) > 0 ? firstPrice : '-'}
small
conversion
/>
</aside>
)}
<Error meta={meta} />
</div>
<div className={styles.datatoken}>
<h4>
= <strong>1</strong> {dataTokenOptions.symbol}{' '}
<Conversion price={field.value} className={styles.conversion} />
</h4>
</div>
</div>
{firstPrice && (
<aside className={styles.firstPrice}>
Expected first price:{' '}
<PriceUnit
price={Number(firstPrice) > 0 ? firstPrice : '-'}
small
conversion
/>
</aside>
</>
)}
</div>
)

View File

@ -24,7 +24,6 @@ export default function PricingFields(): ReactElement {
const type = tabName.toLowerCase()
setFieldValue('pricing.type', type)
type === 'dynamic' && setFieldValue('pricing.amountDataToken', 1000)
setFieldValue('pricing.price', type === 'free' ? 0 : 1)
}
// Always update everything when price value changes

View File

@ -60,14 +60,7 @@ const validationPricing = {
.required('Required'),
// https://github.com/jquense/yup#mixedwhenkeys-string--arraystring-builder-object--value-schema-schema-schema
price: Yup.number()
.when('type', (type, schema) =>
type === 'free'
? schema
: schema.min(
1,
(param: { min: number }) => `Must be more or equal to ${param.min}`
)
)
.min(1, (param: { min: number }) => `Must be more or equal to ${param.min}`)
.required('Required'),
amountDataToken: Yup.number()
.min(50, (param) => `Must be more or equal to ${param.min}`)