ensl_gathers/app/javascripts/components/event.js

31 lines
625 B
JavaScript
Raw Normal View History

2016-01-22 21:39:03 +00:00
const $ = require("jquery");
2016-01-22 10:12:23 +00:00
const React = require("react");
2015-12-29 16:26:11 +00:00
const Events = React.createClass({
propTypes: {
events: React.PropTypes.array.isRequired
},
getTime(timeString) {
return (new Date(timeString)).toTimeString().match(/^[\d:]*/)[0];
},
render() {
let events;
if (this.props.events.length) {
events = this.props.events.map(event => {
2016-01-02 21:32:26 +00:00
return `${this.getTime(event.createdAt)} ${event.description}`;
}).join("\n");
2015-12-29 16:26:11 +00:00
} else {
events = <tr><td>Listening for new events...</td></tr>
}
return (
2016-01-02 21:32:26 +00:00
<pre className="events-panel">
{events}
</pre>
2015-12-29 16:26:11 +00:00
);
}
});
2016-01-22 21:39:03 +00:00
module.exports = Events;