gab-social/app/javascript/gabsocial/containers/notifications_container.js

29 lines
757 B
JavaScript
Raw Normal View History

2019-07-02 08:10:25 +01:00
import { injectIntl } from 'react-intl';
import { NotificationStack } from 'react-notification';
import { dismissAlert } from '../actions/alerts';
import { getAlerts } from '../selectors';
2019-07-02 08:10:25 +01:00
const mapStateToProps = (state, { intl }) => {
const notifications = getAlerts(state);
notifications.forEach(notification => ['title', 'message'].forEach(key => {
const value = notification[key];
if (typeof value === 'object') {
notification[key] = intl.formatMessage(value);
}
}));
return { notifications };
};
const mapDispatchToProps = (dispatch) => {
return {
onDismiss: alert => {
dispatch(dismissAlert(alert));
},
};
};
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(NotificationStack));