DeleteSelectedPageGroup.tsx 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import React, { FC } from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import loggerFactory from '~/utils/logger';
  4. import { CheckboxType } from '../../interfaces/search';
  5. const logger = loggerFactory('growi:searchResultList');
  6. type Props = {
  7. checkboxState: CheckboxType,
  8. onClickInvoked?: () => void,
  9. onCheckInvoked?: (string:CheckboxType) => void,
  10. }
  11. const DeleteSelectedPageGroup:FC<Props> = (props:Props) => {
  12. const { t } = useTranslation();
  13. const {
  14. checkboxState, onClickInvoked, onCheckInvoked,
  15. } = props;
  16. const changeCheckboxStateHandler = () => {
  17. console.log(`changeCheckboxStateHandler is called. current changebox state is ${checkboxState}`);
  18. // Todo: determine next checkboxState from one of the following and tell the parent component
  19. // to change the checkboxState by passing onCheckInvoked function the next checkboxState
  20. // - NONE_CHECKED
  21. // - INDETERMINATE
  22. // - ALL_CHECKED
  23. // https://estoc.weseek.co.jp/redmine/issues/77525
  24. // use CheckboxType by importing from packages/app/src/interfaces/
  25. if (onCheckInvoked == null) { logger.error('onCheckInvoked is null') }
  26. else { onCheckInvoked(CheckboxType.ALL_CHECKED) } // change this to an appropriate value
  27. };
  28. return (
  29. <>
  30. <input
  31. id="check-all-pages"
  32. type="checkbox"
  33. name="check-all-pages"
  34. className="custom-control custom-checkbox ml-1 align-self-center"
  35. onChange={changeCheckboxStateHandler}
  36. checked={checkboxState === CheckboxType.INDETERMINATE || checkboxState === CheckboxType.ALL_CHECKED}
  37. />
  38. <button
  39. type="button"
  40. className="btn text-danger font-weight-light p-0 ml-3"
  41. onClick={() => {
  42. if (onClickInvoked == null) { logger.error('onClickInvoked is null') }
  43. else { onClickInvoked() }
  44. }}
  45. >
  46. <i className="icon-trash"></i>
  47. {t('search_result.delete_all_selected_page')}
  48. </button>
  49. </>
  50. );
  51. };
  52. DeleteSelectedPageGroup.propTypes = {
  53. };
  54. export default DeleteSelectedPageGroup;