Skip to content

Commit

Permalink
Shows correct demo count (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
Caffetaria authored and vpn1997 committed Nov 16, 2018
1 parent 48ac92f commit 37bd54d
Showing 1 changed file with 34 additions and 22 deletions.
56 changes: 34 additions & 22 deletions Origami/src/components/user/user_github_profile.js
Expand Up @@ -5,42 +5,54 @@ 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: "",
count:"4"
github: ""
};
}

componentWillMount() {
userApi.userProfile().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
});
});
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) {
Expand Down Expand Up @@ -87,7 +99,7 @@ class Profile extends Component {
Demo Count
</a>
<a href="#" className="btn btn-success">
{this.state.count}
{this.state.democount}
</a>
</div>

Expand Down

0 comments on commit 37bd54d

Please sign in to comment.