SearchResultList.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import React, { FC } from 'react';
  2. import SearchResultListItem from './SearchResultListItem';
  3. import { IPageHasId } from '../../interfaces/page';
  4. import PaginationWrapper from '../PaginationWrapper';
  5. // TOOD: retrieve bookmark count and add it to the following type
  6. export type ISearchedPage = IPageHasId & {
  7. snippet: string,
  8. elasticSearchResult: {
  9. snippet: string,
  10. matchedPath: string,
  11. },
  12. };
  13. type Props = {
  14. pages: ISearchedPage[],
  15. selectedPages: ISearchedPage[],
  16. onClickInvoked?: (pageId: string) => void,
  17. searchResultCount?: number,
  18. activePage?: number,
  19. pagingLimit?: number,
  20. onPagingNumberChanged?: (activePage: number) => void,
  21. }
  22. const SearchResultList: FC<Props> = (props:Props) => {
  23. return (
  24. <>
  25. {props.pages.map((page) => {
  26. return (
  27. <SearchResultListItem
  28. page={page}
  29. onClickInvoked={props.onClickInvoked}
  30. />
  31. );
  32. })}
  33. {props.searchResultCount != null && props.searchResultCount > 0 && (
  34. <div className="my-4 mx-auto">
  35. <PaginationWrapper
  36. activePage={props.activePage || 1}
  37. changePage={props.onPagingNumberChanged}
  38. totalItemsCount={props.searchResultCount || 0}
  39. pagingLimit={props.pagingLimit}
  40. />
  41. </div>
  42. )}
  43. </>
  44. );
  45. };
  46. export default SearchResultList;