mirror of
https://github.com/oceanprotocol/market.git
synced 2024-11-15 01:34:57 +01:00
safeguard against assets without attributes.additionalInformation
This commit is contained in:
parent
5b36da54d2
commit
cda52aef1c
@ -15,11 +15,7 @@ const AssetTeaser: React.FC<AssetTeaserProps> = ({
|
||||
ddo,
|
||||
metadata
|
||||
}: AssetTeaserProps) => {
|
||||
// TODO: hacky safeguard should be replaced with search query to account for pagination
|
||||
if (!metadata.additionalInformation) return null
|
||||
|
||||
const { name } = metadata.main
|
||||
const { description } = metadata.additionalInformation
|
||||
const isCompute = Boolean(ddo.findServiceByType('compute'))
|
||||
|
||||
return (
|
||||
@ -30,7 +26,7 @@ const AssetTeaser: React.FC<AssetTeaserProps> = ({
|
||||
|
||||
<div className={styles.content}>
|
||||
<Dotdotdot tagName="p" clamp={3}>
|
||||
{description || ''}
|
||||
{metadata?.additionalInformation?.description || ''}
|
||||
</Dotdotdot>
|
||||
</div>
|
||||
|
||||
|
@ -7,6 +7,7 @@ import Tabs from '../../atoms/Tabs'
|
||||
import { useOcean, useMetadata } from '@oceanprotocol/react'
|
||||
import compareAsBN from '../../../utils/compareAsBN'
|
||||
import Pool from './Pool'
|
||||
import { AdditionalInformationMarket } from '../../../@types/MetaData'
|
||||
|
||||
export default function AssetActions({ ddo }: { ddo: DDO }): ReactElement {
|
||||
const { balance } = useOcean()
|
||||
@ -15,7 +16,6 @@ export default function AssetActions({ ddo }: { ddo: DDO }): ReactElement {
|
||||
|
||||
const isCompute = Boolean(ddo.findServiceByType('compute'))
|
||||
const { attributes } = ddo.findServiceByType('metadata')
|
||||
const { priceType } = attributes.additionalInformation
|
||||
|
||||
// Check user balance against price
|
||||
useEffect(() => {
|
||||
@ -44,7 +44,10 @@ export default function AssetActions({ ddo }: { ddo: DDO }): ReactElement {
|
||||
title: 'Use',
|
||||
content: UseContent
|
||||
},
|
||||
(!priceType || priceType === 'dynamic') && {
|
||||
(!((attributes.additionalInformation as unknown) as AdditionalInformationMarket)
|
||||
?.priceType ||
|
||||
((attributes.additionalInformation as unknown) as AdditionalInformationMarket)
|
||||
?.priceType === 'dynamic') && {
|
||||
title: 'Pool',
|
||||
content: <Pool ddo={ddo} />
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ export default function MetaFull({
|
||||
const { ocean, accountId } = useOcean()
|
||||
const { id, dataToken } = ddo
|
||||
const { dateCreated, datePublished, author, license } = metadata.main
|
||||
const { categories, copyrightHolder } = metadata.additionalInformation
|
||||
|
||||
const [dtName, setDtName] = useState<string>()
|
||||
const [dtSymbol, setDtSymbol] = useState<string>()
|
||||
@ -38,9 +37,17 @@ export default function MetaFull({
|
||||
return (
|
||||
<div className={styles.metaFull}>
|
||||
<MetaItem title="Author" content={author} />
|
||||
<MetaItem title="Copyright Holder" content={copyrightHolder} />
|
||||
<MetaItem
|
||||
title="Copyright Holder"
|
||||
content={metadata?.additionalInformation?.copyrightHolder}
|
||||
/>
|
||||
<MetaItem title="License" content={license} />
|
||||
{categories && <MetaItem title="Category" content={categories[0]} />}
|
||||
{metadata?.additionalInformation?.categories && (
|
||||
<MetaItem
|
||||
title="Category"
|
||||
content={metadata?.additionalInformation?.categories[0]}
|
||||
/>
|
||||
)}
|
||||
<MetaItem title="Data Created" content={<Time date={dateCreated} />} />
|
||||
|
||||
<MetaItem
|
||||
|
@ -10,31 +10,33 @@ export default function MetaSecondary({
|
||||
}: {
|
||||
metadata: MetadataMarket
|
||||
}): ReactElement {
|
||||
const { links, tags } = metadata.additionalInformation
|
||||
|
||||
return (
|
||||
<aside className={styles.metaSecondary}>
|
||||
{tags && tags.length > 0 && <Tags items={tags} />}
|
||||
{metadata?.additionalInformation?.tags &&
|
||||
metadata?.additionalInformation?.tags.length > 0 && (
|
||||
<Tags items={metadata?.additionalInformation?.tags} />
|
||||
)}
|
||||
|
||||
{links && links.length && (
|
||||
<div className={styles.samples}>
|
||||
<MetaItem
|
||||
title="Sample Data"
|
||||
content={
|
||||
<Button
|
||||
href={links[0].url}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
download
|
||||
style="text"
|
||||
size="small"
|
||||
>
|
||||
Download Sample
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
{metadata?.additionalInformation?.links &&
|
||||
metadata?.additionalInformation?.links.length && (
|
||||
<div className={styles.samples}>
|
||||
<MetaItem
|
||||
title="Sample Data"
|
||||
content={
|
||||
<Button
|
||||
href={metadata?.additionalInformation?.links[0].url}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
download
|
||||
style="text"
|
||||
size="small"
|
||||
>
|
||||
Download Sample
|
||||
</Button>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</aside>
|
||||
)
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ export default function AssetContent({
|
||||
ddo
|
||||
}: AssetContentProps): ReactElement {
|
||||
const { datePublished } = metadata.main
|
||||
const { description, categories } = metadata.additionalInformation
|
||||
const { debug } = useUserPreferences()
|
||||
|
||||
return (
|
||||
@ -29,16 +28,19 @@ export default function AssetContent({
|
||||
<div className={styles.content}>
|
||||
<aside className={styles.meta}>
|
||||
<p>{datePublished && <Time date={datePublished} />}</p>
|
||||
{categories && categories.length && (
|
||||
<p>
|
||||
<Link to={`/search?categories=["${categories[0]}"]`}>
|
||||
{categories[0]}
|
||||
</Link>
|
||||
</p>
|
||||
)}
|
||||
{metadata?.additionalInformation?.categories &&
|
||||
metadata?.additionalInformation?.categories?.length && (
|
||||
<p>
|
||||
<Link
|
||||
to={`/search?categories=["${metadata?.additionalInformation?.categories[0]}"]`}
|
||||
>
|
||||
{metadata?.additionalInformation?.categories[0]}
|
||||
</Link>
|
||||
</p>
|
||||
)}
|
||||
</aside>
|
||||
|
||||
<Markdown text={description || ''} />
|
||||
<Markdown text={metadata?.additionalInformation?.description || ''} />
|
||||
|
||||
<MetaSecondary metadata={metadata} />
|
||||
|
||||
|
@ -14,8 +14,7 @@ async function getLatestAssets(metadataStoreUri: string) {
|
||||
|
||||
const result = await metadataStore.queryMetadata({
|
||||
page: 1,
|
||||
// TODO: hacky workaround because some assets pushed by external devs are faulty
|
||||
// See molecules/AssetTeaser.tsx
|
||||
// TODO: reduce assets here, once faulty assets pushed by external devs are removed
|
||||
offset: 100,
|
||||
query: {},
|
||||
sort: { created: -1 }
|
||||
|
Loading…
Reference in New Issue
Block a user