forked from ivacf/ivanc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRepoList.js
More file actions
executable file
·56 lines (47 loc) · 1.23 KB
/
Copy pathRepoList.js
File metadata and controls
executable file
·56 lines (47 loc) · 1.23 KB
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
var React = require('react');
var RepoCard = require('./RepoCard.js');
var FetchUtils = require('./FetchUtils');
var RepoList = React.createClass({
loadReposFromServer: function() {
function parseStringDates(repos) {
repos.forEach(function(repo) {
repo.start_date = new Date(repo.start_date);
if (repo.end_date) {
repo.end_date = new Date(repo.end_date);
}
});
return repos;
}
fetch(FetchUtils.buildServerURL('repos/'))
.then(FetchUtils.checkStatus)
.then(FetchUtils.parseJSON)
.then(parseStringDates)
.then(function(reposJson) {
this.setState({repos: reposJson});
}.bind(this))
.catch(function(error) {
console.log('Error retrieving repos', error);
});
},
getInitialState: function() {
return {repos: []};
},
componentDidMount: function() {
this.loadReposFromServer();
},
render: function() {
var repoNodes = this.state.repos.map(function(repo) {
return (
<div className="cardContainer" key={repo.id} >
<RepoCard data={repo} />
</div>
);
});
return (
<div className="repoList">
{repoNodes}
</div>
);
}
});
module.exports=RepoList