Skip to content
Snippets Groups Projects
Commit 0c3322c2 authored by Aulia  Adila's avatar Aulia Adila
Browse files

get name to header done

parent 758c1fca
Branches issue-19-tambah-edit-departemen
Tags
2 merge requests!30Main,!25Merge - Issue 14 ubah password
......@@ -29,11 +29,13 @@
<div
class="d-flex flex-row-reverse justify-content-start align-items-center illustration"
>
<i
class="icon ion-ios-person-outline text-red"
style="font-size: 65px"
></i>
<h2 class="text-red" style="text-align: right">Hello, username</h2>
<button @click="showModal()" class="profile-btn">
<i
class="icon ion-ios-person-outline text-red"
style="font-size: 65px"
></i>
</button>
<Name :name="this.name"/>
</div>
</div>
</div>
......@@ -41,20 +43,70 @@
<hr style="border: 1px solid red" />
</div>
<Modal class="profile-modal"
v-show="isModalVisible"
@close="closeModal"
>
<template v-slot:header>Menu Pilihan</template>
<template v-slot:body>
<!-- warna biru, link ke halaman profil -->
<button @click="toProfile">Lihat Profil</button>
<!-- warna merah -->
<button @click="toLogout">Keluar</button>
</template>
</Modal>
</template>
<script>
import Modal from "../components/modal";
import Name from "../components/name";
import { HTTP } from '../http-common'
export default {
name: "Header",
components: {
Modal,
Name
},
//props:{ name: String },
data() {
return {
nav_active: true,
isModalVisible: false,
users:[],
name:"",
};
},
methods: {
onclick() {
this.nav_active = !this.nav_active;
},
showModal(){
this.isModalVisible = true;
},
closeModal(){
this.isModalVisible = false;
//console.log(this.isModalVisible)
},
toProfile(){
console.log("profile")
},
toLogout(){
console.log("logout")
},
getProfile(){
HTTP.get("users/profile").then((res)=>{
if (res.data.success == true){
//console.log(res.data.data.profile)
this.profile = res.data.data.profile
this.name = res.data.data.profile.name
//console.log(this.name)
}})
}
},
mounted(){
this.getProfile()
},
};
</script>
......@@ -75,4 +127,14 @@ export default {
.logo{
width: 100px;
}
.profile-btn{
text-decoration: none;
border: none;
background-color: transparent;
}
/* butuh buat akses class di dalem class modal */
/* .profile-modal{
width: 100px;
height: 100px;
} */
</style>
<template>
<h2 class="text-red" style="text-align: right">Hello, {{name}}</h2>
</template>
<script>
export default {
name: "Name",
props:{name: String},
};
</script>
\ No newline at end of file
import axios from 'axios';
const token = localStorage.getItem('token')
export const HTTP = axios.create({
baseURL: `http://localhost:8000/api/`,
// headers: {
// Authorization: 'Bearer {token}'
// }
baseURL: `http://simkpi-backend.herokuapp.com/api/`,
headers: {
Accept: 'application/json',
Authorization: `Bearer ${token}`
}
})
......@@ -108,8 +108,9 @@ export default {
password: this.password,
})
.then((response) => {
localStorage.setItem("token", response.data.token)
if (response.data.success) {
this.$router.push({ name: "Home" });
this.$router.push({ name: "User" });
}
})
.catch(() => alert("username atau password salah"));
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment