2016-11-10 14:26:24 +01:00
|
|
|
import React, { PropTypes } from 'react';
|
|
|
|
|
2017-06-29 08:36:10 +02:00
|
|
|
import { Snackbar, Icon } from 'react-mdl';
|
2016-12-04 11:56:41 +01:00
|
|
|
|
2016-11-10 14:26:24 +01:00
|
|
|
class ErrorComponent extends React.Component {
|
|
|
|
static propTypes () {
|
|
|
|
return {
|
|
|
|
errors: PropTypes.array.isRequired,
|
|
|
|
muteError: PropTypes.func.isRequired,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
render () {
|
|
|
|
const showError = this.props.errors.length > 0;
|
|
|
|
const error = showError ? this.props.errors[0] : undefined;
|
2016-11-24 20:41:05 +01:00
|
|
|
const muteError = () => this.props.muteError(error);
|
2016-11-10 14:26:24 +01:00
|
|
|
return (
|
|
|
|
<Snackbar
|
|
|
|
action="Dismiss"
|
|
|
|
active={showError}
|
2016-12-05 16:24:16 +01:00
|
|
|
onActionClick={muteError}
|
2016-11-24 20:41:05 +01:00
|
|
|
onTimeout={muteError}
|
2016-12-05 16:24:16 +01:00
|
|
|
timeout={10000}
|
|
|
|
>
|
|
|
|
<Icon name="question_answer" /> {error}
|
|
|
|
</Snackbar>
|
2016-11-10 14:26:24 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default ErrorComponent;
|