From 851777a1a6dadf8d171100cee45952cdd26fd93b Mon Sep 17 00:00:00 2001 From: Jernej Pregelj Date: Mon, 29 Jul 2019 11:30:12 +0200 Subject: [PATCH] lints --- client/src/routes/Search.tsx | 59 +++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/client/src/routes/Search.tsx b/client/src/routes/Search.tsx index 8fee3e0..a1e5f0c 100644 --- a/client/src/routes/Search.tsx +++ b/client/src/routes/Search.tsx @@ -54,7 +54,7 @@ class Search extends PureComponent { public async componentDidMount() { const { search } = this.props.location - const { text, page, categories, license } = queryString.parse(search) + const { text, page, categories, license } = queryString.parse(search) let update: any = {} if (text) { @@ -62,15 +62,15 @@ class Search extends PureComponent { update.search = decodeURIComponent(`${text}`) } if (categories) { - update.searchCategories = decodeURIComponent(`${categories}`) - update.category = decodeURIComponent(`${categories}`) + update.searchCategories = decodeURIComponent(`${categories}`) + update.category = decodeURIComponent(`${categories}`) } if (license) { update.searchLicense = decodeURIComponent(`${license}`) update.license = decodeURIComponent(`${license}`) } if (page) { - update.currentPage = Number(page) + update.currentPage = Number(page) } this.setState(update, () => this.searchAssets()) @@ -79,14 +79,14 @@ class Search extends PureComponent { private searchAssets = async () => { const { ocean } = this.context const { offset, currentPage, search, category, license } = this.state - const queryValues:any = {} - if(search){ + const queryValues: any = {} + if (search) { queryValues.text = [search] } - if(category){ + if (category) { queryValues.categories = [category] } - if(license){ + if (license) { queryValues.license = [license] } const searchQuery = { @@ -123,38 +123,49 @@ class Search extends PureComponent { 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 | ChangeEvent) => { + private inputChange = ( + event: ChangeEvent | ChangeEvent + ) => { this.setState({ [event.currentTarget.name]: event.currentTarget.value } as any) } private search = (event: ChangeEvent) => { - let searchUrl = '?' - if (this.state.search){ - searchUrl = `${searchUrl}text=${encodeURIComponent(this.state.search)}&` + if (this.state.search) { + searchUrl = `${searchUrl}text=${encodeURIComponent( + this.state.search + )}&` } - if (this.state.category){ - searchUrl = `${searchUrl}categories=${encodeURIComponent(this.state.category)}&` + if (this.state.category) { + searchUrl = `${searchUrl}categories=${encodeURIComponent( + this.state.category + )}&` } - if (this.state.license){ - searchUrl = `${searchUrl}license=${encodeURIComponent(this.state.license)}&` + if (this.state.license) { + searchUrl = `${searchUrl}license=${encodeURIComponent( + this.state.license + )}&` } this.props.history.push({ pathname: this.props.location.pathname, search: searchUrl }) - this.setState({ - searchTerm: this.state.search, - currentPage: 1, - isLoading: true - }, () => this.searchAssets()) + this.setState( + { + searchTerm: this.state.search, + currentPage: 1, + isLoading: true + }, + () => this.searchAssets() + ) } public renderResults = () => @@ -175,7 +186,7 @@ class Search extends PureComponent { public render() { const { totalResults, totalPages, currentPage } = this.state - const { steps }:any = data + const { steps }: any = data return (