mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
adapt to new search response
This commit is contained in:
parent
0c38b6caa3
commit
79e37e965f
@ -13,14 +13,14 @@ interface SearchProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
interface SearchState {
|
interface SearchState {
|
||||||
assets: any[]
|
results: any[]
|
||||||
isLoading: boolean
|
isLoading: boolean
|
||||||
page: number
|
page: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Search extends PureComponent<SearchProps, SearchState> {
|
export default class Search extends PureComponent<SearchProps, SearchState> {
|
||||||
public state = {
|
public state = {
|
||||||
assets: [],
|
results: [],
|
||||||
isLoading: true,
|
isLoading: true,
|
||||||
page: 0
|
page: 0
|
||||||
}
|
}
|
||||||
@ -45,19 +45,19 @@ export default class Search extends PureComponent<SearchProps, SearchState> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const assets = await this.context.ocean.aquarius.queryMetadata(
|
const search = await this.context.ocean.aquarius.queryMetadata(
|
||||||
searchQuery
|
searchQuery
|
||||||
)
|
)
|
||||||
this.setState({ assets, isLoading: false })
|
this.setState({ results: search.results, isLoading: false })
|
||||||
Logger.log(`Loaded ${assets.length} assets`)
|
Logger.log(`Loaded ${this.state.results.length} assets`)
|
||||||
}
|
}
|
||||||
|
|
||||||
public renderResults = () =>
|
public renderResults = () =>
|
||||||
this.state.isLoading ? (
|
this.state.isLoading ? (
|
||||||
<Spinner message="Searching..." />
|
<Spinner message="Searching..." />
|
||||||
) : this.state.assets.length ? (
|
) : this.state.results && this.state.results.length ? (
|
||||||
<div className={styles.results}>
|
<div className={styles.results}>
|
||||||
{this.state.assets.map((asset: any) => (
|
{this.state.results.map((asset: any) => (
|
||||||
<Asset key={asset.id} asset={asset} />
|
<Asset key={asset.id} asset={asset} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user