{"size": 714, "ext": "js", "max_stars_repo_path": "src/containers/GuestSignIn.js", "max_stars_repo_name": "BrooklinJazz/battle-master-client", "max_stars_repo_stars_event_min_datetime": "2018-12-29T02:43:30.000Z", "max_stars_repo_stars_event_max_datetime": "2018-12-29T02:43:30.000Z", "max_issues_repo_path": "src/containers/GuestSignIn.js", "max_issues_repo_name": "BrooklinJazz/battle-master-client", "max_issues_repo_issues_event_min_datetime": "2018-03-28T00:49:11.000Z", "max_issues_repo_issues_event_max_datetime": "2018-04-06T03:30:18.000Z", "max_forks_repo_path": "src/containers/GuestSignIn.js", "max_forks_repo_name": "BrooklinJazz/battle-master-client", "max_forks_repo_forks_event_min_datetime": "2018-03-06T00:05:47.000Z", "max_forks_repo_forks_event_max_datetime": "2018-03-06T00:05:47.000Z"}
{"max_stars_count": 1, "max_issues_count": 1, "max_forks_count": 1, "avg_line_length": 20.4, "max_line_length": 90, "alphanum_fraction": 0.568627451}
import React, { Component } from 'react';
import {Token} from '../requests/tokens'

class GuestSignIn extends Component {
  constructor(props) {
    super(props);
  }

  signIn() {
    event.preventDefault();
    const email = 'guest@guest.com'
    const password = 'guest'
    const {onSignIn = () => {}} = this.props;
    Token
    .create({email, password})
    .then(data => {
      if (!data.error) {
        const {jwt} = data;
        localStorage.setItem('jwt', jwt);
        onSignIn();
        this.props.history.push("/");
      }
    });
  }

  render() {
    return (
      <div className="GuestSignIn" onClick={() => this.signIn()}>or sign in as guest</div>
    )
  }

}

export default GuestSignIn;
