-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.js
52 lines (49 loc) · 1.41 KB
/
index.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
import React, { Component, Fragment } from "react";
import { getRepos } from "../../api/repos";
import { getUser } from "../../api/user";
import ProfileInput from "./profile-input";
import UserProfile from "./profile";
import Repositories from "./repositories";
import Card from "../../components/library/card";
import Nav from "../../components/common/nav";
import styled from "styled-components";
const RepositoriesCard = styled(Card)`
text-align: center;
box-sizing: border-box;
margin: 20px auto 0;
padding: 30px 50px;
width: 500px;
min-height: 100px;
color: #000000;
@media (max-width: 600px) {
width: 90%;
}
`;
export default class Profile extends Component {
state = {
userRepos: [{}, {}, {}, {}, {}],
userProfile: {}
};
getUserInfo = userName => {
getUser(userName).then(userProfile => this.setState({ userProfile }));
getRepos(userName).then(userRepos => this.setState({ userRepos }));
};
render() {
const { userRepos, userProfile } = this.state;
let RepositoriesData = (
<RepositoriesCard>
<UserProfile userProfile={userProfile} />
<Repositories repos={userRepos} />
</RepositoriesCard>
);
if (!userProfile.url) {
RepositoriesData = <RepositoriesCard>No Data Found..</RepositoriesCard>;
}
return (
<Fragment>
<ProfileInput getUserInfo={this.getUserInfo} />
{RepositoriesData}
</Fragment>
);
}
}