1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

pricing to displays

This commit is contained in:
Jernej Pregelj 2019-07-24 15:49:47 +02:00 committed by Matthias Kretschmann
parent 74075fab08
commit 552d9a90f8
Signed by: m
GPG Key ID: 606EEEF3C479A91F
3 changed files with 33 additions and 10 deletions

View File

@ -5,6 +5,8 @@ import Dotdotdot from 'react-dotdotdot'
import cx from 'classnames' import cx from 'classnames'
import styles from './AssetTeaser.module.scss' import styles from './AssetTeaser.module.scss'
import CategoryImage from '../atoms/CategoryImage' import CategoryImage from '../atoms/CategoryImage'
import { allowPricing } from '../../config'
import Web3 from 'web3'
const AssetTeaser = ({ const AssetTeaser = ({
asset, asset,
@ -41,7 +43,9 @@ const AssetTeaser = ({
<CategoryImage dimmed category={base.categories[0]} /> <CategoryImage dimmed category={base.categories[0]} />
)} )}
<h1>{base.name}</h1> <h1>{base.name}</h1>
{allowPricing
? 'Ọ ' + Web3.utils.fromWei(base.price.toString())
: null}
{!minimal && ( {!minimal && (
<div className={styles.description}> <div className={styles.description}>
<Dotdotdot clamp={3}>{base.description}</Dotdotdot> <Dotdotdot clamp={3}>{base.description}</Dotdotdot>

View File

@ -6,6 +6,8 @@ import CategoryLink from '../../atoms/CategoryLink'
import styles from './AssetDetails.module.scss' import styles from './AssetDetails.module.scss'
import AssetFilesDetails from './AssetFilesDetails' import AssetFilesDetails from './AssetFilesDetails'
import Report from './Report' import Report from './Report'
import { allowPricing } from '../../../config'
import Web3 from 'web3'
interface AssetDetailsProps { interface AssetDetailsProps {
metadata: MetaData metadata: MetaData
@ -93,6 +95,23 @@ export default class AssetDetails extends PureComponent<AssetDetailsProps> {
<code>{ddo.id}</code> <code>{ddo.id}</code>
</span> </span>
</li> </li>
{allowPricing ? (
<li>
<span className={styles.metaLabel}>
<strong>Price</strong>
</span>
<span className={styles.metaValue}>
<code>
{' '}
{base.price === '0'
? 0
: Web3.utils.fromWei(
base.price.toString()
)}
</code>
</span>
</li>
) : null}
</ul> </ul>
</div> </div>

View File

@ -38,12 +38,12 @@ interface PublishState {
} }
if (allowPricing) { if (allowPricing) {
(steps as any)[0].fields['price'] = { ;(steps as any)[0].fields['price'] = {
label: "Price", label: 'Price',
placeholder: "Price in Ocean tokens", placeholder: 'Price in Ocean tokens',
type: "string", type: 'string',
required: true, 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, license: this.state.license,
copyrightHolder: this.state.copyrightHolder, copyrightHolder: this.state.copyrightHolder,
files, 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, type: this.state.type,
categories: [this.state.categories] categories: [this.state.categories]
}) })
} }
console.log(newAsset)
try { try {
const asset = await this.context.ocean.assets const asset = await this.context.ocean.assets
.create(newAsset, account[0]) .create(newAsset, account[0])