1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-06-26 03:06:49 +02:00
market/src/components/organisms/AssetContent/index.tsx

120 lines
3.5 KiB
TypeScript
Raw Normal View History

2020-10-01 17:13:19 +02:00
import { MetadataMarket } from '../../../@types/MetaData'
import React, { ReactElement } from 'react'
import { Link } from 'gatsby'
import Markdown from '../../atoms/Markdown'
import MetaFull from './MetaFull'
import MetaSecondary from './MetaSecondary'
2020-07-07 09:43:45 +02:00
import styles from './index.module.css'
2020-07-08 17:57:53 +02:00
import AssetActions from '../AssetActions'
2020-07-21 14:04:32 +02:00
import { DDO } from '@oceanprotocol/lib'
2020-09-09 16:07:37 +02:00
import { useUserPreferences } from '../../../providers/UserPreferences'
2020-10-20 13:10:03 +02:00
import Pricing from './Pricing'
import { useMetadata, useOcean, usePricing } from '@oceanprotocol/react'
2020-10-24 17:01:04 +02:00
import EtherscanLink from '../../atoms/EtherscanLink'
import Bookmark from './Bookmark'
2020-10-30 14:58:36 +01:00
import { accountTruncate } from '../../../utils/wallet'
export interface AssetContentProps {
2020-07-16 13:39:02 +02:00
metadata: MetadataMarket
2020-07-21 13:21:22 +02:00
ddo: DDO
path?: string
}
export default function AssetContent({
metadata,
2020-07-21 13:21:22 +02:00
ddo
}: AssetContentProps): ReactElement {
2020-09-09 16:07:37 +02:00
const { debug } = useUserPreferences()
2020-10-24 17:01:04 +02:00
const { accountId, networkId } = useOcean()
const { owner } = useMetadata(ddo)
2020-10-24 17:01:04 +02:00
const { dtSymbol, dtName } = usePricing(ddo)
2020-10-20 18:33:24 +02:00
const isOwner = accountId === owner
const hasNoPrice = ddo.price.datatoken === 0 && ddo.price.value === 0
2020-10-26 19:30:51 +01:00
const showPricing = isOwner && hasNoPrice
return (
<article className={styles.grid}>
2020-10-20 20:56:54 +02:00
<div>
2020-10-20 18:33:24 +02:00
{showPricing && <Pricing ddo={ddo} />}
2020-10-20 13:10:03 +02:00
2020-10-20 20:56:54 +02:00
<div className={styles.content}>
<aside className={styles.meta}>
2020-10-30 14:58:36 +01:00
<p className={styles.author} title="Author">
{metadata?.main.author}
</p>
2020-10-24 17:01:04 +02:00
<p className={styles.datatoken}>
<EtherscanLink
networkId={networkId}
path={`token/${ddo.dataToken}`}
>
{dtName ? (
`${dtName}${dtSymbol}`
2020-10-24 17:01:04 +02:00
) : (
<code>{ddo.dataToken}</code>
)}
</EtherscanLink>
</p>
<p>
2020-10-30 14:58:36 +01:00
Published by{' '}
<Link
to={`/search/?owner=${owner}`}
title="Show all data sets created by this account."
2020-10-30 14:58:36 +01:00
>
{owner && accountTruncate(owner)}
</Link>
{' — '}
<EtherscanLink networkId={networkId} path={`address/${owner}`}>
Etherscan
2020-10-30 14:58:36 +01:00
</EtherscanLink>
</p>
2020-10-20 20:56:54 +02:00
{metadata?.additionalInformation?.categories?.length && (
<p>
<Link
2020-10-24 17:39:51 +02:00
to={`/search?categories=${metadata?.additionalInformation?.categories[0]}`}
2020-10-20 20:56:54 +02:00
>
{metadata?.additionalInformation?.categories[0]}
</Link>
</p>
)}
</aside>
2020-10-28 19:11:34 +01:00
<Markdown
className={styles.description}
text={metadata?.additionalInformation?.description || ''}
/>
2020-10-20 20:56:54 +02:00
<MetaSecondary metadata={metadata} />
2020-07-08 00:06:48 +02:00
2020-10-20 20:56:54 +02:00
<MetaFull ddo={ddo} metadata={metadata} />
2020-07-08 00:06:48 +02:00
2020-10-20 20:56:54 +02:00
<div className={styles.buttonGroup}>
{/* <EditAction
ddo={ddo}
ocean={ocean}
account={account}
refetchMetadata={refetchMetadata}
/> */}
2020-10-20 20:56:54 +02:00
{/* <DeleteAction ddo={ddo} /> */}
</div>
2020-08-03 12:04:03 +02:00
2020-10-20 20:56:54 +02:00
{debug === true && (
<pre>
<code>{JSON.stringify(ddo, null, 2)}</code>
</pre>
)}
<Bookmark did={ddo.id} />
2020-10-20 20:56:54 +02:00
</div>
</div>
2020-10-20 20:56:54 +02:00
<div className={styles.actions}>
<AssetActions ddo={ddo} />
</div>
</article>
)
}