diff --git a/loginv3/components/dekstop.vue b/loginv3/components/dekstop.vue
index 7ae8faf..743435b 100644
--- a/loginv3/components/dekstop.vue
+++ b/loginv3/components/dekstop.vue
@@ -37,15 +37,17 @@
+
+
+
{{ $t("message.login") }}
-
+
+
@@ -111,8 +116,11 @@
},
computed: {
// Akses state dari store
- count() {
- return this.$store.state.login.count;
+ loading() {
+ return this.$store.state.login.loading;
+ },
+ alert() {
+ return this.$store.state.login.alert;
},
email: {
get() {
@@ -133,6 +141,9 @@
},
methods: {
// Dispatch action ke store
+ login() {
+ this.$store.dispatch("login/login");
+ },
increment() {
this.$store.dispatch("increment");
},
diff --git a/loginv3/components/login.vue b/loginv3/components/login.vue
index 099a549..46ed9a5 100644
--- a/loginv3/components/login.vue
+++ b/loginv3/components/login.vue
@@ -18,6 +18,7 @@
"mobile-component": MobileComponent,
"dekstop-component": DekstopComponent,
},
+ mounted() {},
data() {
return {
visible: false,
diff --git a/loginv3/components/mobile.vue b/loginv3/components/mobile.vue
index 4b29636..682e9fd 100644
--- a/loginv3/components/mobile.vue
+++ b/loginv3/components/mobile.vue
@@ -27,12 +27,11 @@
{{ $t("message.login") }}
-
+
@@ -96,8 +95,11 @@
},
computed: {
// Akses state dari store
- count() {
- return this.$store.state.login.count;
+ loading() {
+ return this.$store.state.login.loading;
+ },
+ alert() {
+ return this.$store.state.login.alert;
},
email: {
get() {
@@ -118,6 +120,9 @@
},
methods: {
// Dispatch action ke store
+ login() {
+ this.$store.dispatch("login/login");
+ },
increment() {
this.$store.dispatch("increment");
},
diff --git a/loginv3/index.html b/loginv3/index.html
index ae2d86a..9431d87 100644
--- a/loginv3/index.html
+++ b/loginv3/index.html
@@ -28,6 +28,7 @@
+
@@ -36,11 +37,12 @@
const { loadModule } = window["vue3-sfc-loader"];
import login from "./modules/login.js";
- const store = Vuex.createStore({
- modules: {
- login: login,
- },
- });
+ import system from "../globalstore/globalstore.js";
+
+ // if (one_token()) {
+ // let usr = JSON.parse(localStorage.getItem("user"));
+ // location.replace("/" + usr.M_UserGroupDashboard);
+ // }
const options = {
moduleCache: {
vue: Vue,
@@ -69,7 +71,13 @@
fallbackLocale: "en", // Set fallback locale
messages, // Set locale messages
});
-
+ window.i18n = i18n;
+ const store = Vuex.createStore({
+ modules: {
+ system: system,
+ login: login,
+ },
+ });
// Vue App
const app = Vue.createApp({
data() {
diff --git a/loginv3/language.js b/loginv3/language.js
index 8d16a8f..b3b6368 100644
--- a/loginv3/language.js
+++ b/loginv3/language.js
@@ -9,6 +9,9 @@ var CustomMessages = {
forgotPassword: "Forgot password?",
placeholderEmail: "Enter your email",
placeholderPassword: "Enter your password",
+ msgInfo: 'Enter the registered account',
+ errorQuery: "Error get data",
+ invalid: "Invalid username / password"
},
},
id: {
@@ -21,6 +24,9 @@ var CustomMessages = {
forgotPassword: "Lupa kata sandi?",
placeholderEmail: "Isikan email anda",
placeholderPassword: "Isikan kata sandi anda",
+ msgInfo: "Masukkan akun terdaftar",
+ errorQuery: "Gagal mendapatkan data",
+ invalid: "Nama pengguna / kata sandi tidak valid"
},
},
};
\ No newline at end of file
diff --git a/loginv3/modules/login.js b/loginv3/modules/login.js
index 678fa32..6fb3a3b 100644
--- a/loginv3/modules/login.js
+++ b/loginv3/modules/login.js
@@ -1,6 +1,8 @@
// const URL = "/westone-api/v1/system/auth";
-const URL = "https://devcpone.aplikasi.web.id/one-api/v1/system/auth/";
+
+const URL = "https://devcpone.aplikasi.web.id/westone-api/v1/system/auth/";
+
const store = {
namespaced: true,
state() {
@@ -9,7 +11,15 @@ const store = {
data: null,
email: "",
password: "",
- dialog_success: false
+ dialog_success: false,
+ loading: false,
+ errorMessage: "",
+ iin: window.i18n.global.t('message.login'),
+ alert: {
+ show: false,
+ type: 'info',
+ message: window.i18n.global.t('message.msgInfo')
+ }
};
},
mutations: {
@@ -30,6 +40,12 @@ const store = {
},
setDialogSuccess(state, data) {
state.dialog_success = data;
+ },
+ setLoading(state, data) {
+ state.loading = data;
+ },
+ setAlert(state, data) {
+ state.alert = data;
}
},
actions: {
@@ -39,7 +55,50 @@ const store = {
decrement({ commit }) {
commit('decrement');
},
+ async login({ state, commit }) {
+ commit('setLoading', true);
+ let alert = {
+ show: false,
+ type: 'info',
+ message: window.i18n.global.t('message.msgInfo')
+ }
+ let params = {
+ username: state.email,
+ password: state.password
+ };
+ console.log(params);
+ try {
+ const response = await axios.post(URL + '/login', params);
+ console.log(response.data)
+ if (response.data.status != 'OK') {
+ commit('setLoading', false);
+ if (response.data.message !== 'Invalid') {
+ alert.message = window.i18n.global.t('message.errorQuery');
+ } else {
+ alert.message = window.i18n.global.t('message.invalid');
+ }
+ alert.type = "error"
+ } else {
+ commit('setLoading', false);
+ commit('setData', response.data.data);
+ localStorage.setItem("token", response.data.data.token)
+ localStorage.setItem('user', JSON.stringify(response.data.data.user))
+ //console.log(localStorage.getItem("token"))
+ // if (data.user.is_courier === 'Y' && window.innerWidth < 600)
+ // window.location = "/one-ui/test/vuex/one-courier-mobile/";
+ // else
+ // window.location = "/" + response.data.data.user.M_UserGroupDashboard;
+
+ }
+ commit('setAlert', alert)
+ } catch (error) {
+ console.log(error)
+ commit('setLoading', false);
+
+ }
+ },
async loginState({ state, commit }) {
+ commit('setLoading', true);
const params = {
email: state.email,
password: state.pasword
@@ -47,8 +106,16 @@ const store = {
try {
const response = await axios.post(URL + '/login', params);
- commit('setData', response.data);
+ if (response.status != 'OK') {
+ commit('setLoading', false);
+
+ } else {
+ commit('setLoading', false);
+ commit('setData', response.data);
+
+ }
} catch (error) {
+ commit('setLoading', false);
commit('setError', error);
}
},