-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
APIKey.js
78 lines (73 loc) · 2.04 KB
/
APIKey.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import React from "react";
import {
Segment,
Header,
Dimmer,
Loader,
Image,
Message,
} from "semantic-ui-react";
import Shell from "./Shell";
import ShortParagraphIMG from "../../assets/images/short_paragraph.png";
import { authAxios } from "../../utils";
import { APIkeyURL } from "../../constants";
class APIKey extends React.Component {
state = {
loading: false,
error: null,
keys: [],
};
componentDidMount() {
this.handleUserDetails();
}
handleUserDetails = () => {
this.setState({ loading: true });
authAxios
.get(APIkeyURL)
.then((res) => {
this.setState({
loading: false,
keys: res.data,
});
})
.catch((err) => {
this.setState({
loading: false,
error: err.response.data.message,
});
});
};
render() {
const { loading, error, keys } = this.state;
return (
<Shell>
{error && (
<Message
error
header="There was an error"
content={error}
/>
)}
{loading && (
<Segment>
<Dimmer active inverted>
<Loader inverted>
Detecting Facial Expressions ......
</Loader>
</Dimmer>
<Image src={ShortParagraphIMG} />
</Segment>
)}
{keys && (
<Segment>
<Header as="h3">API Key</Header>
{keys.map((k) => {
return <p key={k.pk}>{k.key}</p>;
})}
</Segment>
)}
</Shell>
);
}
}
export default APIKey;