Skip to content
Snippets Groups Projects
Commit af9ba280 authored by Anders Høvik's avatar Anders Høvik
Browse files

Added routing from notification-messages

parent 4ae49948
No related branches found
No related tags found
1 merge request!59Feature/inbox
Pipeline #281563 passed with warnings
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
<span class="badge rounded-pill badge-notification bg-danger">1</span> <span class="badge rounded-pill badge-notification bg-danger">1</span>
</a> </a>
<ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink"> <ul class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<li v-for="index in notReadNotification" :key="index"> <li v-for="(array,key) in notifMap" :key="key" >
<a class="not-item dropdown-item text-white" href="#">{{index}}</a> <router-link class="not-item dropdown-item text-white" @click="goToSite(array[1][0])" :to="path">{{array[1][1]}}</router-link>
</li> </li>
</ul> </ul>
</li> </li>
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import { useUserInfoStore } from '@/stores/UserStore'; import { useUserInfoStore } from '@/stores/UserStore';
import {ref} from "vue"; import {onMounted, ref} from "vue";
...@@ -82,9 +82,11 @@ const userStore : any = useUserInfoStore(); ...@@ -82,9 +82,11 @@ const userStore : any = useUserInfoStore();
//Hashmap that contains the path to the Badges, The Friend, The dashboard etc. //Hashmap that contains the path to the Badges, The Friend, The dashboard etc.
//The key value pair is the message of the notification and the path of the route //The key value pair is the message of the notification and the path of the route
let messagePath = new Map<string, string>(); let notifMap = ref (new Map<number, any[]>);
let notifMap = new Map<number, Map<string, string>>();
let notifId = 0; let notifId = ref(0);
let path = ref('#');
let notReadNotification = ['You', 'Another news', 'Something else here']; let notReadNotification = ['You', 'Another news', 'Something else here'];
...@@ -101,15 +103,33 @@ let counter = ref(0) ...@@ -101,15 +103,33 @@ let counter = ref(0)
function getNotification(){ function getNotification(){
//axios call //axios call
let response = ['#id', 'message', ] let response = ref( ['1', 'You have recived a award for getting 200 points'])
messagePath.set(response[0], response[1]) let response2 = ref( ['2', 'You have recived a friend request from Jens Aanestad'])
notifMap.set(notifId,messagePath) let response3 = ref( ['3', 'You have lost your streak. Come back to try again'])
notReadNotification.push(response[1]) notifMap.value.set(notifId.value,response.value)
notifId.value++
notifMap.value.set(notifId.value,response2.value)
notifId.value++
notifMap.value.set(notifId.value,response3.value)
notifId.value++
} }
function toBadges(){ function toBadges(){
} }
function goToSite(id : string){
if(id === '1'){
path.value = '/profile'
return path
}
if(id === '2'){
path.value = '/friends'
}
if(id === '3'){
path.value = '/roadmap'
}
}
function removeNotification() { function removeNotification() {
} }
...@@ -159,7 +179,9 @@ function toLogout() { ...@@ -159,7 +179,9 @@ function toLogout() {
userStore.clearUserInfo(); userStore.clearUserInfo();
router.push('login') router.push('login')
} }
onMounted(() => {
getNotification()
})
</script> </script>
<style scoped> <style scoped>
......
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