Skip to content
Snippets Groups Projects
Commit 128c1c20 authored by Jens Christian Aanestad's avatar Jens Christian Aanestad
Browse files

feat/added remove notification in navbar

parent db6731b6
No related branches found
No related tags found
1 merge request!79Feat/notifications
Pipeline #283332 passed with warnings
...@@ -38,7 +38,9 @@ ...@@ -38,7 +38,9 @@
</a> </a>
<ul v-if="notificationListRef.length > 0" class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink"> <ul v-if="notificationListRef.length > 0" class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
<li v-for="(item, index) in notificationListRef" :key="index" > <li v-for="(item, index) in notificationListRef" :key="index" >
<router-link :to="notificationPathMapper[String(item.notificationType)]" class="d-flex align-items-center"> <router-link :to="notificationPathMapper[String(item.notificationType)]"
class="d-flex align-items-center"
@click="readNotification(item)">
<div class="flex-shrink-0"> <div class="flex-shrink-0">
<img :src="notificationImageMapper[String(item.notificationType)]" alt="Varslingsikon" class="notification-icon"> <img :src="notificationImageMapper[String(item.notificationType)]" alt="Varslingsikon" class="notification-icon">
</div> </div>
...@@ -129,8 +131,8 @@ const notificationImageMapper: any = { ...@@ -129,8 +131,8 @@ const notificationImageMapper: any = {
} }
const notificationPathMapper: any = { const notificationPathMapper: any = {
"FRIEND_REQUEST": "/profile", "FRIEND_REQUEST": "/friends",
"BADGE": "/friends", "BADGE": "/profile",
"COMPLETED_GOAL": "/roadmap" "COMPLETED_GOAL": "/roadmap"
} }
const getNotifications = async () => { const getNotifications = async () => {
...@@ -140,6 +142,17 @@ const getNotifications = async () => { ...@@ -140,6 +142,17 @@ const getNotifications = async () => {
notificationListRef.value = [] notificationListRef.value = []
} }
} }
const readNotification = async (notification: NotificationDTO) => {
try {
notification.unread = false;
await NotificationService.updateNotification({requestBody: notification});
notificationListRef.value = await NotificationService.getUnreadNotificationByUser()
} catch (error) {
notificationListRef.value = [];
}
}
function toBadges(){ function toBadges(){
} }
......
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