From 552d9a90f818049675ecf313ad2a25e19e97f37b Mon Sep 17 00:00:00 2001 From: Jernej Pregelj Date: Wed, 24 Jul 2019 15:49:47 +0200 Subject: [PATCH] pricing to displays --- .../src/components/molecules/AssetTeaser.tsx | 6 +++++- .../templates/Asset/AssetDetails.tsx | 19 +++++++++++++++++++ client/src/routes/Publish/index.tsx | 18 +++++++++--------- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/client/src/components/molecules/AssetTeaser.tsx b/client/src/components/molecules/AssetTeaser.tsx index 85e91ae..14f6d0d 100644 --- a/client/src/components/molecules/AssetTeaser.tsx +++ b/client/src/components/molecules/AssetTeaser.tsx @@ -5,6 +5,8 @@ import Dotdotdot from 'react-dotdotdot' import cx from 'classnames' import styles from './AssetTeaser.module.scss' import CategoryImage from '../atoms/CategoryImage' +import { allowPricing } from '../../config' +import Web3 from 'web3' const AssetTeaser = ({ asset, @@ -41,7 +43,9 @@ const AssetTeaser = ({ )}

{base.name}

- + {allowPricing + ? 'Ọ ' + Web3.utils.fromWei(base.price.toString()) + : null} {!minimal && (
{base.description} diff --git a/client/src/components/templates/Asset/AssetDetails.tsx b/client/src/components/templates/Asset/AssetDetails.tsx index 03ffc49..10db94c 100644 --- a/client/src/components/templates/Asset/AssetDetails.tsx +++ b/client/src/components/templates/Asset/AssetDetails.tsx @@ -6,6 +6,8 @@ import CategoryLink from '../../atoms/CategoryLink' import styles from './AssetDetails.module.scss' import AssetFilesDetails from './AssetFilesDetails' import Report from './Report' +import { allowPricing } from '../../../config' +import Web3 from 'web3' interface AssetDetailsProps { metadata: MetaData @@ -93,6 +95,23 @@ export default class AssetDetails extends PureComponent { {ddo.id} + {allowPricing ? ( +
  • + + Price + + + + Ọ{' '} + {base.price === '0' + ? 0 + : Web3.utils.fromWei( + base.price.toString() + )} + + +
  • + ) : null}
    diff --git a/client/src/routes/Publish/index.tsx b/client/src/routes/Publish/index.tsx index 2aa4347..d3733d0 100644 --- a/client/src/routes/Publish/index.tsx +++ b/client/src/routes/Publish/index.tsx @@ -37,13 +37,13 @@ interface PublishState { validationStatus?: any } -if(allowPricing){ - (steps as any)[0].fields['price'] = { - label: "Price", - placeholder: "Price in Ocean tokens", - type: "string", +if (allowPricing) { + ;(steps as any)[0].fields['price'] = { + label: 'Price', + placeholder: 'Price in Ocean tokens', + type: 'string', required: true, - help: "Enter the price of assets in Ocean tokens." + help: 'Enter the price of assets in Ocean tokens.' } } @@ -292,14 +292,14 @@ class Publish extends Component<{}, PublishState> { license: this.state.license, copyrightHolder: this.state.copyrightHolder, files, - price: allowPricing ? Web3.utils.toWei(this.state.price, 'ether') : this.state.price, + price: allowPricing + ? Web3.utils.toWei(this.state.price, 'ether') + : this.state.price, type: this.state.type, categories: [this.state.categories] }) } - console.log(newAsset) - try { const asset = await this.context.ocean.assets .create(newAsset, account[0])