Added logout button
This commit is contained in:
@@ -21,10 +21,21 @@
|
||||
<button class="btn bg-blue-700 btn-sm">Create Customer</button>
|
||||
</router-link>
|
||||
|
||||
<div v-if="employee.id">
|
||||
<router-link :to="{ name: 'employeeProfile', params: { id: employee.id } }">
|
||||
<div class="">{{ user.user_name }}</div>
|
||||
</router-link>
|
||||
<div v-if="employee.id" class="relative ">
|
||||
<button @click="toggleDropdown" class="flex items-center gap-2 ">
|
||||
<div>{{ user.user_name }}</div>
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path>
|
||||
</svg>
|
||||
</button>
|
||||
<div v-if="isDropdownOpen" class="absolute right-0 mt-2 w-48 bg-gray-800 border border-gray-300 rounded shadow-lg z-10">
|
||||
<router-link :to="{ name: 'employeeProfile', params: { id: employee.id } }" class="block px-4 py-2 text-white hover:bg-gray-700" @click="closeDropdown">
|
||||
User Profile
|
||||
</router-link>
|
||||
<button @click="logout" class="block w-full text-left px-4 py-2 text-white hover:bg-gray-700">
|
||||
Logout
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -62,6 +73,7 @@ export default defineComponent({
|
||||
user_name: '',
|
||||
},
|
||||
company_id: 0,
|
||||
isDropdownOpen: false,
|
||||
company: {
|
||||
creation_date: "",
|
||||
account_prefix: "",
|
||||
@@ -239,12 +251,21 @@ export default defineComponent({
|
||||
.then((response: any) => {
|
||||
this.company = response.data;
|
||||
this.company_id = import.meta.env.VITE_COMPANY_ID
|
||||
|
||||
|
||||
})
|
||||
},
|
||||
toggleDropdown() {
|
||||
this.isDropdownOpen = !this.isDropdownOpen;
|
||||
},
|
||||
closeDropdown() {
|
||||
this.isDropdownOpen = false;
|
||||
},
|
||||
logout() {
|
||||
localStorage.removeItem('auth_user');
|
||||
localStorage.removeItem('auth_token');
|
||||
this.$router.push('/login');
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped></style>
|
||||
<style scoped></style>
|
||||
|
||||
Reference in New Issue
Block a user