Skip to content
Permalink
Browse files

added redirect logic to the login screen

  • Loading branch information...
Greenfield, Gabriel Greenfield, Gabriel
Greenfield, Gabriel authored and Greenfield, Gabriel committed Nov 4, 2018
1 parent a4e5347 commit f592899855529e71ccb6e3482d1fdd1c740aeb7b
Showing with 312 additions and 13 deletions.
  1. +12 −2 app/src/components/login/LoginScreen.js
  2. +266 −11 app/yarn.lock
  3. +3 −0 package-lock.json
  4. +31 −0 yarn-error.log
@@ -18,17 +18,27 @@ class LoginScreen extends Component {
name: ""
};

componentDidMount() {
this.checkForId();
};

checkForId() {
if(localStorage.getItem("playerId")) {
this.props.history.push('/game');
}
}

handleNameChange = e => {
this.setState({ name: e.target.value });
};

handleSubmit = e => {
e.preventDefault();
console.log(e);
this.props
.mutate({ variables: { name: this.state.name } })
.then(({ data }) => {
console.log("got data", data);
localStorage.setItem("playerId", data.insert_Player.returning[0].id);
this.props.history.push('/game');
})
.catch(error => {
console.log("there was an error sending the query", error);
Oops, something went wrong.

0 comments on commit f592899

Please sign in to comment.
You can’t perform that action at this time.