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

103 lines
3.0 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 Time from '../../atoms/Time'
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'
2020-10-24 17:01:04 +02:00
import { useOcean, usePricing } from '@oceanprotocol/react'
import EtherscanLink from '../../atoms/EtherscanLink'
import MetaItem from './MetaItem'
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 { dtSymbol, dtName } = usePricing(ddo)
2020-10-20 18:33:24 +02:00
const isOwner = accountId === ddo.publicKey[0].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}>
<p className={styles.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}`
) : (
<code>{ddo.dataToken}</code>
)}
</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>
)}
</div>
</div>
2020-10-20 20:56:54 +02:00
<div>
<div className={styles.sticky}>
2020-08-26 08:48:22 +02:00
<AssetActions ddo={ddo} />
</div>
</div>
</article>
)
}