<commit_before>import React, { Component } from 'react';
import { connect } from 'react-redux';
import axios from 'axios';
import { browserHistory } from 'react-router';

import SearchProducts from 'APP/app/components/SearchProducts';
import Products from 'APP/app/components/Products';
import SingleProduct from 'APP/app/components/SingleProduct';
import { selectProduct } from 'APP/app/action-creators/product';
import store from '../store';

export class SearchBarContainer extends Component {
	constructor(props) {
		super(props);

		this.state = {
			searchTerm: '',
			searchedProduct: {}
		};

		this.handleInputChange = this.handleInputChange.bind(this);
		this.handleSearchSubmit = this.handleSearchSubmit.bind(this);
	}

	handleInputChange(event) {
		this.setState({searchTerm: event.target.value});
	}

	handleSearchSubmit(event) {
		event.preventDefault();

		const searchedProduct = this.props.products.filter((product) => {
			return product.title.match(this.state.searchTerm);
		});

		console.log('searchedProduct: ', searchedProduct);
		store.dispatch(selectProduct(searchedProduct));

		console.log('SEARCHED PRODUCT', searchedProduct);
		console.log('SELECTED PRODUCT', this.props.selectedProduct);

				// console.log(browserHistory);
		browserHistory.push(`/products/${searchedProduct.id}`)
	}

	render() {
		return (
			<div>
				<SearchProducts
					handleInputChange={this.handleInputChange}
					handleSearchSubmit={this.handleSearchSubmit}
					searchTerm={this.state.searchTerm}
				/>
			</div>
		);
	}
}

export const mapStateToProps = (state) => {
	console.log('state: ', state);

	return {
		products: state.allProducts,
		selectedProduct: state.selectedProduct
	};
};


export default connect(mapStateToProps)(SearchBarContainer);<commit_msg>search is rendering single product page with correct product<commit_after>import React, { Component } from 'react';
import { connect } from 'react-redux';
import axios from 'axios';
import { browserHistory } from 'react-router';

import SearchProducts from 'APP/app/components/SearchProducts';
import Products from 'APP/app/components/Products';
import SingleProduct from 'APP/app/components/SingleProduct';
import { selectProduct } from 'APP/app/action-creators/product';
import store from '../store';

export class SearchBarContainer extends Component {
	constructor(props) {
		super(props);

		this.state = {
			searchTerm: '',
			searchedProduct: {}
		};

		this.handleInputChange = this.handleInputChange.bind(this);
		this.handleSearchSubmit = this.handleSearchSubmit.bind(this);
	}

	handleInputChange(event) {
		this.setState({searchTerm: event.target.value});
	}

	handleSearchSubmit(event) {
		event.preventDefault();

		const searchedProduct = this.props.products.filter((product) => {
			return product.title.match(this.state.searchTerm);
		});

		console.log('searchedProduct: ', searchedProduct);
		store.dispatch(selectProduct(searchedProduct));

		browserHistory.push(`/products/${searchedProduct[0].id}`);
	}

	render() {
		return (
			<div>
				<SearchProducts
					handleInputChange={this.handleInputChange}
					handleSearchSubmit={this.handleSearchSubmit}
					searchTerm={this.state.searchTerm}
				/>
			</div>
		);
	}
}

export const mapStateToProps = (state) => {
	console.log('state: ', state);

	return {
		products: state.allProducts,
		selectedProduct: state.selectedProduct
	};
};


export default connect(mapStateToProps)(SearchBarContainer);
{'fraction_non_alphanumeric': 0.13199883957064112, 'fraction_numerical': 0.0002901073397156948, 'mean_word_length': 4.975736568457539, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '113313', 'n_tokens_mistral': 1127, 'n_tokens_neox': 1008, 'n_words': 188}