require('../stylesheets/content.scss');
import React, { Component } from 'react';
import FontAwesome from 'react-fontawesome';
import { tabStore } from './tabStore';
import { Item } from './Item';

export class TabContent extends Component {
  constructor(props) {
    super(props);
    var path = this.props.location.pathname && this.props.location.pathname.substr(1) || 'All';
    tabStore.dispatch({type: path});
    this.state = {
      list: tabStore.getState(),
      todo: ''
    };
  }

  handleChange(e) {
    this.setState({todo: e.target.value});
  }

  addList() {
    if (this.state.todo) this.state.list.push(this.state.todo);
    this.setState({todo: ''});
  }

  render() {
    return (
      <div>
        <div className="newTodo">
          <input type="text" value={this.state.todo} onChange={this.handleChange.bind(this)} placeholder="Type something..." />
          <FontAwesome name="plus" className="todo-plus" size="2x" onClick={this.addList.bind(this)} />
        </div>
        <div>
          {this.state.list.map(function(item, i) {
            return <Item key={i} data={item}/>;
          })}
        </div>
      </div>
    )
  }
}
@@ -276,16 +276,95 @@
 props);%0A
+    // var path = (this.props.path? this.props.path: 'All').replace(/%5C//, '');%0A
     var 
@@ -435,16 +435,24 @@
 ame.
-substr(1
+replace(/%5C//, ''
 ) %7C%7C
@@ -487,16 +487,29 @@
 h(%7Btype:
+ 'Get', path:
  path%7D);
@@ -561,16 +561,34 @@
 tate(),%0A
+      path: path,%0A
       to
@@ -717,47 +717,184 @@
 do) 
-this.state.list.push(this.state.todo
+%7B%0A      tabStore.dispatch(%7B%0A        type: 'Add',%0A        item: %7B%0A          todo: this.state.todo,%0A          complete: false,%0A          starred: false%0A        %7D%0A      %7D
 );%0A
+    %7D%0A
     
@@ -908,24 +908,64 @@
 tState(%7B
+%0A      list: tabStore.getState(),%0A      
 todo: ''
 %7D);%0A  %7D%0A
@@ -956,16 +956,21 @@
 todo: ''
+%0A    
 %7D);%0A  %7D%0A
@@ -1350,24 +1350,24 @@
 (item, i) %7B%0A
-
             
@@ -1398,16 +1398,17 @@
 a=%7Bitem%7D
+ 
 /%3E;%0A    

use 'Get' to dispatch store