diff --git a/src/components/organisms/AssetList.module.css b/src/components/organisms/AssetList.module.css index 9d860bfaf..cf07a45ac 100644 --- a/src/components/organisms/AssetList.module.css +++ b/src/components/organisms/AssetList.module.css @@ -10,3 +10,8 @@ gap: var(--spacer); } } + +.empty { + color: var(--color-secondary); + font-size: var(--font-size-small); +} diff --git a/src/components/organisms/AssetList.tsx b/src/components/organisms/AssetList.tsx index 6a7aaae17..2f18752e9 100644 --- a/src/components/organisms/AssetList.tsx +++ b/src/components/organisms/AssetList.tsx @@ -1,18 +1,20 @@ import AssetTeaser from '../molecules/AssetTeaser' import React from 'react' import { QueryResult } from '@oceanprotocol/lib/dist/node/metadatastore/MetadataStore' -import shortid from 'shortid' import Pagination from '../molecules/Pagination' import { updateQueryStringParameter } from '../../utils' import styles from './AssetList.module.css' import { MetaDataMarket } from '../../@types/MetaData' import { DDO } from '@oceanprotocol/lib' +import { oceanConfig } from '../../../app.config' declare type AssetListProps = { queryResult: QueryResult } const AssetList: React.FC = ({ queryResult }) => { + // TODO: restore Pagination behavior + // Construct the urls on the pagination links. This is only for UX, // since the links are no they will not work by itself. // function hrefBuilder(pageIndex: number) { @@ -38,20 +40,21 @@ const AssetList: React.FC = ({ queryResult }) => { return ( <>
- {queryResult && + {queryResult && queryResult.totalResults > 0 ? ( queryResult.results.map((ddo: DDO) => { const { attributes }: MetaDataMarket = new DDO( ddo ).findServiceByType('metadata') return ( - + ) - })} + }) + ) : ( +
+ No data sets found in {oceanConfig.metadataStoreUri} +
+ )}
{/* () + const [queryResult, setQueryResult] = useState() useEffect(() => { - async function getLatestAssets() { - try { - const metadataStore = new MetadataStore( - oceanConfig.metadataStoreUri, - Logger - ) - - const result = await metadataStore.queryMetadata({ - page: 1, - offset: 10, - query: {}, - sort: { created: -1 } - }) - - result && result.results && setAssets(result.results) - } catch (error) { - console.error(error.message) - } + async function init() { + const results = await getLatestAssets() + setQueryResult(results) } - getLatestAssets() + init() }, []) return ( <> - - {assets && ( -
- {assets.length ? ( - assets.map((ddo: DDO) => { - const { - attributes - }: ServiceMetaDataMarket = ddo.findServiceByType('metadata') - - return ( - - ) - }) - ) : ( -
- No data sets found in {oceanConfig.metadataStoreUri} -
- )} -
- )} +

Latest Data Sets

+ {queryResult && } ) }