-
-
- {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 (
+
+
+
-
- {props.children}
-
-
-
-
-);
+
+
+
+
+ )
+ }}
+ />
+
+
+
+
+