From 9b6de84a1cfcded449e20b904d87c566f74953fd Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Wed, 29 Jul 2020 13:58:33 +0200 Subject: [PATCH] new calculation --- .../FormFields/Price/Advanced.module.css | 2 +- .../molecules/FormFields/Price/Advanced.tsx | 67 +++++++++++++------ .../molecules/FormFields/Price/Cost.tsx | 2 +- .../FormFields/Price/index.module.css | 2 +- 4 files changed, 50 insertions(+), 23 deletions(-) diff --git a/src/components/molecules/FormFields/Price/Advanced.module.css b/src/components/molecules/FormFields/Price/Advanced.module.css index d307d5b07..e828fb686 100644 --- a/src/components/molecules/FormFields/Price/Advanced.module.css +++ b/src/components/molecules/FormFields/Price/Advanced.module.css @@ -4,5 +4,5 @@ .advanced > div:last-child { display: grid; gap: calc(var(--spacer) / 2); - grid-template-columns: 1fr 1fr; + grid-template-columns: 1fr 1fr 1fr; } diff --git a/src/components/molecules/FormFields/Price/Advanced.tsx b/src/components/molecules/FormFields/Price/Advanced.tsx index e3eaabbe9..6de1cbabe 100644 --- a/src/components/molecules/FormFields/Price/Advanced.tsx +++ b/src/components/molecules/FormFields/Price/Advanced.tsx @@ -11,12 +11,14 @@ import FormHelp from '../../../atoms/Input/Help' export default function Advanced(props: InputProps): ReactElement { const { price } = props.form.values as MetadataPublishForm - const [weight, setWeight] = useState('10') - const liquidity = (price.cost * Number(weight)).toString() + const [ocean, setOcean] = useState('1') + const weight = '90' // in % + const tokensToMint = Number(ocean) * (Number(weight) / 100) + const cost = Number(ocean) / Number(tokensToMint) - function handleWeightChange(event: ChangeEvent) { - setWeight(event.target.value) + function handleOceanChange(event: ChangeEvent) { + setOcean(event.target.value) } return ( @@ -29,40 +31,65 @@ export default function Advanced(props: InputProps): ReactElement {
- +
+ + + + + +
+ +
+ + +
+
+
- + - -
-
- -
+ + {/* Hidden to fields to actually collect form values for Formik state */} + + ) } diff --git a/src/components/molecules/FormFields/Price/Cost.tsx b/src/components/molecules/FormFields/Price/Cost.tsx index 1363ba379..9c848e34e 100644 --- a/src/components/molecules/FormFields/Price/Cost.tsx +++ b/src/components/molecules/FormFields/Price/Cost.tsx @@ -11,7 +11,7 @@ export default function Cost(props: InputProps): ReactElement { return (
- +