mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
use queryMetadata
This commit is contained in:
parent
f954537929
commit
6323c5bbb3
@ -1,6 +1,5 @@
|
|||||||
import { MetaDataMarket } from '../../../@types/MetaData'
|
import { MetaDataMarket } from '../../../@types/MetaData'
|
||||||
import React, { ReactElement } from 'react'
|
import React, { ReactElement } from 'react'
|
||||||
import { useOcean } from '@oceanprotocol/react'
|
|
||||||
import Time from '../../atoms/Time'
|
import Time from '../../atoms/Time'
|
||||||
import { Link } from 'gatsby'
|
import { Link } from 'gatsby'
|
||||||
import Markdown from '../../atoms/Markdown'
|
import Markdown from '../../atoms/Markdown'
|
||||||
|
@ -3,23 +3,27 @@ import SearchBar from '../molecules/SearchBar'
|
|||||||
import { ServiceMetaDataMarket } from '../../@types/MetaData'
|
import { ServiceMetaDataMarket } from '../../@types/MetaData'
|
||||||
import AssetTeaser from '../molecules/AssetTeaser'
|
import AssetTeaser from '../molecules/AssetTeaser'
|
||||||
import styles from './Home.module.css'
|
import styles from './Home.module.css'
|
||||||
import axios from 'axios'
|
|
||||||
import { oceanConfig } from '../../../app.config'
|
import { oceanConfig } from '../../../app.config'
|
||||||
import { DDO } from '@oceanprotocol/lib'
|
import { DDO, MetadataStore, Logger } from '@oceanprotocol/lib'
|
||||||
|
|
||||||
export default function HomePage(): ReactElement {
|
export default function HomePage(): ReactElement {
|
||||||
const [assets, setAssets] = useState<DDO[]>()
|
const [assets, setAssets] = useState<DDO[]>()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
async function getAllAssets() {
|
async function getAllAssets() {
|
||||||
try {
|
const metadataStore = new MetadataStore(
|
||||||
const result = await axios(
|
oceanConfig.metadataStoreUri,
|
||||||
`${oceanConfig.metadataStoreUri}/api/v1/aquarius/assets/ddo`
|
Logger
|
||||||
)
|
)
|
||||||
setAssets(result.data)
|
|
||||||
} catch (error) {
|
const result = await metadataStore.queryMetadata({
|
||||||
console.error(error.message)
|
page: 1,
|
||||||
}
|
offset: 10,
|
||||||
|
query: {},
|
||||||
|
sort: { created: -1 }
|
||||||
|
})
|
||||||
|
|
||||||
|
result && result.results && setAssets(result.results)
|
||||||
}
|
}
|
||||||
getAllAssets()
|
getAllAssets()
|
||||||
}, [])
|
}, [])
|
||||||
|
@ -7,7 +7,7 @@ import { MetaDataMarket, ServiceMetaDataMarket } from '../../@types/MetaData'
|
|||||||
import { MetadataStore, Logger } from '@oceanprotocol/lib'
|
import { MetadataStore, Logger } from '@oceanprotocol/lib'
|
||||||
import { oceanConfig } from '../../../app.config'
|
import { oceanConfig } from '../../../app.config'
|
||||||
import Alert from '../../components/atoms/Alert'
|
import Alert from '../../components/atoms/Alert'
|
||||||
import { useMetadata } from '@oceanprotocol/react'
|
import Loader from '../../components/atoms/Loader'
|
||||||
|
|
||||||
export default function AssetRoute(props: PageProps): ReactElement {
|
export default function AssetRoute(props: PageProps): ReactElement {
|
||||||
const [metadata, setMetadata] = useState<MetaDataMarket>()
|
const [metadata, setMetadata] = useState<MetaDataMarket>()
|
||||||
@ -45,11 +45,7 @@ export default function AssetRoute(props: PageProps): ReactElement {
|
|||||||
init()
|
init()
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
return error ? (
|
return did && metadata ? (
|
||||||
<Layout title={title} noPageHeader uri={props.location.pathname}>
|
|
||||||
<Alert title={title} text={error} state="error" />
|
|
||||||
</Layout>
|
|
||||||
) : did && metadata ? (
|
|
||||||
<Layout title={title} uri={props.location.pathname}>
|
<Layout title={title} uri={props.location.pathname}>
|
||||||
<Router basepath="/asset">
|
<Router basepath="/asset">
|
||||||
<AssetContent
|
<AssetContent
|
||||||
@ -59,9 +55,13 @@ export default function AssetRoute(props: PageProps): ReactElement {
|
|||||||
/>
|
/>
|
||||||
</Router>
|
</Router>
|
||||||
</Layout>
|
</Layout>
|
||||||
|
) : error ? (
|
||||||
|
<Layout title={title} noPageHeader uri={props.location.pathname}>
|
||||||
|
<Alert title={title} text={error} state="error" />
|
||||||
|
</Layout>
|
||||||
) : (
|
) : (
|
||||||
<Layout title="Loading..." uri={props.location.pathname}>
|
<Layout title="Loading..." uri={props.location.pathname}>
|
||||||
Loading...
|
<Loader />
|
||||||
</Layout>
|
</Layout>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user