2020-04-08 21:12:58 +05:00
|
|
|
import { bindActionCreators } from 'redux';
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
|
|
|
import { currentUserSelector } from '../selectors';
|
|
|
|
import {
|
|
|
|
clearCurrentUserEmailUpdateError,
|
|
|
|
clearCurrentUserPasswordUpdateError,
|
|
|
|
clearCurrentUserUsernameUpdateError,
|
|
|
|
closeModal,
|
|
|
|
updateCurrentUser,
|
|
|
|
updateCurrentUserEmail,
|
|
|
|
updateCurrentUserPassword,
|
|
|
|
updateCurrentUserUsername,
|
|
|
|
uploadCurrentUserAvatar,
|
|
|
|
} from '../actions/entry';
|
|
|
|
import UserSettingsModal from '../components/UserSettingsModal';
|
|
|
|
|
|
|
|
const mapStateToProps = (state) => {
|
|
|
|
const {
|
|
|
|
email,
|
|
|
|
name,
|
|
|
|
username,
|
|
|
|
avatar,
|
2020-04-09 18:27:28 +05:00
|
|
|
phone,
|
|
|
|
organization,
|
2020-04-08 21:12:58 +05:00
|
|
|
isAvatarUploading,
|
|
|
|
emailUpdateForm,
|
|
|
|
passwordUpdateForm,
|
|
|
|
usernameUpdateForm,
|
|
|
|
} = currentUserSelector(state);
|
|
|
|
|
|
|
|
return {
|
|
|
|
email,
|
|
|
|
name,
|
|
|
|
username,
|
|
|
|
avatar,
|
2020-04-09 18:27:28 +05:00
|
|
|
phone,
|
|
|
|
organization,
|
2020-04-08 21:12:58 +05:00
|
|
|
isAvatarUploading,
|
|
|
|
emailUpdateForm,
|
|
|
|
passwordUpdateForm,
|
|
|
|
usernameUpdateForm,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) =>
|
|
|
|
bindActionCreators(
|
|
|
|
{
|
|
|
|
onUpdate: updateCurrentUser,
|
|
|
|
onAvatarUpload: uploadCurrentUserAvatar,
|
|
|
|
onUsernameUpdate: updateCurrentUserUsername,
|
|
|
|
onUsernameUpdateMessageDismiss: clearCurrentUserUsernameUpdateError,
|
|
|
|
onEmailUpdate: updateCurrentUserEmail,
|
|
|
|
onEmailUpdateMessageDismiss: clearCurrentUserEmailUpdateError,
|
|
|
|
onPasswordUpdate: updateCurrentUserPassword,
|
|
|
|
onPasswordUpdateMessageDismiss: clearCurrentUserPasswordUpdateError,
|
|
|
|
onClose: closeModal,
|
|
|
|
},
|
|
|
|
dispatch,
|
|
|
|
);
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(UserSettingsModal);
|