2017-12-18 23:29:26 +00:00
|
|
|
import { closeNotification, Notification, TCloseNotification } from 'actions/notifications';
|
2017-09-25 02:06:28 +00:00
|
|
|
import React from 'react';
|
|
|
|
import { connect } from 'react-redux';
|
2017-11-07 06:20:19 +00:00
|
|
|
import { TransitionGroup, CSSTransition } from 'react-transition-group';
|
2017-09-25 02:06:28 +00:00
|
|
|
import NotificationRow from './NotificationRow';
|
|
|
|
import './Notifications.scss';
|
2017-12-19 22:46:34 +00:00
|
|
|
import { AppState } from 'reducers';
|
2017-09-25 02:06:28 +00:00
|
|
|
|
|
|
|
interface Props {
|
|
|
|
notifications: Notification[];
|
|
|
|
closeNotification: TCloseNotification;
|
|
|
|
}
|
2017-11-07 06:20:19 +00:00
|
|
|
|
2017-09-25 02:06:28 +00:00
|
|
|
export class Notifications extends React.Component<Props, {}> {
|
|
|
|
public render() {
|
|
|
|
return (
|
2017-11-07 06:20:19 +00:00
|
|
|
<TransitionGroup className="Notifications">
|
|
|
|
{this.props.notifications.map(n => {
|
|
|
|
return (
|
2018-01-01 03:13:54 +00:00
|
|
|
<CSSTransition classNames="NotificationAnimation" timeout={500} key={n.id}>
|
2017-12-18 23:29:26 +00:00
|
|
|
<NotificationRow notification={n} onClose={this.props.closeNotification} />
|
2018-01-01 03:13:54 +00:00
|
|
|
</CSSTransition>
|
2017-11-07 06:20:19 +00:00
|
|
|
);
|
|
|
|
})}
|
|
|
|
</TransitionGroup>
|
2017-09-25 02:06:28 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-19 22:46:34 +00:00
|
|
|
const mapStateToProps = (state: AppState) => ({
|
2017-09-25 02:06:28 +00:00
|
|
|
notifications: state.notifications
|
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, { closeNotification })(Notifications);
|