From 050b1943738324ae479302be3da15aef8867defe Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Thu, 3 Sep 2020 10:02:55 +0200 Subject: [PATCH] simplify PublishedList --- src/components/organisms/PublishedList.tsx | 83 +++------------------- src/components/pages/History.tsx | 2 +- 2 files changed, 11 insertions(+), 74 deletions(-) diff --git a/src/components/organisms/PublishedList.tsx b/src/components/organisms/PublishedList.tsx index aa01085ac..228dc7dcf 100644 --- a/src/components/organisms/PublishedList.tsx +++ b/src/components/organisms/PublishedList.tsx @@ -1,87 +1,24 @@ import React, { useEffect, useState, ReactElement } from 'react' import Loader from '../atoms/Loader' -import { MetadataMain } from '@oceanprotocol/lib' -import { - useOcean, - OceanConnectionStatus, - useSearch -} from '@oceanprotocol/react' -import Table from '../atoms/Table' -import Price from '../atoms/Price' -import { fromWei } from 'web3-utils' -import DateCell from '../atoms/Table/DateCell' -import DdoLinkCell from '../atoms/Table/DdoLinkCell' - -const publishedColumns = [ - { - name: 'Published', - selector: 'published', - sortable: true, - cell: function getCell(row: any) { - return - } - }, - { - name: 'Name', - selector: 'name', - sortable: true, - cell: function getCell(row: any) { - return - } - }, - { - name: 'Price', - selector: 'price', - sortable: true, - cell: function getCell(row: any) { - return - } - } -] +import { useOcean } from '@oceanprotocol/react' +import { QueryResult } from '@oceanprotocol/lib/dist/node/metadatastore/MetadataStore' +import AssetList from './AssetList' export default function PublishedList(): ReactElement { const { ocean, status, account, accountId } = useOcean() - const { getPublishedList } = useSearch() - const [publishedList, setPublishedList] = useState([]) + const [queryResult, setQueryResult] = useState() const [isLoading, setIsLoading] = useState(false) - const [paginationParams, setPaginationParams] = useState({ - count: 1, - rowsPerPage: 10, - page: 1 - }) useEffect(() => { async function getPublished() { - if ( - !account || - !accountId || - !ocean || - status !== OceanConnectionStatus.CONNECTED - ) - return + if (!account || !accountId || !ocean) return setIsLoading(true) - const publishedItems = await getPublishedList( - paginationParams.page, - paginationParams.rowsPerPage - ) - setPaginationParams({ - ...paginationParams, - count: publishedItems.totalPages - }) - const data = publishedItems.results.map((ddo) => { - const { attributes } = ddo.findServiceByType('metadata') - const { name, price, datePublished } = attributes.main as MetadataMain - return { - published: datePublished, - name: name, - price: price, - id: ddo.id - } - }) + // const queryResult = await + + setQueryResult(queryResult) - setPublishedList(data) setIsLoading(false) } getPublished() @@ -89,8 +26,8 @@ export default function PublishedList(): ReactElement { return isLoading ? ( - ) : account && ocean ? ( - + ) : queryResult ? ( + ) : (
Connect your wallet to see your published data sets.
) diff --git a/src/components/pages/History.tsx b/src/components/pages/History.tsx index c86d92ef5..29c8257a5 100644 --- a/src/components/pages/History.tsx +++ b/src/components/pages/History.tsx @@ -8,7 +8,7 @@ import JobsList from '../organisms/JobsList' const sections = [ { title: 'Published', - component: 'Coming Soon...' + component: }, { title: 'Downloaded',