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

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

// Server Requests
var axios = require('axios');

// Placeholder recipe data 
import placeholders from '../../../../placeholders'


class UserProfile extends React.Component {
  constructor(props) {
    super(props); 
    this.state = {
      username: '',
      userID: null,
      otherUser: false,   
      firstname: '',
      lastname: '',
      email: '',
      image: 'http://www.trbimg.com/img-53c59dde/turbine/la-dd-jacques-pepin-gordon-ramsay-20140715',
      userProfile: null, 
      recipeList: [],
      bio: 'Click here to write a short bio',
      activeKey: 2,
      followingList: placeholders.followingList
    }; 
  }

  componentWillMount() {
    console.log('PARAMS USER PAGE: ', this.props.params); 
    var username = this.props.params.username; 
    var userImage = placeholders.images[username] || 'https://cdn4.iconfinder.com/data/icons/kitchenware-2/100/04-512.png';  

    axios.get(`/${this.props.params.username}/profile`)
    .then((results) => {
      this.setState({
        username: this.props.params.username, 
        userID: this.props.userID,
        date: 'May 4th, 2012', 
        image: userImage, 
        recipeList: results.data.recipes
      }); 
    })
    .catch((error) => {
      console.log(error); 
    }); 
  }

   componentWillReceiveProps(nextProps) {
      console.log('RECEIVING PROPS!'); 
      console.log('PARAMS USER PAGE: ', nextProps.params);
      var username = nextProps.params.username; 
      var userImage = placeholders.images[username] || 'https://cdn4.iconfinder.com/data/icons/kitchenware-2/100/04-512.png';  

      axios.get(`/${username}/profile`)
      .then((results) => {
        console.log('SUCCESSFULLY REQUESTED PROFILE'); 
        console.log(results); 
        this.setState({
          username: username, 
          date: 'May 4th, 2012', 
          otherUser: nextProps.otherUser, 
          image: userImage, 
          recipeList: results.data.recipes,
          activeKey: 2
        }); 
      })
      .catch((error) => {
        console.log(error); <commit_msg>Implement fix on conditional logic in rendering User Page buttons.<commit_after>import React from 'react';
import { browserHistory, Router, Route, IndexRoute, Link} from 'react-router';
import RecipeListEntry from './RecipeListEntry'; 
import FollowingListEntry from './FollowingListEntry'; 

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

// Server Requests
var axios = require('axios');

// Placeholder recipe data 
import placeholders from '../../../../placeholders'


class UserProfile extends React.Component {
  constructor(props) {
    super(props); 
    this.state = {
      username: '',
      userID: null,
      otherUser: false,   
      firstname: '',
      lastname: '',
      email: '',
      image: 'http://www.trbimg.com/img-53c59dde/turbine/la-dd-jacques-pepin-gordon-ramsay-20140715',
      userProfile: null, 
      recipeList: [],
      bio: 'Click here to write a short bio',
      activeKey: 2,
      followingList: placeholders.followingList
    }; 
  }

  componentWillMount() {
    console.log('PARAMS USER PAGE: ', this.props.params); 
    var username = this.props.params.username; 
    var userImage = placeholders.images[username] || 'https://cdn4.iconfinder.com/data/icons/kitchenware-2/100/04-512.png';  

    axios.get(`/${this.props.params.username}/profile`)
    .then((results) => {
      this.setState({
        username: this.props.params.username, 
        userID: this.props.userID,
        date: 'May 4th, 2012', 
        image: userImage, 
        recipeList: results.data.recipes
      }); 
    })
    .catch((error) => {
      console.log(error); 
    }); 
  }

   componentWillReceiveProps(nextProps) {
      console.log('RECEIVING PROPS!'); 
      console.log('PARAMS USER PAGE: ', nextProps.params);
      console.log(nextProps); 
      var username = nextProps.params.username; 
      var userImage = placeholders.images[username] || 'https://cdn4.iconfinder.com/data/icons/kitchenware-2/100/04-512.png';  
      var otherUser = this.props.username !== username; 
      console.log('OTHER USER: ', otherUser); 

      axios.get(`/${username}/profile`)
      .then((results) => {
        console.log('SUCCESSFULLY REQUESTED PROFILE'); 
        console.log(results); 
        this.setState({
          username: username, 
          date: 'May 4th, 2012', 
          otherUser: otherUser, 
          image: userImage, 
          recipeList: results.data.recipes,
          activeKey: 2
        }); 
      })
      .catch((error) => {
        console.log(error); 
{'fraction_non_alphanumeric': 0.14041633935585232, 'fraction_numerical': 0.01728201099764336, 'mean_word_length': 2.679913294797688, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, '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': '921376', 'n_tokens_mistral': 1636, 'n_tokens_neox': 1523, 'n_words': 313}