mirror of
https://github.com/oceanprotocol/commons.git
synced 2023-03-15 18:03:00 +01:00
lints
This commit is contained in:
parent
d0461228d5
commit
851777a1a6
@ -54,7 +54,7 @@ class Search extends PureComponent<SearchProps, SearchState> {
|
|||||||
|
|
||||||
public async componentDidMount() {
|
public async componentDidMount() {
|
||||||
const { search } = this.props.location
|
const { search } = this.props.location
|
||||||
const { text, page, categories, license } = queryString.parse(search)
|
const { text, page, categories, license } = queryString.parse(search)
|
||||||
|
|
||||||
let update: any = {}
|
let update: any = {}
|
||||||
if (text) {
|
if (text) {
|
||||||
@ -62,15 +62,15 @@ class Search extends PureComponent<SearchProps, SearchState> {
|
|||||||
update.search = decodeURIComponent(`${text}`)
|
update.search = decodeURIComponent(`${text}`)
|
||||||
}
|
}
|
||||||
if (categories) {
|
if (categories) {
|
||||||
update.searchCategories = decodeURIComponent(`${categories}`)
|
update.searchCategories = decodeURIComponent(`${categories}`)
|
||||||
update.category = decodeURIComponent(`${categories}`)
|
update.category = decodeURIComponent(`${categories}`)
|
||||||
}
|
}
|
||||||
if (license) {
|
if (license) {
|
||||||
update.searchLicense = decodeURIComponent(`${license}`)
|
update.searchLicense = decodeURIComponent(`${license}`)
|
||||||
update.license = decodeURIComponent(`${license}`)
|
update.license = decodeURIComponent(`${license}`)
|
||||||
}
|
}
|
||||||
if (page) {
|
if (page) {
|
||||||
update.currentPage = Number(page)
|
update.currentPage = Number(page)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState(update, () => this.searchAssets())
|
this.setState(update, () => this.searchAssets())
|
||||||
@ -79,14 +79,14 @@ class Search extends PureComponent<SearchProps, SearchState> {
|
|||||||
private searchAssets = async () => {
|
private searchAssets = async () => {
|
||||||
const { ocean } = this.context
|
const { ocean } = this.context
|
||||||
const { offset, currentPage, search, category, license } = this.state
|
const { offset, currentPage, search, category, license } = this.state
|
||||||
const queryValues:any = {}
|
const queryValues: any = {}
|
||||||
if(search){
|
if (search) {
|
||||||
queryValues.text = [search]
|
queryValues.text = [search]
|
||||||
}
|
}
|
||||||
if(category){
|
if (category) {
|
||||||
queryValues.categories = [category]
|
queryValues.categories = [category]
|
||||||
}
|
}
|
||||||
if(license){
|
if (license) {
|
||||||
queryValues.license = [license]
|
queryValues.license = [license]
|
||||||
}
|
}
|
||||||
const searchQuery = {
|
const searchQuery = {
|
||||||
@ -123,38 +123,49 @@ class Search extends PureComponent<SearchProps, SearchState> {
|
|||||||
search: `?text=${this.state.searchTerm}&page=${toPage}`
|
search: `?text=${this.state.searchTerm}&page=${toPage}`
|
||||||
})
|
})
|
||||||
|
|
||||||
this.setState({ currentPage: toPage, isLoading: true }, () => this.searchAssets())
|
this.setState({ currentPage: toPage, isLoading: true }, () =>
|
||||||
|
this.searchAssets()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private inputChange = (event: ChangeEvent<HTMLInputElement> | ChangeEvent<HTMLSelectElement>) => {
|
private inputChange = (
|
||||||
|
event: ChangeEvent<HTMLInputElement> | ChangeEvent<HTMLSelectElement>
|
||||||
|
) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
[event.currentTarget.name]: event.currentTarget.value
|
[event.currentTarget.name]: event.currentTarget.value
|
||||||
} as any)
|
} as any)
|
||||||
}
|
}
|
||||||
|
|
||||||
private search = (event: ChangeEvent<HTMLInputElement>) => {
|
private search = (event: ChangeEvent<HTMLInputElement>) => {
|
||||||
|
|
||||||
let searchUrl = '?'
|
let searchUrl = '?'
|
||||||
|
|
||||||
if (this.state.search){
|
if (this.state.search) {
|
||||||
searchUrl = `${searchUrl}text=${encodeURIComponent(this.state.search)}&`
|
searchUrl = `${searchUrl}text=${encodeURIComponent(
|
||||||
|
this.state.search
|
||||||
|
)}&`
|
||||||
}
|
}
|
||||||
if (this.state.category){
|
if (this.state.category) {
|
||||||
searchUrl = `${searchUrl}categories=${encodeURIComponent(this.state.category)}&`
|
searchUrl = `${searchUrl}categories=${encodeURIComponent(
|
||||||
|
this.state.category
|
||||||
|
)}&`
|
||||||
}
|
}
|
||||||
if (this.state.license){
|
if (this.state.license) {
|
||||||
searchUrl = `${searchUrl}license=${encodeURIComponent(this.state.license)}&`
|
searchUrl = `${searchUrl}license=${encodeURIComponent(
|
||||||
|
this.state.license
|
||||||
|
)}&`
|
||||||
}
|
}
|
||||||
this.props.history.push({
|
this.props.history.push({
|
||||||
pathname: this.props.location.pathname,
|
pathname: this.props.location.pathname,
|
||||||
search: searchUrl
|
search: searchUrl
|
||||||
})
|
})
|
||||||
this.setState({
|
this.setState(
|
||||||
searchTerm: this.state.search,
|
{
|
||||||
currentPage: 1,
|
searchTerm: this.state.search,
|
||||||
isLoading: true
|
currentPage: 1,
|
||||||
}, () => this.searchAssets())
|
isLoading: true
|
||||||
|
},
|
||||||
|
() => this.searchAssets()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
public renderResults = () =>
|
public renderResults = () =>
|
||||||
@ -175,7 +186,7 @@ class Search extends PureComponent<SearchProps, SearchState> {
|
|||||||
|
|
||||||
public render() {
|
public render() {
|
||||||
const { totalResults, totalPages, currentPage } = this.state
|
const { totalResults, totalPages, currentPage } = this.state
|
||||||
const { steps }:any = data
|
const { steps }: any = data
|
||||||
return (
|
return (
|
||||||
<Route title="Search" wide>
|
<Route title="Search" wide>
|
||||||
<Content wide>
|
<Content wide>
|
||||||
|
Loading…
Reference in New Issue
Block a user