{"size": 1345, "ext": "js", "max_stars_repo_path": "src/components/Question/Question.js", "max_stars_repo_name": "ursulacervantes/premios-joy", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/Question/Question.js", "max_issues_repo_name": "ursulacervantes/premios-joy", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/Question/Question.js", "max_forks_repo_name": "ursulacervantes/premios-joy", "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": 22.7966101695, "max_line_length": 67, "alphanum_fraction": 0.5375464684}
import React from 'react';
import PropTypes from 'prop-types';
import withStyles from 'isomorphic-style-loader/lib/withStyles';
import { connect } from 'react-redux';

import s from './Question.scss';
import { setVote } from '../../actions/poll';

class Question extends React.Component {
  static propTypes = {
    question: PropTypes.string.isRequired,
    nominees: PropTypes.shape({
      name: PropTypes.string.isRequired,
      votes: PropTypes.number.isRequired,
    }).isRequired,
  };

  setVote() {
    this.props.setVote({
      question: 'change',
      nominees: {
        0: {
          name: 'Manuel',
          votes: 100,
        }
      }
    });
  }

  render() {
    const { question = '', nominees = [] } = this.props.question
      ? this.props.question
      : {};
    return (
      <div className={s.root}>
        <div className={s.container}>
          <h1>{question}</h1>
          {!!nominees &&
            nominees.map(nominee => (
              <div
                className={(s.button, s.secondary)}
                role="button"
                onClick={this.setVote.bind(this)}
              >
                {nominee.name}
              </div>
            ))}
        </div>
      </div>
    );
  }
}

const mapDispatch = {
  setVote,
};

export default connect(null, mapDispatch)(withStyles(s)(Question));
