mirror of
https://github.com/wassname/talk.git
synced 2026-07-04 06:44:54 +08:00
0b7432b75e
Conflicts: client/coral-sign-in/components/FakeComment.js client/coral-sign-in/components/UserBox.js
20 lines
739 B
JavaScript
20 lines
739 B
JavaScript
import {addNotification} from '../actions/notification';
|
|
import coralApi from '../helpers/request';
|
|
import * as actions from '../constants/auth';
|
|
|
|
import t from 'coral-framework/services/i18n';
|
|
|
|
const editUsernameFailure = (error) => ({type: actions.EDIT_USERNAME_FAILURE, error});
|
|
const editUsernameSuccess = () => ({type: actions.EDIT_USERNAME_SUCCESS});
|
|
|
|
export const editName = (username) => (dispatch) => {
|
|
return coralApi('/account/username', {method: 'PUT', body: {username}})
|
|
.then(() => {
|
|
dispatch(editUsernameSuccess());
|
|
dispatch(addNotification('success', t('framework.success_name_update')));
|
|
})
|
|
.catch((error) => {
|
|
dispatch(editUsernameFailure(t(`error.${error.translation_key}`)));
|
|
});
|
|
};
|