<commit_before>import * as React from 'react';
import { Link } from 'react-router';
import { connect } from 'react-redux';
import { IApplicationState }  from '../store';
import * as TeabagReducer from '../reducers/teabag';

import {ComboBox} from '../components/ComboBox/ComboBox';
import {Loader} from '../components/Loader';

import {IBrand} from '../interfaces/IBrand';
import {ICountry} from '../interfaces/ICountry';
import {IBagType} from '../interfaces/IBagType';

const BrandComboBox = ComboBox<IBrand>(); // tslint:disable-line:variable-name
const CountryComboBox = ComboBox<ICountry>(); // tslint:disable-line:variable-name
const TypeComboBox = ComboBox<IBagType>(); // tslint:disable-line:variable-name

type TeabagsProps =
    TeabagReducer.ITeabagState     // ... state we've requested from the Redux store
    & typeof TeabagReducer.actionCreators   // ... plus action creators we've requested
    & { params?: { id?: string } };       // ... plus incoming routing parameters

class TeabagForm extends React.Component<TeabagsProps, void> {

  constructor() {
    super();

    this.onAddNewBagType = this.onAddNewBagType.bind(this);
    this.onAddNewBrand = this.onAddNewBrand.bind(this);
    this.onAddNewCountry = this.onAddNewCountry.bind(this);
    this.onBagTypeSelected = this.onBagTypeSelected.bind(this);
    this.onBrandSelected = this.onBrandSelected.bind(this);
    this.onClearBagType = this.onClearBagType.bind(this);
    this.onClearBrand = this.onClearBrand.bind(this);
    this.onClearCountry = this.onClearCountry.bind(this);
    this.onCountrySelected = this.onCountrySelected.bind(this);
    this.onSearchBrand = this.onSearchBrand.bind(this);
    this.onSearchCountry = this.onSearchCountry.bind(this);
    this.onSearchType = this.onSearchType.bind(this);
  }

  componentWillMount() {
    if (this.props.params && this.props.params.id && this.props.params.id.length > 0) {
      this.props.requestTeabag(this.props.params.id);
    }
  }

  componentWillReceiveProps(nextProps: TeabagsProps) {
    (nextProps);
    if (this.props.isLoading === false && this.props.params && this.props.params.id && this.props.params.id.length > 0 && this.props.teabag.id !== this.props.params.id) {
      this.props.requestTeabag(this.props.params.id);
    }
  }

  onAddNewBrand() {}

  onBrandSelected(brand: IBrand) {
    this.props.changeBrand(brand);
  }

  onClearBrand() {
    this.props.clearBrand();
  }

  onSearchBrand(searchTerm: string) {
    let uri = `/api/Brands/?searchterm=${encodeURIComponent(searchTerm)}`;
    return fetch(uri)
            .then(response => response.json() as Promise<IBrand[]>);<commit_msg>remove bad code<commit_after>import * as React from 'react';
import { Link } from 'react-router';
import { connect } from 'react-redux';
import { IApplicationState }  from '../store';
import * as TeabagReducer from '../reducers/teabag';

import {ComboBox} from '../components/ComboBox/ComboBox';
import {Loader} from '../components/Loader';

import {IBrand} from '../interfaces/IBrand';
import {ICountry} from '../interfaces/ICountry';
import {IBagType} from '../interfaces/IBagType';

const BrandComboBox = ComboBox<IBrand>(); // tslint:disable-line:variable-name
const CountryComboBox = ComboBox<ICountry>(); // tslint:disable-line:variable-name
const TypeComboBox = ComboBox<IBagType>(); // tslint:disable-line:variable-name

type TeabagsProps =
    TeabagReducer.ITeabagState     // ... state we've requested from the Redux store
    & typeof TeabagReducer.actionCreators   // ... plus action creators we've requested
    & { params?: { id?: string } };       // ... plus incoming routing parameters

class TeabagForm extends React.Component<TeabagsProps, void> {

  constructor() {
    super();

    this.onAddNewBagType = this.onAddNewBagType.bind(this);
    this.onAddNewBrand = this.onAddNewBrand.bind(this);
    this.onAddNewCountry = this.onAddNewCountry.bind(this);
    this.onBagTypeSelected = this.onBagTypeSelected.bind(this);
    this.onBrandSelected = this.onBrandSelected.bind(this);
    this.onClearBagType = this.onClearBagType.bind(this);
    this.onClearBrand = this.onClearBrand.bind(this);
    this.onClearCountry = this.onClearCountry.bind(this);
    this.onCountrySelected = this.onCountrySelected.bind(this);
    this.onSearchBrand = this.onSearchBrand.bind(this);
    this.onSearchCountry = this.onSearchCountry.bind(this);
    this.onSearchType = this.onSearchType.bind(this);
  }

  componentWillMount() {
    if (this.props.params && this.props.params.id && this.props.params.id.length > 0) {
      this.props.requestTeabag(this.props.params.id);
    }
  }

  componentWillReceiveProps(nextProps: TeabagsProps) {
    if (this.props.isLoading === false && this.props.params && this.props.params.id && this.props.params.id.length > 0 && this.props.teabag.id !== this.props.params.id) {
      this.props.requestTeabag(this.props.params.id);
    }
  }

  onAddNewBrand() {}

  onBrandSelected(brand: IBrand) {
    this.props.changeBrand(brand);
  }

  onClearBrand() {
    this.props.clearBrand();
  }

  onSearchBrand(searchTerm: string) {
    let uri = `/api/Brands/?searchterm=${encodeURIComponent(searchTerm)}`;
    return fetch(uri)
            .then(response => response.json() as Promise<IBrand[]>);
{'fraction_non_alphanumeric': 0.14415609016859254, 'fraction_numerical': 0.0007577192650123129, 'mean_word_length': 4.009487666034156, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, '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': '2360391', 'n_tokens_mistral': 1739, 'n_tokens_neox': 1672, 'n_words': 292}