SearchControl.tsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import React, { FC } from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import SearchPageForm from './SearchPageForm';
  4. import AppContainer from '../../client/services/AppContainer';
  5. type Props = {
  6. searchingKeyword: string,
  7. appContainer: AppContainer,
  8. onSearchInvoked: (data : any[]) => boolean,
  9. onExcludeUsersHome?: () => void,
  10. onExcludeTrash?: () => void,
  11. }
  12. const SearchControl: FC <Props> = (props: Props) => {
  13. // Temporaly workaround for lint error
  14. // later needs to be fixed: SearchControl to typescript componet
  15. const SearchPageFormTypeAny : any = SearchPageForm;
  16. const { t } = useTranslation('');
  17. const onExcludeUsersHome = () => {
  18. if (props.onExcludeUsersHome != null) {
  19. props.onExcludeUsersHome();
  20. }
  21. };
  22. const onExcludeTrash = () => {
  23. if (props.onExcludeTrash != null) {
  24. props.onExcludeTrash();
  25. }
  26. };
  27. return (
  28. <div className="">
  29. <div className="search-page-input sps sps--abv">
  30. <SearchPageFormTypeAny
  31. keyword={props.searchingKeyword}
  32. appContainer={props.appContainer}
  33. onSearchFormChanged={props.onSearchInvoked}
  34. />
  35. </div>
  36. {/* TODO: replace the following elements deleteAll button , relevance button and include specificPath button component */}
  37. <div className="d-flex my-4">
  38. <div className="form-check border-gray">
  39. <input
  40. className="form-check-input"
  41. type="checkbox"
  42. value=""
  43. id="flexCheckDefault"
  44. onClick={() => onExcludeUsersHome()}
  45. />
  46. <label className="form-check-label" htmlFor="flexCheckDefault">
  47. {t('Include Subordinated Target Page', { target: '/user' })}
  48. </label>
  49. </div>
  50. <div className="form-check">
  51. <input
  52. className="form-check-input"
  53. type="checkbox"
  54. value=""
  55. id="flexCheckChecked"
  56. onClick={() => onExcludeTrash()}
  57. />
  58. <label className="form-check-label" htmlFor="flexCheckChecked">
  59. {t('Include Subordinated Target Page', { target: '/trash' })}
  60. </label>
  61. </div>
  62. </div>
  63. </div>
  64. );
  65. };
  66. export default SearchControl;