diff --git a/src/components/modal/mute/modal.jsx b/src/components/modal/mute/modal.jsx index 44936168b..f9ea0918d 100644 --- a/src/components/modal/mute/modal.jsx +++ b/src/components/modal/mute/modal.jsx @@ -32,18 +32,15 @@ class MuteModal extends React.Component { 'handleNext', 'handlePrevious', 'handleGoToFeedback', - 'handleFeedbackInput', - 'handleFeedbackSubmit', 'handleSetFeedbackRef', + 'handleValidSubmit', 'validateFeedback' ]); - this.numSteps = 2; - if (this.props.showWarning) { - this.numSteps++; - } + + this.numSteps = this.props.showWarning ? steps.BAN_WARNING : steps.MUTE_INFO; + this.state = { - step: 0, - feedback: '' + step: 0 }; } handleNext () { @@ -64,22 +61,16 @@ class MuteModal extends React.Component { }); } - handleFeedbackSubmit () { - const noError = !this.validateFeedback(this.state.feedback); + // called after feedback validation passes with no errors + handleValidSubmit (formData, formikBag) { + formikBag.setSubmitting(false); // formik makes us do this ourselves - if (noError) { - /* eslint-disable no-console */ - console.log(this.state.feedback); - /* eslint-enable no-console */ - this.setState({ - step: steps.FEEDBACK_SENT - }); - } - } + /* eslint-disable no-console */ + console.log(formData.feedback); + /* eslint-enable no-console */ - handleFeedbackInput (feedback) { this.setState({ - feedback: feedback + step: steps.FEEDBACK_SENT }); } @@ -89,14 +80,24 @@ class MuteModal extends React.Component { validateFeedback (feedback) { if (feedback.length === 0) { - return 'Can\'t be empty'; + return this.props.intl.formatMessage({id: 'comments.muted.feedbackEmpty'}); } - return null; } render () { - const finalStep = this.showWarning ? steps.BAN_WARNING : steps.MUTE_INFO; + const feedbackPrompt = ( +
+ + + + )}} + /> +
- - - - )}} - /> -