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

105 lines
3.1 KiB
TypeScript
Raw Normal View History

2020-10-01 17:13:19 +02:00
import { MetadataMarket } from '../../../@types/MetaData'
import React, { ReactElement, useEffect, useState } 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 { useOcean, usePricing } from '@oceanprotocol/react'
2020-10-24 17:01:04 +02:00
import EtherscanLink from '../../atoms/EtherscanLink'
import Bookmark from './Bookmark'
import Publisher from '../../atoms/Publisher'
import { useAsset } from '../../../providers/Asset'
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 } = useAsset()
2020-10-24 17:01:04 +02:00
const { dtSymbol, dtName } = usePricing(ddo)
const [showPricing, setShowPricing] = useState(false)
const { price } = useAsset()
useEffect(() => {
setShowPricing(accountId === owner && price.isConsumable === '')
}, [accountId, owner, price])
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 20:56:54 +02:00
<div className={styles.content}>
{metadata?.additionalInformation?.categories?.length && (
<p>
<Link
to={`/search?categories=${metadata?.additionalInformation?.categories[0]}`}
>
{metadata?.additionalInformation?.categories[0]}
</Link>
2020-10-30 14:58:36 +01:00
</p>
)}
2020-10-24 17:01:04 +02:00
<aside className={styles.meta}>
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>
Published By <Publisher account={owner} />
2020-10-20 20:56:54 +02:00
</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>
)
}