SearchOptionModal.tsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import type { FC } from 'react';
  2. import React from 'react';
  3. import { useTranslation } from 'next-i18next';
  4. import {
  5. Modal, ModalHeader, ModalBody,
  6. } from 'reactstrap';
  7. type Props = {
  8. isOpen: boolean,
  9. includeUserPages: boolean,
  10. includeTrashPages: boolean,
  11. onClose?: () => void,
  12. onIncludeUserPagesSwitched?: (isChecked: boolean) => void,
  13. onIncludeTrashPagesSwitched?: (isChecked: boolean) => void,
  14. }
  15. const SearchOptionModal: FC<Props> = (props: Props) => {
  16. const { t } = useTranslation('');
  17. const {
  18. isOpen, includeUserPages, includeTrashPages,
  19. onClose,
  20. onIncludeUserPagesSwitched,
  21. onIncludeTrashPagesSwitched,
  22. } = props;
  23. const onCloseModal = () => {
  24. if (onClose != null) {
  25. onClose();
  26. }
  27. };
  28. const includeUserPagesChangeHandler = (isChecked: boolean) => {
  29. if (onIncludeUserPagesSwitched != null) {
  30. onIncludeUserPagesSwitched(isChecked);
  31. }
  32. };
  33. const includeTrashPagesChangeHandler = (isChecked: boolean) => {
  34. if (onIncludeTrashPagesSwitched != null) {
  35. onIncludeTrashPagesSwitched(isChecked);
  36. }
  37. };
  38. return (
  39. <Modal size="lg" isOpen={isOpen} toggle={onCloseModal} autoFocus={false}>
  40. <ModalHeader tag="h4" toggle={onCloseModal}>
  41. Search Option
  42. </ModalHeader>
  43. <ModalBody>
  44. <div className="d-flex p-2">
  45. <div className="me-3">
  46. <label className="form-label px-3 py-2 mb-0 d-flex align-items-center">
  47. <input
  48. className="me-2"
  49. type="checkbox"
  50. onChange={e => includeUserPagesChangeHandler(e.target.checked)}
  51. checked={includeUserPages}
  52. />
  53. {t('Include Subordinated Target Page', { target: '/user' })}
  54. </label>
  55. </div>
  56. <div className="">
  57. <label className="form-label px-3 py-2 mb-0 d-flex align-items-center">
  58. <input
  59. className="me-2"
  60. type="checkbox"
  61. onChange={e => includeTrashPagesChangeHandler(e.target.checked)}
  62. checked={includeTrashPages}
  63. />
  64. {t('Include Subordinated Target Page', { target: '/trash' })}
  65. </label>
  66. </div>
  67. </div>
  68. </ModalBody>
  69. </Modal>
  70. );
  71. };
  72. export default SearchOptionModal;