<commit_before>import React, { Component, PropTypes } from 'react';
import cx from 'classnames';
import LuverneStore from '../../stores/LuverneStore';
import s from './Result.scss';
import withStyles from '../../decorators/withStyles';
import PartResults from '../PartResults';

@withStyles(s)
class Result extends Component {

	static propTypes = {
		result: PropTypes.object.isRequired,
		activeIndex: PropTypes.number,
		className: PropTypes.string,
		fitments: PropTypes.array,
		iconParts: PropTypes.oneOfType([
			React.PropTypes.object,
			React.PropTypes.array,
		]),
	};

	constructor() {
		super();

		this.state = {
			products: [],
		};

		this.updateStyle = this.updateStyle.bind(this);
	}

	componentWillReceiveProps(props) {
		const products = [];
		if (props.fitments && props.fitments.length > 0) {
			props.fitments.map((ft) => {
				if (!ft.product || !ft.product.categories || ft.product.categories.length === 0) {
					return;
				}

				if (ft.product.categories[0].id === props.result.category.id) {
					ft.product.iconLayer = this.props.iconParts ? this.props.iconParts[ft.product.part_number] : '';
					products.push(ft.product);
				}
			});
		}

		if (products.length !== this.state.products.length) {
			this.setState({
				products,
			});
		}
	}

	updateStyle(e) {
		e.preventDefault();

		LuverneStore.fetchFitments(this.props.result, this.refs.style.value);
	}

	renderStyles() {
		if (
			!this.props.result.fitments ||
			this.props.result.fitments.length === 0
		) {
			return null;
		}
		// if (this.props.result.style_options[0].style.toLowerCase() === 'all') {
		// 	return null;
		// }

		return (
			<div className={'form-group'}>
				<select ref="style" onChange={this.updateStyle} className="form-control">
					<option value="">- Select Style -</option>
					{this.props.result.fitments.map((fit, i) => <option key={i}>{fit.title.toUpperCase()}</option>)}
				</select>
			</div>
		);
	}

	render() {
		if (
			!this.props.activeIndex ||
			!this.props.result.category
		) {
			return <div></div>;
		}

		return (
			<div<commit_msg>Dropdowns are populated properly<commit_after>import React, { Component, PropTypes } from 'react';
import cx from 'classnames';
import LuverneStore from '../../stores/LuverneStore';
import s from './Result.scss';
import withStyles from '../../decorators/withStyles';
import PartResults from '../PartResults';

@withStyles(s)
class Result extends Component {

	static propTypes = {
		result: PropTypes.object.isRequired,
		activeIndex: PropTypes.number,
		className: PropTypes.string,
		fitments: PropTypes.array,
		iconParts: PropTypes.oneOfType([
			React.PropTypes.object,
			React.PropTypes.array,
		]),
	};

	constructor() {
		super();

		this.state = {
			products: [],
		};

		this.updateStyle = this.updateStyle.bind(this);
	}

	componentWillReceiveProps(props) {
		const products = [];
		if (props.fitments && props.fitments.length > 0) {
			props.fitments.map((ft) => {
				if (!ft.product || !ft.product.categories || ft.product.categories.length === 0) {
					return;
				}

				if (ft.product.categories[0].id === props.result.category.id) {
					ft.product.iconLayer = this.props.iconParts ? this.props.iconParts[ft.product.part_number] : '';
					products.push(ft.product);
				}
			});
		}

		if (products.length !== this.state.products.length) {
			this.setState({
				products,
			});
		}
	}

	updateStyle(e) {
		e.preventDefault();

		LuverneStore.fetchFitments(this.props.result, this.refs.style.value);
	}

	renderStyles() {
		if (
			!this.props.result.fitments ||
			this.props.result.fitments.length === 0
		) {
			return null;
		}

		const lst = [];
		this.props.result.fitments.map((fit) => {
			const opts = [];
			if (fit.options.length > 0) {
				fit.options.map((o, i) => {
					opts.push(
						<option key={i}>{o.toUpperCase()}</option>
					);
				});
			}

			lst.push(
				<div className={'form-group'}>
					<select ref="style" onChange={this.updateStyle} className="form-control">
						<option value="">- {fit.title.toUpperCase()} -</option>
							{ opts }
					</select>
				</div>
			);
		});

		console.log(lst);

		return lst;
	}

	render() {
		if (
			!this.props.activeIndex ||
			!this.props.result.category
		) {
			return <div></div>;
		}

		return (
			<div
{'fraction_non_alphanumeric': 0.1730095727293953, 'fraction_numerical': 0.0023348120476301658, 'mean_word_length': 3.167315175097276, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 31, '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': '2479254', 'n_tokens_mistral': 1708, 'n_tokens_neox': 1461, 'n_words': 247}