<commit_before>import React, { Component } from 'react';
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { UncontrolledDropdown, DropdownToggle, DropdownMenu, DropdownItem, FormControl } from 'reactstrap';

import { selectPreferredSurvey } from '../../actions'
import Arrays from 'utils/Arrays'

class SurveySelect extends Component {
    constructor( props ) {
        super( props );
		this.handleSurveySelect = this.handleSurveySelect.bind( this );
		
		this.state = {
			dropdownOpen: false,
			selectedSurveyName: '---Select a survey---'
		}
    }
    static propTypes = {
        summaries: PropTypes.array.isRequired,
        selectedSurvey: PropTypes.object,
		isFetchingSummaries: PropTypes.bool.isRequired,
		isFetchingPreferredSurvey: PropTypes.bool.isRequired,
        lastUpdated: PropTypes.number,
        dispatch: PropTypes.func.isRequired
    }
    componentDidMount() {
        //const { dispatch } = this.props
        //dispatch(fetchSurveySummaries())
	}
	
    handleSurveySelect(surveyId) {
    	const { summaries } = this.props
    	var survey = summaries.find(summary => summary.id === surveyId);
    	if (survey) {
			this.setState({selectedSurveyName: survey.name})
    		this.props.dispatch(selectPreferredSurvey(survey));
    	}
	}
	
    render() {
		const { selectedSurvey, summaries } = this.props
		const publishedSurveys = summaries.filter(s => s.published && !s.temporary)
    	const isEmpty = publishedSurveys.length === 0
		Arrays.sort(publishedSurveys, 'name')
    	
    	const dropdownItems = publishedSurveys.map(s => 
			<DropdownItem key={s.id} className="survey-item" onClick={this.handleSurveySelect.bind(this, s.id)}>
				<div className="survey-name">{s.name}</div><div className="survey-project-name">{s.projectName}</div><commit_msg>Code clean<commit_after>import React, { Component } from 'react';
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { UncontrolledDropdown, DropdownToggle, DropdownMenu, DropdownItem, FormControl } from 'reactstrap';

import { selectPreferredSurvey } from '../../actions'
import Arrays from 'utils/Arrays'

class SurveySelect extends Component {
    constructor( props ) {
        super( props );
		this.handleSurveySelect = this.handleSurveySelect.bind( this );
		
		this.state = {
			dropdownOpen: false,
			selectedSurveyName: '---Select a survey---'
		}
    }
    static propTypes = {
        summaries: PropTypes.array.isRequired,
        selectedSurvey: PropTypes.object,
		isFetchingSummaries: PropTypes.bool.isRequired,
		isFetchingPreferredSurvey: PropTypes.bool.isRequired,
        lastUpdated: PropTypes.number,
        dispatch: PropTypes.func.isRequired
    }
	
    handleSurveySelect(surveyId) {
    	const { summaries } = this.props
    	var survey = summaries.find(summary => summary.id === surveyId);
    	if (survey) {
			this.setState({selectedSurveyName: survey.name})
    		this.props.dispatch(selectPreferredSurvey(survey));
    	}
	}
	
    render() {
		const { selectedSurvey, summaries } = this.props
		const publishedSurveys = summaries.filter(s => s.published && !s.temporary)
    	const isEmpty = publishedSurveys.length === 0
		Arrays.sort(publishedSurveys, 'name')
    	
    	const dropdownItems = publishedSurveys.map(s => 
			<DropdownItem key={s.id} className="survey-item" onClick={this.handleSurveySelect.bind(this, s.id)}>
				<div className="survey-name">{s.name}</div><div className="survey-project-name">{s.projectName}</div>
{'fraction_non_alphanumeric': 0.12389380530973451, 'fraction_numerical': 0.0005709391949757351, 'mean_word_length': 3.7868852459016393, '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': '3754029', 'n_tokens_mistral': 1114, 'n_tokens_neox': 1083, 'n_words': 209}