@infect/frontend
Version:
infect frontend
44 lines (36 loc) • 1.44 kB
JSX
import React from 'react';
import { observer } from 'mobx-react';
import { computed, observable, action } from 'mobx';
export default class Notifications extends React.Component {
/**
* Errors are always added, never removed; to hide errors, just update this.hiddenErrorCounter to
* match current amount of errors
*/
hiddenErrorCounter = 0;
hideErrors() {
this.hiddenErrorCounter = this.props.errors.length;
}
get showErrors() {
return this.props.errors.length > this.hiddenErrorCounter;
}
render() {
return (
<div className={ `notification-container ${this.showErrors ? 'notification-container--active' : ''}` }>
<div className="notification">
<div className="notification__error-icon">
<button className="notification__link button button--close" onClick={ () => this.hideErrors() }>
×
</button>
</div>
<div className="notification__message message">
<h2>Oops, something went wrong!</h2>
{ this.props.errors.map(err => (
<p key={ err.message }>{ err.message }</p>
))}
</div>
</div>
</div>
);
}
}