diff --git a/src/components/header.vue b/src/components/header.vue index c952bf54c5c22bd0b8b474c448e1cdc965d4c033..079006c14476e13f92bda033f27dc8145f600743 100644 --- a/src/components/header.vue +++ b/src/components/header.vue @@ -61,16 +61,13 @@ <script> import Modal from "../components/modal"; -//import Name from "../components/name"; import { HTTP } from '../http-common' export default { name: "Header", components: { Modal - // Name }, - // props:{ username: String }, data() { return { nav_active: true, @@ -92,10 +89,8 @@ export default { }, closeModal(){ this.isModalVisible = false; - //console.log(this.isModalVisible) }, toProfile(){ - //console.log("profile") if (this.is_admin){ this.$router.push({ name: "profil-admin", params: { id: this.id }}); } else { @@ -103,38 +98,34 @@ export default { } }, - toLogout(){ + toLogout(e){ + e.preventDefault(); console.log("logout") - //panggil api logout (delete token) - //data user jadi null - //pastiin dia gabisa ke halaman lain lagi + this.$router.push('login') + // var a = localStorage.getItem("token"); + // console.log(a) + // var b = localStorage.removeItem("token"); + // console.log(b) + localStorage.removeItem("token"); + console.log('token removed') }, getProfile(){ HTTP.get("users/profile").then((res)=>{ if (res.data.success == true){ this.is_admin = res.data.data.is_admin if (this.is_admin){ - //console.log(this.is_admin) this.profile_admin = res.data.data this.name = this.profile_admin.username this.id = this.profile_admin.id } else { - //console.log(res.data.data.profile) this.profile_employee = res.data.data.profile this.name = this.profile_employee.name this.user_id = this.profile_employee.user_id } - //console.log(this.name) }}) }, }, - // computed:{ - // getName(){ - // this.username = this.name - // return this.username - // } - // }, mounted(){ this.getProfile(); },