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
mihaisc dac47bf524
3Box publisher profiles (#264)
* install 3box

Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>

* tinkering

* check tweak

* load library on init only

* add profile

Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>

* get 3box profile

Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>

* fix return type

Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>

* remove console.log

* fix travis

Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>

* fix eslit

Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>

* fix travis

Signed-off-by: mihaisc <mihai.scarlat@smartcontrol.ro>

* 3box data structure tweaks, prepare output in byline

* refactor

* new Publisher component

* tweaks

* remove data partners

* link/profile splitup

* profile tweaks

* component splitup

* lots of styling, add image

* affordance for publisher, refactor, server response tinkering

* use 3Box proxy

* open all 3box links in new tab/window

* mobile fixes

Co-authored-by: Matthias Kretschmann <m@kretschmann.io>
2020-11-27 12:04:35 +01:00

105 lines
3.1 KiB
TypeScript

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'
import styles from './index.module.css'
import AssetActions from '../AssetActions'
import { DDO } from '@oceanprotocol/lib'
import { useUserPreferences } from '../../../providers/UserPreferences'
import Pricing from './Pricing'
import { useOcean, usePricing } from '@oceanprotocol/react'
import EtherscanLink from '../../atoms/EtherscanLink'
import Bookmark from './Bookmark'
import Publisher from '../../atoms/Publisher'
import { useAsset } from '../../../providers/Asset'
export interface AssetContentProps {
metadata: MetadataMarket
ddo: DDO
path?: string
}
export default function AssetContent({
metadata,
ddo
}: AssetContentProps): ReactElement {
const { debug } = useUserPreferences()
const { accountId, networkId } = useOcean()
const { owner } = useAsset()
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}>
<div>
{showPricing && <Pricing ddo={ddo} />}
<div className={styles.content}>
{metadata?.additionalInformation?.categories?.length && (
<p>
<Link
to={`/search?categories=${metadata?.additionalInformation?.categories[0]}`}
>
{metadata?.additionalInformation?.categories[0]}
</Link>
</p>
)}
<aside className={styles.meta}>
<p className={styles.datatoken}>
<EtherscanLink
networkId={networkId}
path={`token/${ddo.dataToken}`}
>
{dtName ? (
`${dtName}${dtSymbol}`
) : (
<code>{ddo.dataToken}</code>
)}
</EtherscanLink>
</p>
Published By <Publisher account={owner} />
</aside>
<Markdown
className={styles.description}
text={metadata?.additionalInformation?.description || ''}
/>
<MetaSecondary metadata={metadata} />
<MetaFull ddo={ddo} metadata={metadata} />
<div className={styles.buttonGroup}>
{/* <EditAction
ddo={ddo}
ocean={ocean}
account={account}
refetchMetadata={refetchMetadata}
/> */}
{/* <DeleteAction ddo={ddo} /> */}
</div>
{debug === true && (
<pre>
<code>{JSON.stringify(ddo, null, 2)}</code>
</pre>
)}
<Bookmark did={ddo.id} />
</div>
</div>
<div className={styles.actions}>
<AssetActions ddo={ddo} />
</div>
</article>
)
}