Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<template>
<nav class="flex items-center justify-between bg-white h-20 shadow-2xl">
<div class="logo">
<img class="ml-4 cursor-pointer h-16 " src="../assets/logo3.svg" alt="BoCo logo" @click="$router.push('/')"/>
</div>
<ul class="flex">
<li>
<div class="text-black mr-4 bg-gray-100 p-1 hover:bg-gray-600 transition-all rounded" @click="loadMessages">Meldinger</div>
</li>
<li>
<div class="text-black mr-4 bg-gray-100 p-1 hover:bg-gray-600 transition-all rounded" @click="loadNotifications">Varsler</div>
</li>
<li>
<div class="text-black mr-4 bg-gray-100 p-1 hover:bg-gray-600 transition-all rounded" @click="loadProfile">Profil</div>
</li>
</ul>
</nav>
</template>
<script>
import {parseUserFromToken} from "@/utils/token-utils";
export default {
name: "NavBar.vue",
methods: {
async loadMessages(){
if(this.$store.state.user.token !== null){
await this.$router.push("/messages")
}
else {
await this.$router.push("/login");
}
},
async loadNotifications(){
if(this.$store.state.user.token !== null){
await this.$router.push("/notifications")
}
else {
await this.$router.push("/login");
}
},
async loadProfile() {
if(this.$store.state.user.token !== null){
let user = parseUserFromToken(this.$store.state.user.token);
console.log(user);
let id = user.accountId;
console.log(id);
await this.$router.push("/profile/" + id);
}
else {
await this.$router.push("/login");
}
}
}
}
</script>
<style scoped>
</style>