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

fix error output on asset details loading

This commit is contained in:
Matthias Kretschmann 2019-09-12 11:11:47 +02:00
parent c4029b147c
commit c4e71173ba
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 79 additions and 94 deletions

View File

@ -21,18 +21,24 @@ export function datafilesLine(files: File[]) {
return <span>{files.length} data files</span> return <span>{files.length} data files</span>
} }
export default class AssetDetails extends PureComponent<AssetDetailsProps> { const Pricing = ({ price }: { price: string }) => (
public render() { <li>
const { metadata, ddo } = this.props <span className={styles.metaLabel}>
<strong>Price</strong>
</span>
<span className={styles.metaValue}>
{price === '0' ? 0 : Web3.utils.fromWei(price.toString())} OCEAN
</span>
</li>
)
export default function AssetDetails({ metadata, ddo }: AssetDetailsProps) {
const { base } = metadata const { base } = metadata
return ( return (
<> <>
<aside className={styles.metaPrimary}> <aside className={styles.metaPrimary}>
<h2 <h2 className={styles.copyrightHolder} title="Copyright Holder">
className={styles.copyrightHolder}
title="Copyright Holder"
>
{base.copyrightHolder} {base.copyrightHolder}
</h2> </h2>
<div className={styles.metaPrimaryData}> <div className={styles.metaPrimaryData}>
@ -75,17 +81,13 @@ export default class AssetDetails extends PureComponent<AssetDetailsProps> {
<span className={styles.metaLabel}> <span className={styles.metaLabel}>
<strong>Author</strong> <strong>Author</strong>
</span> </span>
<span className={styles.metaValue}> <span className={styles.metaValue}>{base.author}</span>
{base.author}
</span>
</li> </li>
<li> <li>
<span className={styles.metaLabel}> <span className={styles.metaLabel}>
<strong>License</strong> <strong>License</strong>
</span> </span>
<span className={styles.metaValue}> <span className={styles.metaValue}>{base.license}</span>
{base.license}
</span>
</li> </li>
<li> <li>
<span className={styles.metaLabel}> <span className={styles.metaLabel}>
@ -95,29 +97,11 @@ export default class AssetDetails extends PureComponent<AssetDetailsProps> {
<code>{ddo.id}</code> <code>{ddo.id}</code>
</span> </span>
</li> </li>
{allowPricing ? ( {allowPricing ? <Pricing price={base.price} /> : null}
<li>
<span className={styles.metaLabel}>
<strong>Price</strong>
</span>
<span className={styles.metaValue}>
{base.price === '0'
? 0
: Web3.utils.fromWei(
base.price.toString()
)}{' '}
OCEAN
</span>
</li>
) : null}
</ul> </ul>
</div> </div>
<AssetFilesDetails <AssetFilesDetails files={base.files ? base.files : []} ddo={ddo} />
files={base.files ? base.files : []}
ddo={ddo}
/>
</> </>
) )
} }
}

View File

@ -54,12 +54,13 @@ class Asset extends Component<AssetProps, AssetState> {
public render() { public render() {
const { metadata, ddo, error } = this.state const { metadata, ddo, error } = this.state
const isLoading = metadata.base.name === '' const isLoading = metadata.base.name === ''
const hasError = error !== ''
return isLoading ? ( return isLoading && !hasError ? (
<div className={stylesApp.loader}> <div className={stylesApp.loader}>
<Spinner message="Loading asset..." /> <Spinner message="Loading asset..." />
</div> </div>
) : error !== '' ? ( ) : hasError ? (
<div className={styles.error}>{error}</div> <div className={styles.error}>{error}</div>
) : ( ) : (
<Route <Route