IncludeSpecificPathButton.jsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import React, { useState } from 'react';
  2. import PropTypes from 'prop-types';
  3. import { useTranslation } from 'react-i18next';
  4. const IncludeSpecificPathButton = (props) => {
  5. const { pathToInclude, checked } = props;
  6. const { t } = useTranslation();
  7. // TODO : implement this function
  8. // 77526 story https://estoc.weseek.co.jp/redmine/issues/77526
  9. // 77535 stroy https://estoc.weseek.co.jp/redmine/issues/77535
  10. function includeSpecificPathInSearchResult(pathToInclude) {
  11. console.log(`now including ${pathToInclude} in search result`);
  12. }
  13. return (
  14. <div className="border px-2 btn btn-outline-secondary">
  15. <label className="mb-0">
  16. <span className="font-weight-light">
  17. {pathToInclude === '/user'
  18. ? t('search_result.include_certain_path', { pathToInclude: '/user' }) : t('search_result.include_certain_path', { pathToInclude: '/trash' })}
  19. </span>
  20. <input
  21. type="checkbox"
  22. name="check-include-specific-path"
  23. onChange={() => {
  24. if (checked) {
  25. includeSpecificPathInSearchResult(pathToInclude);
  26. }
  27. }}
  28. />
  29. </label>
  30. </div>
  31. );
  32. };
  33. IncludeSpecificPathButton.propTypes = {
  34. pathToInclude: PropTypes.string.isRequired,
  35. checked: PropTypes.bool.isRequired,
  36. };
  37. export default IncludeSpecificPathButton;