Skip to content
Snippets Groups Projects
Commit c85b64b8 authored by Titus Netland's avatar Titus Netland
Browse files

Navbar added and navigation upgraded

parent b801e499
No related branches found
No related tags found
1 merge request!23Navbar
<template>
<div>
<NavBar />
<router-view />
</div>
</template>
<script>
import { defineComponent } from "vue";
// Components
import NavBar from "./components/NavBar.vue";
export default defineComponent({
name: "App",
components: {
NavBar,
},
});
</script>
\ No newline at end of file
......@@ -5,6 +5,9 @@
<router-link to="/register" class="m-6">Registrer deg</router-link>
<router-link to="/about" class="m-6">Om BoCo</router-link>
<div @click="logout" class="m-6 cursor-pointer"><p>Logout</p></div>
</div>
</template>
......@@ -13,5 +16,11 @@ export default {
name: "HelloWorld",
data: () => ({}),
methods: {
logout (){
this.$store.commit("logout");
},
}
};
</script>
......@@ -165,7 +165,7 @@ export default {
console.log(user);
let id = user.accountId;
console.log(id);
this.$router.push("/profile/" + id);
await this.$router.push("/profile/" + id);
} else {
console.log("Something went wrong");
}
......
<template>
<div> This is a message page</div>
</template>
<script>
export default {
name: "MessagesForm"
}
</script>
<style scoped>
</style>
\ No newline at end of file
<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>
\ No newline at end of file
<template>
<div> This is a notification page</div>
</template>
<script>
export default {
name: "NotificationsForm"
}
</script>
<style scoped>
</style>
\ No newline at end of file
......@@ -4,6 +4,7 @@ import HomeView from "../views/HomeView.vue";
import LoginView from "../views/LoginView.vue";
import NewPasswordView from "../views/NewPasswordView";
const routes = [
{
path: "/", //Endre før push
......@@ -57,6 +58,17 @@ const routes = [
name: "addNewItem",
component: () => import("../views/AddNewItemView.vue"),
},
{
path: "/notifications",
name: "notifications",
component: () => import("../views/NotificationView.vue"),
},
{
path: "/messages",
name: "messages",
component: () => import("../views/MessagesView.vue"),
},
];
const router = createRouter({
......
<template>
<div class="about">
<h1>This is an about page</h1>
</div>
<div>This is an about page</div>
</template>
<script>
import { defineComponent } from "vue";
// Components
export default defineComponent({
name: "HomeView",
components: {
},
});
</script>
<template>
<div>
<MessagesForm/>
</div>
</template>
<script>
import MessagesForm from "@/components/MessagesForm";
export default {
name: "MessagesView.vue",
components: {
MessagesForm
},
};
</script>
<style scoped>
</style>
\ No newline at end of file
<template>
<div>
<NotificationsForm/>
</div>
</template>
<script>
import NotificationsForm from "@/components/NotificationsForm";
export default {
name: "NotificationView.vue",
components: {
NotificationsForm
},
};
</script>
<style scoped>
</style>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment