forked from ivacf/ivanc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppList.js
More file actions
executable file
·57 lines (48 loc) · 1.24 KB
/
Copy pathAppList.js
File metadata and controls
executable file
·57 lines (48 loc) · 1.24 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
57
var React = require('react');
var AppCard = require('./AppCard.js');
var FetchUtils = require('./FetchUtils');
var AppList = React.createClass({
loadAppsFromServer: function() {
function parseStringDates(apps) {
apps.forEach(function(app) {
app.start_date = new Date(app.start_date);
if (app.end_date) {
app.end_date = new Date(app.end_date);
}
});
return apps;
}
fetch(FetchUtils.buildServerURL('apps/'))
.then(FetchUtils.checkStatus)
.then(FetchUtils.parseJSON)
.then(parseStringDates)
.then(function(appsJson) {
this.setState({apps: appsJson});
}.bind(this))
.catch(function(error) {
console.log('Error retrieving apps', error);
//TODO display error to user?
});
},
getInitialState: function() {
return {apps: []};
},
componentDidMount: function() {
this.loadAppsFromServer();
},
render: function() {
var appNodes = this.state.apps.map(function(app) {
return (
<div className="cardContainer" key={app.id} >
<AppCard data={app} />
</div>
);
});
return (
<div className="appList">
{appNodes}
</div>
);
}
});
module.exports=AppList