Add email and password change functionality for a current user, remove deep compare hooks
This commit is contained in:
@@ -11,7 +11,13 @@ import {
|
||||
fetchCurrentUserFailed,
|
||||
fetchCurrentUserRequested,
|
||||
fetchCurrentUserSucceeded,
|
||||
updateUserEmailFailed,
|
||||
updateUserEmailRequested,
|
||||
updateUserEmailSucceeded,
|
||||
updateUserFailed,
|
||||
updateUserPasswordFailed,
|
||||
updateUserPasswordRequested,
|
||||
updateUserPasswordSucceeded,
|
||||
updateUserRequested,
|
||||
updateUserSucceeded,
|
||||
uploadUserAvatarFailed,
|
||||
@@ -92,13 +98,61 @@ export function* updateUserRequest(id, data) {
|
||||
}
|
||||
}
|
||||
|
||||
export function* updateUserEmailRequest(id, data) {
|
||||
yield put(updateUserEmailRequested(id, data));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.updateUserEmail, id, data);
|
||||
|
||||
const action = updateUserEmailSucceeded(id, item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = updateUserEmailFailed(id, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* updateUserPasswordRequest(id, data) {
|
||||
yield put(updateUserPasswordRequested(id, data));
|
||||
|
||||
try {
|
||||
yield call(request, api.updateUserPassword, id, data);
|
||||
|
||||
const action = updateUserPasswordSucceeded(id);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = updateUserPasswordFailed(id, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* uploadUserAvatarRequest(id, file) {
|
||||
yield put(uploadUserAvatarRequested(id));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.uploadUserAvatar, id, file);
|
||||
|
||||
const action = uploadUserAvatarSucceeded(item);
|
||||
const action = uploadUserAvatarSucceeded(id, item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
|
||||
@@ -5,6 +5,8 @@ import {
|
||||
createUserRequest,
|
||||
deleteCardMembershipRequest,
|
||||
deleteUserRequest,
|
||||
updateUserEmailRequest,
|
||||
updateUserPasswordRequest,
|
||||
updateUserRequest,
|
||||
uploadUserAvatarRequest,
|
||||
} from '../requests';
|
||||
@@ -12,7 +14,9 @@ import { currentUserIdSelector, pathSelector } from '../../../selectors';
|
||||
import {
|
||||
addUserToBoardFilter,
|
||||
addUserToCard,
|
||||
clearUserCreationError,
|
||||
clearUserCreateError,
|
||||
clearUserEmailUpdateError,
|
||||
clearUserPasswordUpdateError,
|
||||
createUser,
|
||||
deleteUser,
|
||||
updateUser,
|
||||
@@ -25,8 +29,8 @@ export function* createUserService(data) {
|
||||
yield call(createUserRequest, data);
|
||||
}
|
||||
|
||||
export function* clearUserCreationErrorService() {
|
||||
yield put(clearUserCreationError());
|
||||
export function* clearUserCreateErrorService() {
|
||||
yield put(clearUserCreateError());
|
||||
}
|
||||
|
||||
export function* updateUserService(id, data) {
|
||||
@@ -40,10 +44,54 @@ export function* updateCurrentUserService(data) {
|
||||
yield call(updateUserService, id, data);
|
||||
}
|
||||
|
||||
export function* updateUserEmailService(id, data) {
|
||||
yield call(updateUserEmailRequest, id, data);
|
||||
}
|
||||
|
||||
export function* updateCurrentUserEmailService(data) {
|
||||
const id = yield select(currentUserIdSelector);
|
||||
|
||||
yield call(updateUserEmailService, id, data);
|
||||
}
|
||||
|
||||
export function* clearUserEmailUpdateErrorService(id) {
|
||||
yield put(clearUserEmailUpdateError(id));
|
||||
}
|
||||
|
||||
export function* clearCurrentUserEmailUpdateErrorService() {
|
||||
const id = yield select(currentUserIdSelector);
|
||||
|
||||
yield call(clearUserEmailUpdateErrorService, id);
|
||||
}
|
||||
|
||||
export function* updateUserPasswordService(id, data) {
|
||||
yield call(updateUserPasswordRequest, id, data);
|
||||
}
|
||||
|
||||
export function* updateCurrentUserPasswordService(data) {
|
||||
const id = yield select(currentUserIdSelector);
|
||||
|
||||
yield call(updateUserPasswordService, id, data);
|
||||
}
|
||||
|
||||
export function* clearUserPasswordUpdateErrorService(id) {
|
||||
yield put(clearUserPasswordUpdateError(id));
|
||||
}
|
||||
|
||||
export function* clearCurrentUserPasswordUpdateErrorService() {
|
||||
const id = yield select(currentUserIdSelector);
|
||||
|
||||
yield call(clearUserPasswordUpdateErrorService, id);
|
||||
}
|
||||
|
||||
export function* uploadUserAvatarService(id, file) {
|
||||
yield call(uploadUserAvatarRequest, id, file);
|
||||
}
|
||||
|
||||
export function* uploadCurrentUserAvatarService(file) {
|
||||
const id = yield select(currentUserIdSelector);
|
||||
|
||||
yield call(uploadUserAvatarRequest, id, file);
|
||||
yield call(uploadUserAvatarService, id, file);
|
||||
}
|
||||
|
||||
export function* deleteUserService(id) {
|
||||
|
||||
@@ -4,13 +4,17 @@ import {
|
||||
addUserToCardService,
|
||||
addUserToCurrentCardService,
|
||||
addUserToFilterInCurrentBoardService,
|
||||
clearUserCreationErrorService,
|
||||
clearCurrentUserEmailUpdateErrorService,
|
||||
clearCurrentUserPasswordUpdateErrorService,
|
||||
clearUserCreateErrorService,
|
||||
createUserService,
|
||||
deleteUserService,
|
||||
removeUserFromCardService,
|
||||
removeUserFromCurrentCardService,
|
||||
removeUserFromFilterInCurrentBoardService,
|
||||
updateUserService,
|
||||
updateCurrentUserEmailService,
|
||||
updateCurrentUserPasswordService,
|
||||
updateCurrentUserService,
|
||||
uploadCurrentUserAvatarService,
|
||||
} from '../services';
|
||||
@@ -19,7 +23,7 @@ import EntryActionTypes from '../../../constants/EntryActionTypes';
|
||||
export default function* () {
|
||||
yield all([
|
||||
takeLatest(EntryActionTypes.USER_CREATE, ({ payload: { data } }) => createUserService(data)),
|
||||
takeLatest(EntryActionTypes.USER_CREATION_ERROR_CLEAR, () => clearUserCreationErrorService()),
|
||||
takeLatest(EntryActionTypes.USER_CREATE_ERROR_CLEAR, () => clearUserCreateErrorService()),
|
||||
takeLatest(
|
||||
EntryActionTypes.USER_UPDATE,
|
||||
({ payload: { id, data } }) => updateUserService(id, data),
|
||||
@@ -28,6 +32,22 @@ export default function* () {
|
||||
EntryActionTypes.CURRENT_USER_UPDATE,
|
||||
({ payload: { data } }) => updateCurrentUserService(data),
|
||||
),
|
||||
takeLatest(
|
||||
EntryActionTypes.CURRENT_USER_EMAIL_UPDATE,
|
||||
({ payload: { data } }) => updateCurrentUserEmailService(data),
|
||||
),
|
||||
takeLatest(
|
||||
EntryActionTypes.CURRENT_USER_EMAIL_UPDATE_ERROR_CLEAR,
|
||||
() => clearCurrentUserEmailUpdateErrorService(),
|
||||
),
|
||||
takeLatest(
|
||||
EntryActionTypes.CURRENT_USER_PASSWORD_UPDATE,
|
||||
({ payload: { data } }) => updateCurrentUserPasswordService(data),
|
||||
),
|
||||
takeLatest(
|
||||
EntryActionTypes.CURRENT_USER_PASSWORD_UPDATE_ERROR_CLEAR,
|
||||
() => clearCurrentUserPasswordUpdateErrorService(),
|
||||
),
|
||||
takeLatest(
|
||||
EntryActionTypes.CURRENT_USER_AVATAR_UPLOAD,
|
||||
({ payload: { file } }) => uploadCurrentUserAvatarService(file),
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { call, put } from 'redux-saga/effects';
|
||||
|
||||
import { authenticateRequest } from '../requests';
|
||||
import { authenticate, clearAuthenticationError } from '../../../actions';
|
||||
import { authenticate, clearAuthenticateError } from '../../../actions';
|
||||
|
||||
export function* authenticateService(data) {
|
||||
yield put(authenticate(data));
|
||||
yield call(authenticateRequest, data);
|
||||
}
|
||||
|
||||
export function* clearAuthenticationErrorService() {
|
||||
yield put(clearAuthenticationError());
|
||||
export function* clearAuthenticateErrorService() {
|
||||
yield put(clearAuthenticateError());
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
import { all, takeLatest } from 'redux-saga/effects';
|
||||
|
||||
import { authenticateService, clearAuthenticationErrorService } from '../services';
|
||||
import { authenticateService, clearAuthenticateErrorService } from '../services';
|
||||
import EntryActionTypes from '../../../constants/EntryActionTypes';
|
||||
|
||||
export default function* () {
|
||||
yield all([
|
||||
takeLatest(EntryActionTypes.AUTHENTICATE, ({ payload: { data } }) => authenticateService(data)),
|
||||
takeLatest(
|
||||
EntryActionTypes.AUTHENTICATION_ERROR_CLEAR,
|
||||
() => clearAuthenticationErrorService(),
|
||||
),
|
||||
takeLatest(EntryActionTypes.AUTHENTICATE_ERROR_CLEAR, () => clearAuthenticateErrorService()),
|
||||
]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user