The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

55 lines
1.3 KiB

  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { injectIntl, FormattedMessage } from 'react-intl';
  4. import Button from '../../../components/button';
  5. class ConfirmationModal extends React.PureComponent {
  6. static propTypes = {
  7. message: PropTypes.node.isRequired,
  8. confirm: PropTypes.string.isRequired,
  9. onClose: PropTypes.func.isRequired,
  10. onConfirm: PropTypes.func.isRequired,
  11. intl: PropTypes.object.isRequired,
  12. };
  13. componentDidMount() {
  14. this.button.focus();
  15. }
  16. handleClick = () => {
  17. this.props.onClose();
  18. this.props.onConfirm();
  19. }
  20. handleCancel = () => {
  21. this.props.onClose();
  22. }
  23. setRef = (c) => {
  24. this.button = c;
  25. }
  26. render () {
  27. const { message, confirm } = this.props;
  28. return (
  29. <div className='modal-root__modal confirmation-modal'>
  30. <div className='confirmation-modal__container'>
  31. {message}
  32. </div>
  33. <div className='confirmation-modal__action-bar'>
  34. <Button onClick={this.handleCancel} className='confirmation-modal__cancel-button'>
  35. <FormattedMessage id='confirmation_modal.cancel' defaultMessage='Cancel' />
  36. </Button>
  37. <Button text={confirm} onClick={this.handleClick} ref={this.setRef} />
  38. </div>
  39. </div>
  40. );
  41. }
  42. }
  43. export default injectIntl(ConfirmationModal);