You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.5 KiB
JavaScript
50 lines
1.5 KiB
JavaScript
import { bindActionCreators } from 'redux';
|
|
import { connect } from 'react-redux';
|
|
|
|
import { currentUserSelector, notificationsForCurrentUserSelector } from '../selectors';
|
|
import {
|
|
clearCurrentUserEmailUpdateError,
|
|
clearCurrentUserPasswordUpdateError,
|
|
clearCurrentUserUsernameUpdateError,
|
|
deleteNotification,
|
|
logout,
|
|
openUsersModal,
|
|
updateCurrentUser,
|
|
updateCurrentUserEmail,
|
|
updateCurrentUserPassword,
|
|
updateCurrentUserUsername,
|
|
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,
|
|
onUserUsernameUpdate: updateCurrentUserUsername,
|
|
onUserUsernameUpdateMessageDismiss: clearCurrentUserUsernameUpdateError,
|
|
onUserEmailUpdate: updateCurrentUserEmail,
|
|
onUserEmailUpdateMessageDismiss: clearCurrentUserEmailUpdateError,
|
|
onUserPasswordUpdate: updateCurrentUserPassword,
|
|
onUserPasswordUpdateMessageDismiss: clearCurrentUserPasswordUpdateError,
|
|
onLogout: logout,
|
|
},
|
|
dispatch,
|
|
);
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Header);
|