-
Notifications
You must be signed in to change notification settings - Fork 107
/
user_github_profile.js
145 lines (135 loc) · 3.84 KB
/
user_github_profile.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
import React, { Component } from "react";
import PropTypes from "prop-types";
import { connect } from "react-redux";
import userApi from "../../api/Github/userApi";
import { BounceLoader } from "react-spinners";
import { Link, withRouter } from "react-router-dom";
import pic from "../assets/profile.png";
import { getDeployed } from "../../api/Nongh/getDeployed";
class Profile extends Component {
constructor(props, context) {
super(props, context);
this.state = {
democount: "democount",
userid: "userid",
username: "username",
name: "name",
email: "email.com",
bio: "bio",
company: "company",
avatar: pic,
github: ""
};
}
componentWillMount() {
userApi
.userProfile()
.then(user => {
user = JSON.parse(user);
let userid = user.id;
let username = user.login;
let name = user.name;
let email = user.email;
let bio = user.bio;
let company = user.company;
let avatar = user.avatar_url;
let github = user.html_url;
this.setState({
userid,
username,
name,
email,
bio,
company,
avatar,
github
});
})
.then(
getDeployed(this.state.userid).then(deployedArray => {
let democount = JSON.parse(deployedArray).length;
this.setState({ democount });
})
);
}
componentWillReceiveProps(nextProps) {
this.setState({ demoLoading: true });
let uname = nextProps.user;
userApi.userProfileFromName(uname).then(user => {
user = JSON.parse(user);
let username = user.login;
let name = user.name;
let email = user.email;
let bio = user.bio;
let company = user.company;
let avatar = user.avatar_url;
let github = user.html_url;
this.setState({
username,
name,
email,
bio,
company,
avatar,
github
});
});
}
render() {
return (
<div className="container">
<div className="profile-sidebar">
<div>
<div className="profile-userpic">
<img src={this.state.avatar} className="img-responsive" alt="" />
</div>
<div className="profile-usertitle">
<div className="profile-usertitle-name">{this.state.name}</div>
<div className="profile-usertitle-job">{this.state.username}</div>
</div>
<div className="btn-group" style={{ marginLeft: 30 }}>
<a href="#" className="btn btn-primary">
Demo Count
</a>
<a href="#" className="btn btn-success">
{this.state.democount}
</a>
</div>
<div className="profile-usermenu">
<ul className="nav">
<li>
<a href="#">
<i className="glyphicon glyphicon-envelope" />
<span style={{ float: "right" }}>
<a href={this.state.email}> E-mail</a>
</span>
</a>
</li>
{this.state.company && (
<li>
<a href="#">
<i className="glyphicon glyphicon-user" />
{this.state.company}{" "}
</a>
</li>
)}
<li>
<a href={this.state.github}>
<i className="fab fa-github" />
Github Profile{" "}
</a>
</li>
</ul>
</div>
</div>
</div>
</div>
);
}
}
function mapStateToProps(state) {
return {
user: state.activeUser
};
}
export default connect(mapStateToProps)(Profile);