{"size": 1394, "ext": "js", "max_stars_repo_path": "src/components/Production/Production.js", "max_stars_repo_name": "oonne/clapperboard", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/Production/Production.js", "max_issues_repo_name": "oonne/clapperboard", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/Production/Production.js", "max_forks_repo_name": "oonne/clapperboard", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.3454545455, "max_line_length": 117, "alphanum_fraction": 0.56241033}
import React, { Component } from 'react';
import { connect } from 'react-redux';
import { requestProduction } from './../../actions/attr';

import './Production.css';

class Production extends Component {

    constructor(props) {
        super(props);

        this.state = {
            production: '',
        };
    };

    changeProduction(production) {
        if (production !== null) {
            this.setState({production: production});
            this.props.requestProduction(production);    
        };
    };

    componentDidMount() {
        let production = localStorage.getItem("production");
        this.changeProduction(production);
    };

    handleInput = (event) => {
        let production = event.target.value;
        this.changeProduction(production);
        localStorage.setItem("production", production);
    };

    render() {
        return (
            <div className="production">
                <div className="Home-attr">
                    PRODUCTION
                </div>
                <input className="Home-input" type="text" value={this.state.production} onChange={this.handleInput}/>
            </div>
        );
    };
}

export default connect(
    (state, ownProps) => ({
        production: state.attr.production,
    }),
    dispatch => ({
        requestProduction: (params) => dispatch(requestProduction(params)),
    })
)(Production);
