-
Notifications
You must be signed in to change notification settings - Fork 1
/
VerifyPage.js
60 lines (58 loc) · 1.55 KB
/
VerifyPage.js
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import React from "react";
import { Route, Link } from "react-router-dom";
import { Text, Box, Button } from "gestalt";
import qs from "query-string";
class VerifyPage extends React.Component {
state = {
status: "verifying"
};
componentDidMount() {
if (this.props.match) {
const query = qs.parse(this.props.location.search);
this.props
.verify(query.token)
.then(() => {
this.setState({ status: "success" });
setTimeout(() => this.props.history.push("/"), 1000);
})
.catch(() => {
this.setState({ status: "failure" });
});
}
}
render() {
if (!this.props.match) {
return null;
}
return (
<div className="verify-page">
<Box
height="90vh"
display="flex"
justifyContent="center"
alignItems="center"
>
{this.state.status === "verifying" && (
<Text size="xl">Verifying...</Text>
)}
{this.state.status === "success" && <Text size="xl">Success!</Text>}
{this.state.status === "failure" && (
<Box>
<Box marginBottom={4}>
<Text size="xl">Email verification failed</Text>
</Box>
<Link to="/login">
<Button color="red" text="Login again" />
</Link>
</Box>
)}
</Box>
</div>
);
}
}
export default props => (
<Route exact path="/verify">
{routerProps => <VerifyPage {...props} {...routerProps} />}
</Route>
);