Просмотр исходного кода

79951 replace tentetive number with a total number of pages returned from elasticsearch

Yohei-Shiina 4 лет назад
Родитель
Сommit
70325ec13a

+ 3 - 0
packages/app/src/components/SearchPage.jsx

@@ -32,6 +32,7 @@ class SearchPage extends React.Component {
       searchResultMeta: {},
       selectedPage: {},
       selectedPages: new Set(),
+      searchResultCount: 0,
       excludeUsersHome: true,
       excludeTrash: true,
     };
@@ -124,6 +125,7 @@ class SearchPage extends React.Component {
             searchedKeyword: keyword,
             searchedPages: res.data,
             searchResultMeta: res.meta,
+            searchResultCount: res.totalCount,
             selectedPage: res.data[0],
           });
         }
@@ -177,6 +179,7 @@ class SearchPage extends React.Component {
         deletionMode={false}
         selectedPage={this.state.selectedPage}
         selectedPages={this.state.selectedPages}
+        searchResultCount={this.state.searchResultCount}
         onClickInvoked={this.selectPage}
         onChangedInvoked={this.toggleCheckBox}
       >

+ 3 - 2
packages/app/src/components/SearchPage/SearchResultList.jsx

@@ -21,8 +21,8 @@ class SearchResultList extends React.Component {
           <PaginationWrapper
             activePage={1}
             changePage={() => { console.log('page chagned') }} // Todo: replace this with a function to change state vars
-            // a total number of pages that can be retrieved from elasticsearch on the current search condition
-            totalItemsCount={10} // Todo: replace this with a state that dynamically changes its value
+            // a total number of pages retrieved from elasticsearch on the current search condition
+            totalItemsCount={this.props.searchResultCount}
             // a number of pages to show in one page
             pagingLimit={5} // Todo: replace this with a state that dynamically changes its value
           />
@@ -37,6 +37,7 @@ SearchResultList.propTypes = {
   pages: PropTypes.array.isRequired,
   deletionMode: PropTypes.bool.isRequired,
   selectedPages: PropTypes.array.isRequired,
+  searchResultCount: PropTypes.number,
   onClickInvoked: PropTypes.func,
   onChangeInvoked: PropTypes.func,
 };