diff options
| author | Wes Bos <wesbos@gmail.com> | 2018-03-20 14:13:18 -0400 |
|---|---|---|
| committer | Wes Bos <wesbos@gmail.com> | 2018-03-20 14:13:18 -0400 |
| commit | 217cfed064989816fbffcb1e285134c8e03ef5c7 (patch) | |
| tree | 0e9a3e43641ad839f5c141c32a3375d7d305022c /frontend/components/RequestReset.js | |
| parent | 43890f9940326702dac1769eb0ded8651db6bad6 (diff) | |
tests
Diffstat (limited to 'frontend/components/RequestReset.js')
| -rw-r--r-- | frontend/components/RequestReset.js | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/frontend/components/RequestReset.js b/frontend/components/RequestReset.js deleted file mode 100644 index 974924f..0000000 --- a/frontend/components/RequestReset.js +++ /dev/null @@ -1,68 +0,0 @@ -import React, { Component } from 'react'; -import { graphql, compose } from 'react-apollo'; -import { REQUEST_RESET_MUTATION } from '../queries'; -import Form from './styles/Form'; - -class ResetRequest extends Component { - state = { - email: `wesbos@gmail.com`, - password: 'abc123', - errors: [], - }; - - requestReset = async e => { - e.preventDefault(); - console.log(this.state.email); - const res = await this.props.requestReset({ - variables: { - email: this.state.email, - }, - }); - if (res.errors) { - this.setState({ errors: res.errors }); - } - console.log(res); - // // pull the values from state - // const { email, password } = this.state; - // this.setState({ loading: true, errors: [] }); - // const res = await this.props.signin({ - // // pass in those variables from state - // variables: { name, email, password }, - // }); - // if (res.errors) { - // this.setState({ errors: res.errors }); - // return; - // } - // localStorage.setItem('token', res.data.signin.token); - // // TODO refetch current user query - // this.props.currentUser.refetch(); - // this.setState({ loading: false }); - }; - - saveToState = e => { - const { name, value } = e.target; - this.setState({ [name]: value }); - }; - - render() { - return ( - <Form onSubmit={this.requestReset}> - {this.state.loading ? 'LOADING...' : null} - {this.state.errors ? this.state.errors.map(err => <p>{err.message}</p>) : null} - <label htmlFor="email"> - Email - <input value={this.state.email} onChange={this.saveToState} name="email" type="text" placeholder="email" /> - </label> - - <button type="submit">Request Reset!</button> - </Form> - ); - } -} - -// When we submit this mutation, we need to update our store - we have a few ways to do that: -// One - we can go nucular and run refetchQueries() which will just go get everything - this is easy, but at the cost of efficiency. - -const requestResetEnhancer = graphql(REQUEST_RESET_MUTATION, { name: 'requestReset' }); - -export default compose(requestResetEnhancer)(ResetRequest); |
