diff --git a/src/components/modal/report/modal.jsx b/src/components/modal/report/modal.jsx index 840b123e8..7c69183e8 100644 --- a/src/components/modal/report/modal.jsx +++ b/src/components/modal/report/modal.jsx @@ -1,34 +1,186 @@ +const bindAll = require('lodash.bindall'); const PropTypes = require('prop-types'); const React = require('react'); +const FormattedMessage = require('react-intl').FormattedMessage; +const injectIntl = require('react-intl').injectIntl; +const intlShape = require('react-intl').intlShape; const Modal = require('../base/modal.jsx'); +const log = require('../../../lib/log.js'); + +const Form = require('../../forms/form.jsx'); +const Button = require('../../forms/button.jsx'); +const Select = require('../../forms/select.jsx'); +const Spinner = require('../../spinner/spinner.jsx'); +const TextArea = require('../../forms/textarea.jsx'); require('../../forms/button.scss'); require('./modal.scss'); -const ReportModal = props => ( - -
-
-
- {props.contentLabel} -
-
+class ReportModal extends React.Component { + constructor (props) { + super(props); + bindAll(this, [ + 'handleReasonSelect', + 'handleSubmit' + ]); + this.state = { + prompt: props.intl.formatMessage({id: 'report.promptPlaceholder'}), + reason: '', + waiting: false + }; + } + handleReasonSelect (name, value) { + const prompts = [ + this.props.intl.formatMessage({id: 'report.promptCopy'}), + this.props.intl.formatMessage({id: 'report.promptUncredited'}), + this.props.intl.formatMessage({id: 'report.promptScary'}), + this.props.intl.formatMessage({id: 'report.promptLanguage'}), + this.props.intl.formatMessage({id: 'report.promptMusic'}), + this.props.intl.formatMessage({id: 'report.promptPersonal'}), + this.props.intl.formatMessage({id: 'report.promptGuidelines'}), + 'not used', + this.props.intl.formatMessage({id: 'report.promptImage'}) + ]; + this.setState({prompt: prompts[value], reason: value}); + } + handleSubmit (formData) { + this.setState({waiting: true}); + this.props.onReport(formData, err => { + if (err) log.error(err); + this.setState({ + prompt: this.props.intl.formatMessage({id: 'report.promptPlaceholder'}), + reason: '', + waiting: false + }); + }); + } + render () { + const { + intl, + onReport, // eslint-disable-line no-unused-vars + type, + ...modalProps + } = this.props; + const contentLabel = intl.formatMessage({id: `report.${type}`}); + return ( + +
+
+
+ {contentLabel} +
+
-
- {props.children} -
-
- -
-); +
+ + + + ) + }} + /> +
+