1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00
commons/src/components/molecules/AssetsUser.tsx

57 lines
1.7 KiB
TypeScript
Raw Normal View History

import React, { PureComponent } from 'react'
import { Link } from 'react-router-dom'
2019-02-15 17:26:28 +01:00
import Spinner from '../atoms/Spinner'
import Asset from '../molecules/Asset'
import styles from './AssetsUser.module.scss'
export default class AssetsUser extends PureComponent {
2019-02-15 17:26:28 +01:00
public state = { results: [], isLoading: true }
public componentDidMount() {
this.searchOcean()
}
private async searchOcean() {
const queryRequest: any = {
offset: 100,
page: 0,
query: {
// TODO: query all assets published by current active account
$text: {
$search: 'zoid'
}
}
}
2019-02-15 17:26:28 +01:00
try {
const assets = await this.context.ocean.searchAssets(queryRequest)
this.setState({ results: assets, isLoading: false })
} catch (error) {
this.setState({ isLoading: false })
}
}
public render() {
return (
<div className={styles.assetsUser}>
<h2 className={styles.subTitle}>Your Data Sets</h2>
2019-02-15 17:26:28 +01:00
{this.state.isLoading ? (
<Spinner />
) : this.state.results.length ? (
<div className={styles.assets}>
{this.state.results.map((asset, index) => (
<Asset key={index} asset={asset} />
))}
</div>
) : (
<div>
<p>None yet.</p>
<Link to="/publish">+ Publish A Data Set</Link>
</div>
)}
</div>
)
}
}