1 import React, {Component} from "react";
2 import SearchTermsInput from "./SearchTermsInput";
3 import {Map} from "immutable";
5 class SentimentAnalysis extends Component {
6 constructor(props, context) {
12 this.handleSubmit = this.handleSubmit.bind(this);
13 this.handleTermChange = this.handleTermChange.bind(this);
14 this.handleAddTerm = this.handleAddTerm.bind(this);
15 this.handleRemoveTerm = this.handleRemoveTerm.bind(this);
16 this.addEmptyTerm = this.addEmptyTerm.bind(this);
20 const terms = this.state.terms;
21 if (terms.length === 0) {
27 event.preventDefault();
28 const target = event.target;
30 const terms = this.state.terms;
31 terms.forEach((term) => {
36 handleTermChange(id, value) {
37 const terms = this.state.terms;
39 terms: terms.set(id, value),
43 handleAddTerm(event) {
47 handleRemoveTerm(id) {
48 const terms = this.state.terms;
50 terms: terms.delete(id),
55 const terms = this.state.terms;
56 const termId = this.state.nextTermId;
58 terms: terms.set(termId, ''),
59 nextTermId: termId + 1,
65 <div className="sentiment-analysis">
66 <form onSubmit={this.handleSubmit}>
67 <label>Search Terms</label>
68 <SearchTermsInput terms={this.state.terms}
69 onTermChange={this.handleTermChange}
70 onAddTerm={this.handleAddTerm}
71 onRemoveTerm={this.handleRemoveTerm}/>
72 <input type="submit" value="Submit"/>
79 SentimentAnalysis.propTypes = {};
81 export default SentimentAnalysis;