<commit_before>import React, { Component } from 'react';
import { merge, isEqual } from 'lodash';

class Search extends Component {
  constructor(props) {
    super(props);
    this.state = {
      category: {}
    };
    this.handleSubmit = this.handleSubmit.bind(this);
    this.updateCheckbox = this.updateCheckbox.bind(this);
    this.props.cleanSearchParams();
  }

  handleSubmit(e) {
    e.preventDefault();
    this.props.receiveSearchParam(this.state);
  }

  updateCheckbox(e) {
    const newState = {
      category: merge(
        {},
        this.state.category,
        { [e.target.value]: e.target.checked }
      )
    };

    this.setState(newState);

    // For dynamic searching
    // this.setState(newState, () => {
    //   this.props.receiveSearchParam(this.state);
    // });
  }

  render() {
    return (
      <div className="search-params">
        <form onSubmit={this.handleSubmit}>
          <label>
            <input
              onChange={this.updateCheckbox}
              type="checkbox" 
              className="category-check" 
              value="clothing" />
            Clothing
          </label>
          <label>
            <input
              onChange={this.updateCheckbox}
              type="checkbox" 
              className="category-check" 
              value="jewelry" />
            Jewelry
          </label>
          <label>
            <input
              onChange={this.updateCheckbox}
              type="checkbox" 
              className="category-check" 
              value="kids" />
            Kids
          </label>
          <label>
            <input
              onChange={this.updateCheckbox}
              type="checkbox" 
              className="category-check" 
              value="entertainment" />
            Entertainment
          </label>
          <label>
            <input
              onChange={this.updateCheckbox}
              type="checkbox" 
              className="category-check" 
              value="home_and_living" />
            Home and Living
          </label>
          <label>
            <input
              onChange={this.updateCheckbox}
              type="checkbox" 
              className="category-check" 
              value="electronics" />
            Electronics
          </label>
          <input type="submit" className="primary-button form-button u-full-width" />
        </form>
      </div>
    );
  }
}

export default Search;<commit_msg>Change to dynamic searching for categories<commit_after>import React, { Component } from 'react';
import { merge, isEqual } from 'lodash';

class Search extends Component {
  constructor(props) {
    super(props);
    this.state = {
      category: {}
    };
    this.handleSubmit = this.handleSubmit.bind(this);
    this.updateCheckbox = this.updateCheckbox.bind(this);
    this.props.cleanSearchParams();
  }

  handleSubmit(e) {
    e.preventDefault();
    this.props.receiveSearchParam(this.state);
  }

  updateCheckbox(e) {
    const newState = {
      category: merge(
        {},
        this.state.category,
        { [e.target.value]: e.target.checked }
      )
    };

    // this.setState(newState);

    // For dynamic searching
    this.setState(newState, () => {
      this.props.receiveSearchParam(this.state);
    });
  }

  render() {
    return (
      <div className="search-params">
        <form onSubmit={this.handleSubmit}>
          <label>
            <input
              onChange={this.updateCheckbox}
              type="checkbox" 
              className="category-check" 
              value="clothing" />
            Clothing
          </label>
          <label>
            <input
              onChange={this.updateCheckbox}
              type="checkbox" 
              className="category-check" 
              value="jewelry" />
            Jewelry
          </label>
          <label>
            <input
              onChange={this.updateCheckbox}
              type="checkbox" 
              className="category-check" 
              value="kids" />
            Kids
          </label>
          <label>
            <input
              onChange={this.updateCheckbox}
              type="checkbox" 
              className="category-check" 
              value="entertainment" />
            Entertainment
          </label>
          <label>
            <input
              onChange={this.updateCheckbox}
              type="checkbox" 
              className="category-check" 
              value="home_and_living" />
            Home and Living
          </label>
          <label>
            <input
              onChange={this.updateCheckbox}
              type="checkbox" 
              className="category-check" 
              value="electronics" />
            Electronics
          </label>
          {/*<input type="submit" className="primary-button form-button u-full-width" />*/}
        </form>
      </div>
    );
  }
}

export default Search;
{'fraction_non_alphanumeric': 0.11752867780237472, 'fraction_numerical': 0.0, 'mean_word_length': 1.485, 'pattern_counts': {'":': 0, '<': 49, '<?xml version=': 0, '>': 51, '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': '2540527', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1295, 'n_words': 216}