diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-04-05 13:54:22 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-04-05 13:54:22 -0400 |
| commit | f4f10d5eb690a33dd1c112358457a2b987297f26 (patch) | |
| tree | d97326763dd016c13a068fb7dee40fc0b9667f83 /frontend/components/Signup.js | |
| parent | a75b2491758a451283e2a373bb3fbe886520b345 (diff) | |
work
Diffstat (limited to 'frontend/components/Signup.js')
| -rw-r--r-- | frontend/components/Signup.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/frontend/components/Signup.js b/frontend/components/Signup.js index 4adc1ad..2fc8950 100644 --- a/frontend/components/Signup.js +++ b/frontend/components/Signup.js @@ -1,8 +1,9 @@ import React, { Component } from 'react'; import { Mutation } from 'react-apollo'; -import { SIGNUP_MUTATION } from '../queries'; +import { SIGNUP_MUTATION, CURRENT_USER_QUERY } from '../queries'; import Form from './styles/Form'; import Error from './ErrorMessage'; +import { client } from '../lib/withData'; class Signup extends Component { state = { @@ -21,9 +22,11 @@ class Signup extends Component { <Mutation mutation={SIGNUP_MUTATION} variables={this.state}> {(signup, { loading, error }) => ( <Form - onSubmit={e => { + onSubmit={async e => { e.preventDefault(); - signup(); + const res = await signup(); + localStorage.setItem('token', res.data.signup.token); + client.query({ query: CURRENT_USER_QUERY, fetchPolicy: 'network-only' }); }} > <fieldset disabled={loading} aria-busy={loading}> |
