mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-15 20:55:56 +05:30
Decouple api/accounts into a separate module
This commit is contained in:
parent
428043f9a4
commit
6f54971a16
@ -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) => {
|
||||
|
19
src/services/api/accounts.js
Normal file
19
src/services/api/accounts.js
Normal 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}
|
||||
);
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user