1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00
unleash.unleash/public/js/components/event/EventsComponent.jsx
2020-02-20 08:30:15 +01:00

47 lines
1.2 KiB
JavaScript

var React = require('react'),
EventList = require('./EventList'),
eventStore = require('../../stores/EventStore'),
ErrorMessages = require('../ErrorMessages');
var EventsComponent = React.createClass({
getInitialState: function() {
return {
createView: false,
events: [],
errors: []
};
},
componentDidMount: function () {
eventStore.getEvents().then(function(res) {
this.setState({events: res.events});
}.bind(this), this.initError);
},
initError: function() {
this.onError("Could not load events from server");
},
clearErrors: function() {
this.setState({errors: []});
},
onError: function(error) {
var errors = this.state.errors.concat([error]);
this.setState({errors: errors});
},
render: function() {
return (
<div>
<ErrorMessages errors={this.state.errors} onClearErrors={this.clearErrors} />
<hr />
<EventList events={this.state.events} />
</div>
);
},
});
module.exports = EventsComponent;