Add email and password change functionality for a current user, remove deep compare hooks
This commit is contained in:
@@ -4,7 +4,7 @@ import { connect } from 'react-redux';
|
||||
import { closeModal, createProject } from '../actions/entry';
|
||||
import AddProjectModal from '../components/AddProjectModal';
|
||||
|
||||
const mapStateToProps = ({ project: { data: defaultData, isSubmitting } }) => ({
|
||||
const mapStateToProps = ({ projectCreateForm: { data: defaultData, isSubmitting } }) => ({
|
||||
defaultData,
|
||||
isSubmitting,
|
||||
});
|
||||
|
||||
@@ -1,36 +1,19 @@
|
||||
import { bindActionCreators } from 'redux';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { clearUserCreationError, createUser } from '../actions/entry';
|
||||
import { clearUserCreateError, createUser } from '../actions/entry';
|
||||
import AddUserPopup from '../components/AddUserPopup';
|
||||
|
||||
const mapStateToProps = ({ user: { data: defaultData, isSubmitting, error: externalError } }) => {
|
||||
let error;
|
||||
|
||||
if (externalError) {
|
||||
if (externalError.message === 'User is already exist') {
|
||||
error = {
|
||||
message: 'userIsAlreadyExist',
|
||||
};
|
||||
} else {
|
||||
error = {
|
||||
type: 'warning',
|
||||
message: 'unknownError',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
defaultData,
|
||||
isSubmitting,
|
||||
error,
|
||||
};
|
||||
};
|
||||
const mapStateToProps = ({ userCreateForm: { data: defaultData, isSubmitting, error } }) => ({
|
||||
defaultData,
|
||||
isSubmitting,
|
||||
error,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => bindActionCreators(
|
||||
{
|
||||
onCreate: createUser,
|
||||
onMessageDismiss: clearUserCreationError,
|
||||
onMessageDismiss: clearUserCreateError,
|
||||
},
|
||||
dispatch,
|
||||
);
|
||||
|
||||
@@ -3,10 +3,14 @@ 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';
|
||||
@@ -24,10 +28,14 @@ const mapStateToProps = (state) => {
|
||||
|
||||
const mapDispatchToProps = (dispatch) => bindActionCreators(
|
||||
{
|
||||
onUsers: openUsersModal, // TODO: rename
|
||||
onNotificationDelete: deleteNotification,
|
||||
onUserUpdate: updateCurrentUser,
|
||||
onUserAvatarUpload: uploadCurrentUserAvatar,
|
||||
onNotificationDelete: deleteNotification,
|
||||
onUsers: openUsersModal, // TODO: rename
|
||||
onUserEmailUpdate: updateCurrentUserEmail,
|
||||
onUserEmailUpdateMessageDismiss: clearCurrentUserEmailUpdateError,
|
||||
onUserPasswordUpdate: updateCurrentUserPassword,
|
||||
onUserPasswordUpdateMessageDismiss: clearCurrentUserPasswordUpdateError,
|
||||
onLogout: logout,
|
||||
},
|
||||
dispatch,
|
||||
|
||||
@@ -1,59 +1,19 @@
|
||||
import { bindActionCreators } from 'redux';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
import { authenticate, clearAuthenticationError } from '../actions/entry';
|
||||
import { authenticate, clearAuthenticateError } from '../actions/entry';
|
||||
import Login from '../components/Login';
|
||||
|
||||
const mapStateToProps = ({ login: { data: defaultData, isSubmitting, error: externalError } }) => {
|
||||
let error;
|
||||
|
||||
if (externalError) {
|
||||
switch (externalError.message) {
|
||||
case 'Email does not exist':
|
||||
error = {
|
||||
message: 'emailDoesNotExist',
|
||||
};
|
||||
|
||||
break;
|
||||
case 'Password is not valid':
|
||||
error = {
|
||||
message: 'invalidPassword',
|
||||
};
|
||||
|
||||
break;
|
||||
case 'Failed to fetch':
|
||||
error = {
|
||||
type: 'warning',
|
||||
message: 'noInternetConnection',
|
||||
};
|
||||
|
||||
break;
|
||||
case 'Network request failed':
|
||||
error = {
|
||||
type: 'warning',
|
||||
message: 'serverConnectionFailed',
|
||||
};
|
||||
|
||||
break;
|
||||
default:
|
||||
error = {
|
||||
type: 'warning',
|
||||
message: 'unknownError',
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
defaultData,
|
||||
isSubmitting,
|
||||
error,
|
||||
};
|
||||
};
|
||||
const mapStateToProps = ({ authenticateForm: { data: defaultData, isSubmitting, error } }) => ({
|
||||
defaultData,
|
||||
isSubmitting,
|
||||
error,
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => bindActionCreators(
|
||||
{
|
||||
onAuthenticate: authenticate,
|
||||
onMessageDismiss: clearAuthenticationError,
|
||||
onMessageDismiss: clearAuthenticateError,
|
||||
},
|
||||
dispatch,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user