Decouple api/accounts into a separate module

This commit is contained in:
SleepWalker 2016-05-01 13:28:54 +03:00
parent 428043f9a4
commit 6f54971a16
2 changed files with 22 additions and 3 deletions

View File

@ -1,4 +1,5 @@
import request from 'services/request';
import accounts from 'services/api/accounts';
export const UPDATE = 'USER_UPDATE';
/**
@ -26,7 +27,7 @@ export function logout() {
export function fetchUserData() {
return (dispatch) =>
request.get('/api/accounts/current')
accounts.current()
.then((resp) => {
dispatch(updateUser(resp));
})
@ -51,8 +52,7 @@ export function changePassword({
logoutAll = true,
}) {
return (dispatch) =>
request.post(
'/api/accounts/change-password',
accounts.changePassword(
{password, newPassword, newRePassword, logoutAll}
)
.then((resp) => {

View File

@ -0,0 +1,19 @@
import request from 'services/request';
export default {
current() {
return request.get('/api/accounts/current');
},
changePassword({
password = '',
newPassword = '',
newRePassword = '',
logoutAll = true
}) {
return request.post(
'/api/accounts/change-password',
{password, newPassword, newRePassword, logoutAll}
);
}
};