Client: minor refactor (user)

This commit is contained in:
Sam
2018-04-29 17:02:08 +02:00
parent cd90c802b5
commit 1c570ab320
5 changed files with 21 additions and 16 deletions

View File

@ -1,4 +1,4 @@
import mpwoApi from '../mpwoApi'
import mpwoApiUser from '../mwpoApi/user'
import { history } from '../index'
import { generateIds } from '../utils'
@ -48,7 +48,7 @@ export const updateProfileFormData = (target, value) => ({
})
export function getProfile(dispatch) {
return mpwoApi
return mpwoApiUser
.getProfile()
.then(ret => {
if (ret.status === 'success') {
@ -64,7 +64,7 @@ export function getProfile(dispatch) {
export function register(formData) {
return function(dispatch) {
return mpwoApi
return mpwoApiUser
.register(
formData.username,
formData.email,
@ -86,7 +86,7 @@ export function register(formData) {
export function login(formData) {
return function(dispatch) {
return mpwoApi
return mpwoApiUser
.login(formData.email, formData.password)
.then(ret => {
if (ret.status === 'success') {
@ -165,7 +165,7 @@ export function handleProfileFormSubmit(event) {
'Password and password confirmation don\'t match.'
))
} else {
return mpwoApi
return mpwoApiUser
.updateProfile(state.formProfile.formProfile)
.then(ret => {
if (ret.status === 'success') {
@ -189,7 +189,7 @@ export function uploadPicture (event) {
form.append('file', event.target.picture.files[0])
event.target.reset()
return function(dispatch) {
return mpwoApi
return mpwoApiUser
.updatePicture(form)
.then(ret => {
if (ret.status === 'success') {
@ -206,7 +206,7 @@ export function uploadPicture (event) {
export function deletePicture() {
return function(dispatch) {
return mpwoApi
return mpwoApiUser
.deletePicture()
.then(ret => {
if (ret.status === 'success') {