diff options
| author | Randy Ridge <randyridge@gmail.com> | 2018-09-14 20:01:25 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-09-14 20:01:25 -0400 |
| commit | 908180c77cd38011eeedcae949613da2a3391e5e (patch) | |
| tree | b59bf1aae819a04d453cde72f6e601f5561a740f /finished-application/frontend/components/Signup.js | |
| parent | 1f6667d233a4a2e9df977204d83a8f749c050c75 (diff) | |
| parent | b3bebda57ba187b7fa10398054b54c05d3fd3555 (diff) | |
Merge branch 'master' into randyridge/our
Diffstat (limited to 'finished-application/frontend/components/Signup.js')
| -rw-r--r-- | finished-application/frontend/components/Signup.js | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/finished-application/frontend/components/Signup.js b/finished-application/frontend/components/Signup.js index 9164e67..e2f1a3f 100644 --- a/finished-application/frontend/components/Signup.js +++ b/finished-application/frontend/components/Signup.js @@ -1,9 +1,9 @@ import React, { Component } from 'react'; import { Mutation } from 'react-apollo'; import gql from 'graphql-tag'; -import { CURRENT_USER_QUERY } from './User'; import Form from './styles/Form'; import Error from './ErrorMessage'; +import { CURRENT_USER_QUERY } from './User'; const SIGNUP_MUTATION = gql` mutation SIGNUP_MUTATION($email: String!, $name: String!, $password: String!) { @@ -17,16 +17,13 @@ const SIGNUP_MUTATION = gql` class Signup extends Component { state = { - email: '', name: '', + email: '', password: '', }; - saveToState = e => { - const { name, value } = e.target; - this.setState({ [name]: value }); + this.setState({ [e.target.name]: e.target.value }); }; - render() { return ( <Mutation @@ -34,28 +31,28 @@ class Signup extends Component { variables={this.state} refetchQueries={[{ query: CURRENT_USER_QUERY }]} > - {(signup, { loading, error }) => ( + {(signup, { error, loading }) => ( <Form method="post" onSubmit={async e => { e.preventDefault(); - const res = await signup(); + await signup(); + this.setState({ name: '', email: '', password: '' }); }} > <fieldset disabled={loading} aria-busy={loading}> + <h2>Sign Up for An Account</h2> <Error error={error} /> - <h2>Sign Up for an Account</h2> <label htmlFor="email"> Email <input - value={this.state.email} - onChange={this.saveToState} + type="email" name="email" - type="text" placeholder="email" + value={this.state.email} + onChange={this.saveToState} /> </label> - <label htmlFor="name"> Name <input @@ -66,21 +63,18 @@ class Signup extends Component { onChange={this.saveToState} /> </label> - - <label htmlFor="signupPassword"> + <label htmlFor="password"> Password <input type="password" name="password" - id="signupPassword" - className="password" placeholder="password" value={this.state.password} onChange={this.saveToState} /> </label> - <button type="submit">Submit</button> + <button type="submit">Sign Up!</button> </fieldset> </Form> )} |
