{"size": 1432, "ext": "js", "max_stars_repo_path": "src/components/Login.js", "max_stars_repo_name": "fsharifnezhad/react-redux-auth0", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/components/Login.js", "max_issues_repo_name": "fsharifnezhad/react-redux-auth0", "max_issues_repo_issues_event_min_datetime": "2021-10-05T22:10:31.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-26T11:19:59.000Z", "max_forks_repo_path": "src/components/Login.js", "max_forks_repo_name": "fsharifnezhad/react-redux-auth0", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 4, "max_forks_count": null, "avg_line_length": 26.0363636364, "max_line_length": 76, "alphanum_fraction": 0.6634078212}
import React, {Component} from "react";
import {Link} from "react-router-dom";
import {AppBar, Toolbar, Typography, Button, Grid} from "@material-ui/core";
import {withStyles} from "@material-ui/core/styles";
import {connect} from "react-redux";
import requestLogin from "../actions/requestLogin";
import requestLogout from "../actions/requestLogout";
import history from "../history";
// import "../styles/styles.css";

const styles = theme => ({
  title: {
    flexGrow: 1
  },
  loginGrid: {
    background: "url(../assets/images/login_bgdark.png) center center"
  },
  button: {
    margin: theme.spacing(1)
  }
});

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

  componentDidMount = () => {
    let access_token = localStorage.getItem("access_token");
    let id_token = localStorage.getItem("id_token");
    let expires_at = localStorage.getItem("expires_at");

    if (!access_token && !id_token && new Date().getTime() > expires_at) {
      this.props.auth.authorize();
    }
  };

  render() {
    return <p>Logging in...</p>;
  }
}

const mapStateToProps = state => {
  return {auth: state.auth, isAuthenticated: state.isAuthenticated};
};

// const mapDispatchToProps = dispatch => {
//   return {
//     requestLogin: () => dispatch(requestLogin()),
//     requestLogout: () => dispatch(requestLogout())
//   };
// };

export default connect(mapStateToProps)(withStyles(styles)(Login));
