<commit_before>import React, { Component } from 'react';
import { Router, Route, Link, IndexRoute, hashHistory, browserHistory } from 'react-router';
import SearchResultsList from './SearchResultsList'; 

//Bootstrap 
import { Image, Grid, Row, Col, Form, FormGroup, Badge, ProgressBar, Jumbotron, Carousel, FormControl, Button, Container, ControlLabel, DropdownButton, MenuItem, Nav, NavItem } from 'react-bootstrap';
const progressBarStyles = ['success', 'warning', 'danger']; 

// Axios 
var axios = require('axios'); 

/*
NOTE: SHOULD WE REMOVE USERS OWN RECIPES FROM SEARCH RESULTS??
*/

class SearchResultsMain extends Component {
  constructor(props) {
    super(props);

    this.state = {
      searchTerm: '',
      searchResultsArray: []
    };
  }

  componentWillMount() {
    console.log('searchResults main mounting!');
    this.getSearchResults();
  }

  getSearchResults() {
    var username = this.props.username;
    var searchTerm = this.props.params.search;
    //need to remove spaces from the seach string and replace
    //  the spaces with + sign
    var searchTermPlus = searchTerm.replace(/\s+/g, '+').toLowerCase();
    console.log('searchTermPlus: ', searchTermPlus);
    //make axios request to search endpoint with user entered search terms
    axios.get(`/search/${searchTermPlus}`)
    .then((result) => {
      var searchResultsArray = result.data;
      console.log('results: ', result);
      this.setState({
        searchResultsArray: searchResultsArray,
        searchTerm: searchTerm,
        username: username
      });
    })
    .catch((error) => {
      console.log('error getting search results: ', error);
    })
  }

  render() {
    return (
      <Grid className='SearchResultsMain'> 
        <Row> <commit_msg>have to press search twice rerender search page<commit_after>import React, { Component } from 'react';
import { Router, Route, Link, IndexRoute, hashHistory, browserHistory } from 'react-router';
import SearchResultsList from './SearchResultsList'; 

//Bootstrap 
import { Image, Grid, Row, Col, Form, FormGroup, Badge, ProgressBar, Jumbotron, Carousel, FormControl, Button, Container, ControlLabel, DropdownButton, MenuItem, Nav, NavItem } from 'react-bootstrap';

// Axios 
var axios = require('axios'); 

/*
NOTE: SHOULD WE REMOVE USERS OWN RECIPES FROM SEARCH RESULTS??
*/

class SearchResultsMain extends Component {
  constructor(props) {
    super(props);

    this.state = {
      searchTerm: '',
      searchResultsArray: []
    };
  }

  componentWillMount() {
    this.getSearchResults();
  }

  // componentWillUpdate() {
  //   if (this.state.searchTerm !== this.props.params.search){
  //     this.getSearchResults();
  //   }
  // }

  getSearchResults() {
    var username = this.props.username;
    var searchTerm = this.props.params.search;
    //need to remove spaces from the seach string and replace
    //  the spaces with + sign
    var searchTermPlus = searchTerm.replace(/\s+/g, '+').toLowerCase();
    console.log('searchTermPlus: ', searchTermPlus);
    //make axios request to search endpoint with user entered search terms
    axios.get(`/search/${searchTermPlus}`)
    .then((result) => {
      var searchResultsArray = result.data;
      console.log('results: ', result);
      this.setState({
        searchResultsArray: searchResultsArray,
        searchTerm: searchTerm,
        username: username
      });
    })
    .catch((error) => {
      console.log('error getting search results: ', error);
    })
  }

  render() {
    return (
      <Grid className='SearchResultsMain'> 
        <Row> 
{'fraction_non_alphanumeric': 0.12841225626740946, 'fraction_numerical': 0.0, 'mean_word_length': 3.2954545454545454, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '935256', 'n_tokens_mistral': 1050, 'n_tokens_neox': 1027, 'n_words': 276}