<commit_before>import React from 'react';
import { Panel, Col, Glyphicon } from 'react-bootstrap';
import PropTypes from 'prop-types';

import './ProductSearch.scss';

class ProductSearch extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      searchString: '',
    };
    this.onsearchStringChange = this.onsearchStringChange.bind(this);
    this.clear = this.clear.bind(this);
    this.onFocus = this.onFocus.bind(this);
  }

  onsearchStringChange() {
    const searchValue = this.searchBox.value;

    this.setState({
      searchString: searchValue,
    });
  }

  onFocus() {
    this.props.onFocus();
  }

  informProductUnavailability() {
    return (<Col xs={12}>
      <p>
        OOps! We are not able to find what you are looking for. You could try a different spelling or browse for it in the lists below.
    </p> </Col>);
  }

  clear() {
    this.setState({
      searchString: '',
    });
  }

  render() {
    const { searchString } = this.state;
    const searchResults = (searchString !== '' && searchString.length > 3) ?
        (this.props.getProductsMatchingSearch(searchString, 8)) : '';

    return (
      <div className="productOrderSearch">
        <Panel
          header={
            (
              <div className="input-group productSearchInp">
                <input
                  className="form-control"
                  type="text"
                  placeholder="Search & Order"
                  value={this.state.searchString}
                  onChange={this.onsearchStringChange}
                  ref={searchBox => (this.searchBox = searchBox)}
                  onFocus={this.onFocus}
                />
                <span className="input-group-addon">
                  <Glyphicon glyph="remove" onClick={this.clear} />
                </span>
              </div>
            )}
        >
          { searchString !== '' && searchResults }
          { searchResults && searchResults.length === 0 && this.informProductUnavailability()}
        </Panel>
      </div>
    );
  }
}

ProductSearch.propTypes = {
  getProductsMatchingSearch: PropTypes.func.isRequired,
  onFocus: PropTypes.func.isRequired,
};

export default ProductSearch;
<commit_msg>Added product search, after entering 2 letters.<commit_after>import React from 'react';
import { Panel, Col, Glyphicon } from 'react-bootstrap';
import PropTypes from 'prop-types';

import './ProductSearch.scss';

class ProductSearch extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      searchString: '',
    };
    this.onsearchStringChange = this.onsearchStringChange.bind(this);
    this.clear = this.clear.bind(this);
    this.onFocus = this.onFocus.bind(this);
  }

  onsearchStringChange() {
    const searchValue = this.searchBox.value;

    this.setState({
      searchString: searchValue,
    });
  }

  onFocus() {
    this.props.onFocus();
  }

  informProductUnavailability() {
    return (<Col xs={12}>
      <p>
        OOps! We are not able to find what you are looking for. You could try a different spelling or browse for it in the lists below.
    </p> </Col>);
  }

  clear() {
    this.setState({
      searchString: '',
    });
  }

  render() {
    const { searchString } = this.state;
    const searchResults = (searchString !== '' && searchString.length > 2) ?
        (this.props.getProductsMatchingSearch(searchString, 8)) : '';

    return (
      <div className="productOrderSearch">
        <Panel
          header={
            (
              <div className="input-group productSearchInp">
                <input
                  className="form-control"
                  type="text"
                  placeholder="Search & Order"
                  value={this.state.searchString}
                  onChange={this.onsearchStringChange}
                  ref={searchBox => (this.searchBox = searchBox)}
                  onFocus={this.onFocus}
                />
                <span className="input-group-addon">
                  <Glyphicon glyph="remove" onClick={this.clear} />
                </span>
              </div>
            )}
        >
          { searchString !== '' && searchResults }
          { searchResults && searchResults.length === 0 && this.informProductUnavailability()}
        </Panel>
      </div>
    );
  }
}

ProductSearch.propTypes = {
  getProductsMatchingSearch: PropTypes.func.isRequired,
  onFocus: PropTypes.func.isRequired,
};

export default ProductSearch;

{'fraction_non_alphanumeric': 0.1251109139307897, 'fraction_numerical': 0.0024401064773735583, 'mean_word_length': 2.1225761772853184, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7057332', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1229, 'n_words': 262}