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