Newer
Older
import loginAPI from '@/api/loginAPI.js';
import { ErrorService } from '@/services/error-service.js';
/**************** STATE *******************/
const state = {
userData: null,
userError: null,
error: null,
success: null
};
/**************** GETTERS *****************/
const getters = {
};
/*************** MUTATIONS ****************/
const mutations = {
state.userData = payload;
},
if (error) {
ErrorService.onError(error);
} else {
state.userError = error;
}
},
state.error = null;
state.success = payload.message;
},
};
/**************** ACTIONS *****************/
const actions = {
GET_USER_DETAIL: async ({ commit }) => {
try {
const resp = await loginAPI.getUserDetail();
if (resp) {
commit('SET_ERROR', null);
commit('SET_USER_DETAIL', resp);
}
} catch (error) {
commit('SET_ERROR', error.response);
UPDATE_USER_DETAIL: async ({ commit }, data) => {
try {
const resp = await loginAPI.updateUserDetail(data);
if (resp) {
commit('SET_ERROR', null);
commit('SET_SUCCESS', {
response: resp,
commit('SET_SUCCESS', {
response: null,
message: null
});
commit('SET_ERROR', error.response);
throw new Error(error);
}