import React from 'react'; import cn from 'classnames'; import PropTypes from 'prop-types'; import { Dialog } from 'coral-ui'; import styles from './BanUserDialog.css'; import Button from 'coral-ui/components/Button'; import t from 'coral-framework/services/i18n'; const initialState = { step: 0, message: '' }; class BanUserDialog extends React.Component { state = initialState; componentWillReceiveProps(next) { if (this.props.open && !next.open) { this.setState(initialState); } } handleMessageChange = e => { const { target: { value: message } } = e; this.setState({ message }); }; goToStep1 = () => { this.setState({ step: 1, message: t('bandialog.email_message_ban', this.props.username), }); }; handlePerform = () => { this.props.onPerform({ message: this.state.message, }); }; renderStep0() { const { onCancel, username, info } = this.props; return ( {t('bandialog.ban_user')} {t('bandialog.are_you_sure', username)} {info} {t('bandialog.cancel')} {t('bandialog.yes_ban_user')} ); } renderStep1() { const { onCancel } = this.props; const { message } = this.state; return ( {t('bandialog.notify_ban_headline')} {t('bandialog.notify_ban_description')} {t('bandialog.write_a_message')} {t('bandialog.cancel')} {t('bandialog.send')} ); } render() { const { step } = this.state; const { open, onCancel } = this.props; return ( × {step === 0 && this.renderStep0()} {step === 1 && this.renderStep1()} ); } } BanUserDialog.propTypes = { open: PropTypes.bool, onPerform: PropTypes.func.isRequired, onCancel: PropTypes.func.isRequired, username: PropTypes.string, info: PropTypes.string, }; export default BanUserDialog;
{info}
{t('bandialog.notify_ban_description')}