mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
import React from 'react'
|
|
import { Link } from 'gatsby'
|
|
import Dotdotdot from 'react-dotdotdot'
|
|
import Price from '../atoms/Price'
|
|
import styles from './AssetTeaser.module.css'
|
|
import { DDO } from '@oceanprotocol/lib'
|
|
import removeMarkdown from 'remove-markdown'
|
|
import Publisher from '../atoms/Publisher'
|
|
import Time from '../atoms/Time'
|
|
import AssetType from '../atoms/AssetType'
|
|
|
|
declare type AssetTeaserProps = {
|
|
ddo: DDO
|
|
}
|
|
|
|
const AssetTeaser: React.FC<AssetTeaserProps> = ({ ddo }: AssetTeaserProps) => {
|
|
const { attributes } = ddo.findServiceByType('metadata')
|
|
const { name, type } = attributes.main
|
|
const { dataTokenInfo } = ddo
|
|
const isCompute = Boolean(ddo?.findServiceByType('compute'))
|
|
const accessType = isCompute ? 'compute' : 'access'
|
|
const { owner } = ddo.publicKey[0]
|
|
|
|
return (
|
|
<article className={`${styles.teaser} ${styles[type]}`}>
|
|
<Link to={`/asset/${ddo.id}`} className={styles.link}>
|
|
<header className={styles.header}>
|
|
<div className={styles.symbol}>{dataTokenInfo?.symbol}</div>
|
|
<Dotdotdot clamp={3}>
|
|
<h1 className={styles.title}>{name}</h1>
|
|
</Dotdotdot>
|
|
<Publisher account={owner} minimal className={styles.publisher} />
|
|
</header>
|
|
|
|
<AssetType
|
|
type={type}
|
|
accessType={accessType}
|
|
className={styles.typeDetails}
|
|
/>
|
|
|
|
<div className={styles.content}>
|
|
<Dotdotdot tagName="p" clamp={3}>
|
|
{removeMarkdown(
|
|
attributes?.additionalInformation?.description || ''
|
|
)}
|
|
</Dotdotdot>
|
|
</div>
|
|
|
|
<footer className={styles.foot}>
|
|
<Price price={ddo.price} small />
|
|
<p className={styles.date}>
|
|
<Time date={ddo?.created} relative />
|
|
</p>
|
|
</footer>
|
|
</Link>
|
|
</article>
|
|
)
|
|
}
|
|
|
|
export default AssetTeaser
|