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';
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
notifications: Notification[];
|
|
|
|
closeNotification: TCloseNotification;
|
|
|
|
}
|
2017-11-07 06:20:19 +00:00
|
|
|
|
|
|
|
const Transition = props => (
|
|
|
|
<CSSTransition
|
|
|
|
{...props}
|
|
|
|
classNames="NotificationAnimation"
|
|
|
|
timeout={{ enter: 500, exit: 500 }}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
|
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 (
|
|
|
|
<Transition key={n.id}>
|
2017-12-18 23:29:26 +00:00
|
|
|
<NotificationRow notification={n} onClose={this.props.closeNotification} />
|
2017-11-07 06:20:19 +00:00
|
|
|
</Transition>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</TransitionGroup>
|
2017-09-25 02:06:28 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const mapStateToProps = state => ({
|
|
|
|
notifications: state.notifications
|
|
|
|
});
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, { closeNotification })(Notifications);
|