<commit_before>import React, { Component, PropTypes } from 'react'
import { connect } from 'react-redux'
import { Link } from 'react-router'
import * as applicationActions from '../../actions/application'

class ProductOverview extends Component {

  static propTypes = {
    products: PropTypes.array.isRequired,
    loadProducts: PropTypes.func.isRequired,
    performSearch: PropTypes.func.isRequired,
  };

  constructor(props) {
    super(props);
    this.state = {
      term: ''
    };

    this.handleChange = this.handleChange.bind(this);
    this.handleSubmit = this.handleSubmit.bind(this);
  }

  componentWillMount () {
    this.props.loadProducts()
    console.log("CWM" )
  }

  handleChange (event) {
    this.setState({term: event.target.value});
  }

  handleSubmit(event) {
    console.log('search with ', this.state.term)
    event.preventDefault();
    this.props.performSearch(this.state.term)
  }

  render () {
    const { products } = this.props
    console.log("Products", products)
    const productList = products.map(_ => <div className="product col-md-9 col-md-offset-3" key={_.id}>
      <div className="row">
        <div className="preview col-md-4">
          <img src="http://www.cicis.com/media/1138/pizza_trad_pepperoni.png"/>
        </div>
        <div className="info col-md-8">
          <h2><Link to={`/product/${_.key}`}>{_.title}</Link></h2>
          <p dangerouslySetInnerHTML={{__html:_.shortDesc}}></p>
        </div>
      </div>
    </div>)

    return (
    <div id="product-overview">
      <div className="search row">
        <form onSubmit={this.handleSubmit}>
          <div className="col-md-offset-3 col-md-9 input-group">
            <input type="text" name="term" className="form-control" value={this.state.value}
                   onChange={this.handleChange} placeholder="Search for..."/>
            <span className="input-group-btn">
              <button className="btn btn-default" type="submit">Go!</button>
            </span>
          </div>
        </form>
      </div>
      <div className="content row">
        {productList}
      </div>
    </div>
    )
  }

}

export default connect(<commit_msg>type ahead search<commit_after>import React, { Component, PropTypes } from 'react'
import { connect } from 'react-redux'
import { Link } from 'react-router'
import * as applicationActions from '../../actions/application'

class ProductOverview extends Component {

  static propTypes = {
    products: PropTypes.array.isRequired,
    loadProducts: PropTypes.func.isRequired,
    performSearch: PropTypes.func.isRequired,
  };


  componentWillMount () {
    this.props.loadProducts()
    console.log("CWM" )
  }

  handleChange (event) {
    const term = event.target.value
    if (term.length){
      this.props.performSearch(term)
    } else {
      this.props.loadProducts()
    }
  }

  render () {
    const { products } = this.props
    const productList = products.map(_ => <div className="product col-md-9 col-md-offset-3" key={_.id}>
      <div className="row">
        <div className="preview col-md-4">
          <img src="http://www.cicis.com/media/1138/pizza_trad_pepperoni.png"/>
        </div>
        <div className="info col-md-8">
          <h2><Link to={`/product/${_.key}`}>{_.title}</Link></h2>
          <p dangerouslySetInnerHTML={{__html:_.shortDesc}}></p>
        </div>
      </div>
    </div>)

    return (
    <div id="product-overview">
      <div className="search row">
        <div className="col-md-offset-3 col-md-9 input-group">
          <input type="text" name="term" className="form-control" value={this.state.value}
                 onChange={::this.handleChange} placeholder="Search for..."/>
        </div>
      </div>
      <div className="content row">
        {productList}
      </div>
    </div>
    )
  }

}

export default connect(
{'fraction_non_alphanumeric': 0.15827711468604047, 'fraction_numerical': 0.006227296315516347, 'mean_word_length': 2.6333647502356268, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 59, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2751375', 'n_tokens_mistral': 1201, 'n_tokens_neox': 1188, 'n_words': 227}