2015-03-17 20:29:03 +01:00
|
|
|
var React = require('react');
|
|
|
|
var Ui = require('./ErrorMessages.ui');
|
|
|
|
var ErrorStore = require('../stores/ErrorStore');
|
|
|
|
var ErrorActions = require('../stores/ErrorActions');
|
2014-10-30 18:25:38 +01:00
|
|
|
|
|
|
|
var ErrorMessages = React.createClass({
|
2015-03-17 20:29:03 +01:00
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
|
|
|
errors: ErrorStore.getErrors()
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
onStoreChange: function() {
|
|
|
|
this.setState({
|
|
|
|
errors: ErrorStore.getErrors()
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
componentDidMount: function() {
|
|
|
|
this.unsubscribe = ErrorStore.listen(this.onStoreChange);
|
|
|
|
},
|
2014-10-30 18:25:38 +01:00
|
|
|
|
2015-03-17 20:29:03 +01:00
|
|
|
componentWillUnmount: function() {
|
|
|
|
this.unsubscribe();
|
|
|
|
},
|
2014-10-30 18:25:38 +01:00
|
|
|
|
2015-03-17 20:29:03 +01:00
|
|
|
onClearErrors: function() {
|
|
|
|
ErrorActions.clear();
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
2014-10-30 18:25:38 +01:00
|
|
|
return (
|
2015-03-17 20:29:03 +01:00
|
|
|
<Ui errors={this.state.errors} onClearErrors={this.onClearErrors}></Ui>
|
2014-10-30 18:25:38 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-10-31 10:30:23 +01:00
|
|
|
module.exports = ErrorMessages;
|