-
Notifications
You must be signed in to change notification settings - Fork 122
/
app.js
52 lines (47 loc) · 1.58 KB
/
app.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
var React = require('react');
var ReactDOM = require('react-dom');
var MainInterface = React.createClass({
getInitialState: function() {
return {
myAppointments: []
} //return
}, //getInitialState
componentDidMount: function() {
this.serverRequest = $.get('./js/data.json', function(result) {
var tempApts = result;
this.setState({
myAppointments: tempApts
}); //setState
}.bind(this));
},
componentWillUnmount: function() {
this.serverRequest.abort();
},
render: function() {
var filteredApts = this.state.myAppointments;
filteredApts = filteredApts.map(function(item, index) {
return(
<li className="pet-item media" key={index}>
<div className="pet-info media-body">
<div className="pet-head">
<span className="pet-name">{this.state.myAppointments[index].petName}</span>
<span className="apt-date pull-right">{this.state.myAppointments[index].aptDate}</span>
</div>
<div className="owner-name"><span className="label-item">Owner:</span>
{this.state.myAppointments[index].ownerName}</div>
<div className="apt-notes">{this.state.myAppointments[index].aptNotes}</div>
</div>
</li>
) //return
}.bind(this)); //filteredApts.map
return (
<div className="interface">
<ul className="item-list media-list">{filteredApts}</ul>
</div>
) //return
} //render
}); //MainInterface
ReactDOM.render(
<MainInterface />,
document.getElementById('petAppointments')
); //render