From 27f02f3e037f24b14f60c0af564d28d95df0e9bf Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Fri, 5 Apr 2019 15:24:06 +0200 Subject: [PATCH] ouput total results --- client/src/routes/Search.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/client/src/routes/Search.tsx b/client/src/routes/Search.tsx index d59e2aa..3602fd8 100644 --- a/client/src/routes/Search.tsx +++ b/client/src/routes/Search.tsx @@ -15,6 +15,7 @@ interface SearchProps { interface SearchState { results: any[] + totalResults: number offset: number totalPages: number currentPage: number @@ -24,6 +25,7 @@ interface SearchState { export default class Search extends PureComponent { public state = { results: [], + totalResults: 0, offset: 25, totalPages: 1, currentPage: 1, @@ -55,6 +57,7 @@ export default class Search extends PureComponent { ) this.setState({ results: search.results, + totalResults: search.totalResults, totalPages: search.totalPages, currentPage: search.page + 1, // first page is always 0 in response isLoading: false @@ -81,11 +84,13 @@ export default class Search extends PureComponent { ) public render() { - const { totalPages, currentPage } = this.state + const { totalResults, totalPages, currentPage } = this.state return ( ${this.searchTerm}`} + title={`${totalResults > 0 && totalResults} Results for ${ + this.searchTerm + }`} titleReverse wide >