import PropTypes from 'prop-types'; import React from 'react'; import { injectIntl, FormattedMessage } from 'react-intl'; import { SimpleForm, FieldsGroup, Checkbox } from 'soapbox/features/forms'; import Button from '../../../components/button'; import Icon from '../../../components/icon'; export default @injectIntl class ConfirmationModal extends React.PureComponent { static propTypes = { heading: PropTypes.node, icon: PropTypes.node, message: PropTypes.node.isRequired, confirm: PropTypes.node.isRequired, onClose: PropTypes.func.isRequired, onConfirm: PropTypes.func.isRequired, secondary: PropTypes.string, onSecondary: PropTypes.func, intl: PropTypes.object.isRequired, onCancel: PropTypes.func, checkbox: PropTypes.node, }; state = { checked: false, } componentDidMount() { this.button.focus(); } handleClick = () => { this.props.onClose('CONFIRM'); this.props.onConfirm(); } handleSecondary = () => { this.props.onClose('CONFIRM'); this.props.onSecondary(); } handleCancel = () => { const { onClose, onCancel } = this.props; onClose('CONFIRM'); if (onCancel) onCancel(); } handleCheckboxChange = e => { this.setState({ checked: e.target.checked }); } setRef = (c) => { this.button = c; } render() { const { heading, icon, message, confirm, secondary, checkbox } = this.props; const { checked } = this.state; return (
{heading && (
{icon && } {heading}
)}
{message}
{checkbox &&
}
{secondary !== undefined && (
); } }