<commit_before>import React from 'react';
import { Button } from 'react-bootstrap';

//Components
import Map from './Map';

class Restaurant extends React.Component {
  constructor(){
    super();
    this.getTopRestaurant = this.getTopRestaurant.bind(this);
    this.handleClick = this.handleClick.bind(this);
    this.displayTopRestaurant = this.displayTopRestaurant.bind(this);
  }

  componentWillMount(){
    const { fetchSnapPeaData } = this.props.dinerActions;
    const { diners } = this.props;

    fetchSnapPeaData(diners);
  }

  getTopRestaurant(){
    const { updateTopRestaurant } = this.props.dinerActions;

    updateTopRestaurant();
  }

  handleClick(e){
    e.preventDefault();
    const { updateTopRestaurant } = this.props.dinerActions;

    updateTopRestaurant();
  }

  displayTopRestaurant(){
    if (this.props.topRestaurant.name) {
      return (
        <div>
          <h2>This is the best restaurant for you!</h2>
          <h3>{this.props.topRestaurant.name}</h3>
          <p>{this.props.topRestaurant.location.display_address[0]}</p>
          <p>{this.props.topRestaurant.location.display_address[1]}</p>
          <p>{this.props.topRestaurant.location.display_address[2]}</p>
          <p>{this.props.topRestaurant.display_phone}</p>
          <div style={{width:300, height:300}}>
            <Map lat={this.props.topRestaurant.location.coordinate.latitude} lng={this.props.topRestaurant.location.coordinate.longitude}/>
          </div>
          <Button>Peas get directions!</Button>
          <Button onClick={this.handleClick}>Next restaurant</Button>
        </div>
      )
    } else {
      return null;
    }
  }

  render(){
    let isFetching = this.props.isLoadingResults ? (
      <div>
        <h1>Our algorithm is crunching numbers. Your recommendation will be ready in snap!</h1>
        <image src='./../static/assets/spinner.gif' />
      </div>
    ) : null;

  	return (
  	 	<div>
        <h1>Results</h1>
        {isFetching}
        {this.displayTopRestaurant()}
  	 	</div>
 	  )
  }
}
<commit_msg>[refactor] moves loading spinner logic to function in Restaurant component<commit_after>import React from 'react';
import { Button } from 'react-bootstrap';

//Components
import Map from './Map';

class Restaurant extends React.Component {
  constructor(){
    super();
    this.getTopRestaurant = this.getTopRestaurant.bind(this);
    this.handleClick = this.handleClick.bind(this);
    this.displayLoadingSpinner = this.displayLoadingSpinner.bind(this);
    this.displayTopRestaurant = this.displayTopRestaurant.bind(this);
  }

  componentWillMount(){
    const { fetchSnapPeaData } = this.props.dinerActions;
    const { diners } = this.props;

    fetchSnapPeaData(diners);
  }

  getTopRestaurant(){
    const { updateTopRestaurant } = this.props.dinerActions;

    updateTopRestaurant();
  }

  handleClick(e){
    e.preventDefault();
    const { updateTopRestaurant } = this.props.dinerActions;

    updateTopRestaurant();
  }

  displayLoadingSpinner(){
    if(this.props.isLoadingResults){
      return (
        <div>
          <h1>Our algorithm is crunching numbers. Your recommendation will be ready in snap!</h1>
          <image src='./../static/assets/spinner.gif' />
        </div>
      )
    } else {
      return null;
    }
  }

  displayTopRestaurant(){
    if (this.props.topRestaurant.name) {
      return (
        <div>
          <h2>This is the best restaurant for you!</h2>
          <h3>{this.props.topRestaurant.name}</h3>
          <p>{this.props.topRestaurant.location.display_address[0]}</p>
          <p>{this.props.topRestaurant.location.display_address[1]}</p>
          <p>{this.props.topRestaurant.location.display_address[2]}</p>
          <p>{this.props.topRestaurant.display_phone}</p>
          <div style={{width:300, height:300}}>
            <Map lat={this.props.topRestaurant.location.coordinate.latitude} lng={this.props.topRestaurant.location.coordinate.longitude}/>
          </div>
          <Button>Peas get directions!</Button>
          <Button onClick={this.handleClick}>Next restaurant</Button>
        </div>
      )
    } else {
      return null;
    }
  }

  render(){
  	return (
  	 	<div>
        <h1>Results</h1>
        {this.displayLoadingSpinner()}
        {this.displayTopRestaurant()}
  	 	</div>
 	  )
  }
}

{'fraction_non_alphanumeric': 0.13731825525040386, 'fraction_numerical': 0.007846757442880221, 'mean_word_length': 2.775261324041812, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 63, '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': '6864030', 'n_tokens_mistral': 1436, 'n_tokens_neox': 1366, 'n_words': 223}