Files
planka_custom/client/src/containers/HeaderContainer.js
T

46 lines
1.3 KiB
JavaScript
Executable File

import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { currentUserSelector, notificationsForCurrentUserSelector } from '../selectors';
import {
clearCurrentUserEmailUpdateError,
clearCurrentUserPasswordUpdateError,
deleteNotification,
logout,
openUsersModal,
updateCurrentUser,
updateCurrentUserEmail,
updateCurrentUserPassword,
uploadCurrentUserAvatar,
} from '../actions/entry';
import Header from '../components/Header';
const mapStateToProps = state => {
const currentUser = currentUserSelector(state);
const notifications = notificationsForCurrentUserSelector(state);
return {
notifications,
user: currentUser,
isEditable: currentUser.isAdmin,
};
};
const mapDispatchToProps = dispatch =>
bindActionCreators(
{
onUsers: openUsersModal, // TODO: rename
onNotificationDelete: deleteNotification,
onUserUpdate: updateCurrentUser,
onUserAvatarUpload: uploadCurrentUserAvatar,
onUserEmailUpdate: updateCurrentUserEmail,
onUserEmailUpdateMessageDismiss: clearCurrentUserEmailUpdateError,
onUserPasswordUpdate: updateCurrentUserPassword,
onUserPasswordUpdateMessageDismiss: clearCurrentUserPasswordUpdateError,
onLogout: logout,
},
dispatch,
);
export default connect(mapStateToProps, mapDispatchToProps)(Header);