65 lines
1.7 KiB
JavaScript
65 lines
1.7 KiB
JavaScript
|
|
// const URL = "/westone-api/v1/system/auth";
|
|
const URL = "https://devcpone.aplikasi.web.id/one-api/v1/system/auth/";
|
|
const store = {
|
|
namespaced: true,
|
|
state() {
|
|
return {
|
|
count: 0,
|
|
data: null,
|
|
email: "",
|
|
password: "",
|
|
dialog_success: false
|
|
};
|
|
},
|
|
mutations: {
|
|
increment(state) {
|
|
state.count++;
|
|
},
|
|
decrement(state) {
|
|
state.count--;
|
|
},
|
|
setData(state, payload) {
|
|
state.data = payload;
|
|
},
|
|
setEmail(state, data) {
|
|
state.email = data;
|
|
},
|
|
setPassword(state, data) {
|
|
state.password = data;
|
|
},
|
|
setDialogSuccess(state, data) {
|
|
state.dialog_success = data;
|
|
}
|
|
},
|
|
actions: {
|
|
increment({ commit }) {
|
|
commit('increment');
|
|
},
|
|
decrement({ commit }) {
|
|
commit('decrement');
|
|
},
|
|
async loginState({ state, commit }) {
|
|
const params = {
|
|
email: state.email,
|
|
password: state.pasword
|
|
};
|
|
|
|
try {
|
|
const response = await axios.post(URL + '/login', params);
|
|
commit('setData', response.data);
|
|
} catch (error) {
|
|
commit('setError', error);
|
|
}
|
|
},
|
|
async LoginParam({ commit }, params) {
|
|
try {
|
|
const response = await axios.post(URL + '/login', params);
|
|
commit('setData', response.data);
|
|
} catch (error) {
|
|
commit('setError', error);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
export default store |