blob: 1762aa3249133d6f659fe7841a2b1cbdbfb1a301 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
import React from 'react';
import { Mutation } from 'react-apollo';
import { REQUEST_RESET_MUTATION } from '../queries/queries.graphql';
import Form from './styles/Form';
import Error from './ErrorMessage';
class ResetRequest extends React.Component {
state = {
email: '',
};
render() {
return (
<Mutation mutation={REQUEST_RESET_MUTATION} variables={this.state}>
{(resetMutation, { loading, error, called }) => (
<Form
onSubmit={async e => {
e.preventDefault();
await resetMutation();
}}
data-test="ResetRequest"
>
<Error error={error} />
{!error && called && !loading && <p>Success! Check Your Email!</p>}
<fieldset disabled={loading} aria-busy={loading}>
<label htmlFor="email">
Email
<input
value={this.state.email}
onChange={e => this.setState({ email: e.target.value })}
name="email"
type="text"
placeholder="email"
/>
</label>
<button type="submit">Request Reset!</button>
</fieldset>
</Form>
)}
</Mutation>
);
}
}
export default ResetRequest;
|