From b1600adec47a04f60e1da07d94a3ed3906ff5aee Mon Sep 17 00:00:00 2001 From: Wes Bos Date: Thu, 14 Jun 2018 16:44:21 -0400 Subject: starter files --- finished-application/frontend/components/Signup.js | 93 ++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 finished-application/frontend/components/Signup.js (limited to 'finished-application/frontend/components/Signup.js') diff --git a/finished-application/frontend/components/Signup.js b/finished-application/frontend/components/Signup.js new file mode 100644 index 0000000..9164e67 --- /dev/null +++ b/finished-application/frontend/components/Signup.js @@ -0,0 +1,93 @@ +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'; + +const SIGNUP_MUTATION = gql` + mutation SIGNUP_MUTATION($email: String!, $name: String!, $password: String!) { + signup(email: $email, name: $name, password: $password) { + id + email + name + } + } +`; + +class Signup extends Component { + state = { + email: '', + name: '', + password: '', + }; + + saveToState = e => { + const { name, value } = e.target; + this.setState({ [name]: value }); + }; + + render() { + return ( + + {(signup, { loading, error }) => ( +
{ + e.preventDefault(); + const res = await signup(); + }} + > +
+ +

Sign Up for an Account

+ + + + + + + +
+
+ )} +
+ ); + } +} + +export default Signup; +export { SIGNUP_MUTATION }; -- cgit v1.3