mirror of
https://github.com/plankanban/planka.git
synced 2025-12-26 17:25:03 +03:00
Add username to user
This commit is contained in:
@@ -20,6 +20,9 @@ import {
|
||||
updateUserPasswordSucceeded,
|
||||
updateUserRequested,
|
||||
updateUserSucceeded,
|
||||
updateUserUsernameFailed,
|
||||
updateUserUsernameRequested,
|
||||
updateUserUsernameSucceeded,
|
||||
uploadUserAvatarFailed,
|
||||
uploadUserAvatarRequested,
|
||||
uploadUserAvatarSucceeded,
|
||||
@@ -146,6 +149,30 @@ export function* updateUserPasswordRequest(id, data) {
|
||||
}
|
||||
}
|
||||
|
||||
export function* updateUserUsernameRequest(id, data) {
|
||||
yield put(updateUserUsernameRequested(id, data));
|
||||
|
||||
try {
|
||||
const { item } = yield call(request, api.updateUserUsername, id, data);
|
||||
|
||||
const action = updateUserUsernameSucceeded(id, item);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
payload: action.payload,
|
||||
};
|
||||
} catch (error) {
|
||||
const action = updateUserUsernameFailed(id, error);
|
||||
yield put(action);
|
||||
|
||||
return {
|
||||
success: false,
|
||||
payload: action.payload,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export function* uploadUserAvatarRequest(id, file) {
|
||||
yield put(uploadUserAvatarRequested(id));
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
updateUserEmailRequest,
|
||||
updateUserPasswordRequest,
|
||||
updateUserRequest,
|
||||
updateUserUsernameRequest,
|
||||
uploadUserAvatarRequest,
|
||||
} from '../requests';
|
||||
import { currentUserIdSelector, pathSelector } from '../../../selectors';
|
||||
@@ -17,6 +18,7 @@ import {
|
||||
clearUserCreateError,
|
||||
clearUserEmailUpdateError,
|
||||
clearUserPasswordUpdateError,
|
||||
clearUserUsernameUpdateError,
|
||||
createUser,
|
||||
deleteUser,
|
||||
updateUser,
|
||||
@@ -84,6 +86,26 @@ export function* clearCurrentUserPasswordUpdateErrorService() {
|
||||
yield call(clearUserPasswordUpdateErrorService, id);
|
||||
}
|
||||
|
||||
export function* updateUserUsernameService(id, data) {
|
||||
yield call(updateUserUsernameRequest, id, data);
|
||||
}
|
||||
|
||||
export function* updateCurrentUserUsernameService(data) {
|
||||
const id = yield select(currentUserIdSelector);
|
||||
|
||||
yield call(updateUserUsernameService, id, data);
|
||||
}
|
||||
|
||||
export function* clearUserUsernameUpdateErrorService(id) {
|
||||
yield put(clearUserUsernameUpdateError(id));
|
||||
}
|
||||
|
||||
export function* clearCurrentUserUsernameUpdateErrorService() {
|
||||
const id = yield select(currentUserIdSelector);
|
||||
|
||||
yield call(clearUserUsernameUpdateErrorService, id);
|
||||
}
|
||||
|
||||
export function* uploadUserAvatarService(id, file) {
|
||||
yield call(uploadUserAvatarRequest, id, file);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
addUserToFilterInCurrentBoardService,
|
||||
clearCurrentUserEmailUpdateErrorService,
|
||||
clearCurrentUserPasswordUpdateErrorService,
|
||||
clearCurrentUserUsernameUpdateErrorService,
|
||||
clearUserCreateErrorService,
|
||||
createUserService,
|
||||
deleteUserService,
|
||||
@@ -16,6 +17,7 @@ import {
|
||||
updateCurrentUserEmailService,
|
||||
updateCurrentUserPasswordService,
|
||||
updateCurrentUserService,
|
||||
updateCurrentUserUsernameService,
|
||||
uploadCurrentUserAvatarService,
|
||||
} from '../services';
|
||||
import EntryActionTypes from '../../../constants/EntryActionTypes';
|
||||
@@ -42,6 +44,12 @@ export default function* () {
|
||||
takeLatest(EntryActionTypes.CURRENT_USER_PASSWORD_UPDATE_ERROR_CLEAR, () =>
|
||||
clearCurrentUserPasswordUpdateErrorService(),
|
||||
),
|
||||
takeLatest(EntryActionTypes.CURRENT_USER_USERNAME_UPDATE, ({ payload: { data } }) =>
|
||||
updateCurrentUserUsernameService(data),
|
||||
),
|
||||
takeLatest(EntryActionTypes.CURRENT_USER_USERNAME_UPDATE_ERROR_CLEAR, () =>
|
||||
clearCurrentUserUsernameUpdateErrorService(),
|
||||
),
|
||||
takeLatest(EntryActionTypes.CURRENT_USER_AVATAR_UPLOAD, ({ payload: { file } }) =>
|
||||
uploadCurrentUserAvatarService(file),
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user