<commit_before>import React, { Component } from 'react'
import { connect } from 'react-redux'
import { hashHistory } from 'react-router'
import { getIsAuthenticated } from '../selectors/user'
import { getSelectedOrganization } from '../selectors/organizations'
import { selectOrganization } from '../actions/organizations'

class OrganizationPage extends Component {
  componentWillMount() {
    // if(this.props.organization === undefined) {
    //   this.props.dispatch(selectOrganization(parseInt(this.props.params.orgId, 10)));
    // }
  }
  render() {
    if(!this.props.isAuthenticated) {
      hashHistory.push('');
      return null;
    }
    return (
      <div className="container">
        {this.props.organization ? this.props.organization.name : null}
      </div>
    );
  }
}

export default connect(
  state => ({
    isAuthenticated: getIsAuthenticated(state),
    organization: getSelectedOrganization(state)
  })
)(OrganizationPage);<commit_msg>Fetch organizations on organization page load<commit_after>import React, { Component } from 'react'
import { connect } from 'react-redux'
import { hashHistory } from 'react-router'
import { getIsAuthenticated } from '../selectors/user'
import { getOrganizations } from '../selectors/organizations'
import { fetchOrganizations } from '../actions/organizations'

class OrganizationPage extends Component {
  componentWillMount() {
    if(this.props.organizations.length == 0) {
      this.props.dispatch(fetchOrganizations());
    }
  }
  render() {
    if(!this.props.isAuthenticated) {
      hashHistory.push('');
      return null;
    }
    let selectedOrganization = this.props.organizations[parseInt(this.props.params.orgId, 10)];
    let name = selectedOrganization ? selectedOrganization.name : null;
    return (
      <div className="container">
        {name}
      </div>
    );
  }
}

export default connect(
  state => ({
    isAuthenticated: getIsAuthenticated(state),
    organizations: getOrganizations(state)
  })
)(OrganizationPage);
{'fraction_non_alphanumeric': 0.12989588497768964, 'fraction_numerical': 0.002478929102627665, 'mean_word_length': 3.7370892018779345, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '3204147', 'n_tokens_mistral': 581, 'n_tokens_neox': 574, 'n_words': 120}