Skip to content

Commit d35b68b

Browse files
committed
notifications are deleted on frontend
1 parent 90e1682 commit d35b68b

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

components/Navigation/NotificationDropdown.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<div v-if="getNotifications.length > 0">
1616
<div class="relative px-5 py-4 hover:bg-gray-200 cursor-pointer" v-for="(notification, index) in getNotifications">
1717

18-
<div @click="deleteNotification(notification.id)" class="p-1 absolute mt-3 mr-2 right-0 top-0 ml-5 bg-white rounded-full shadow hover:bg-red-500">
18+
<div @click="deleteNotification({id: notification.id, index})" class="p-1 absolute mt-3 mr-2 right-0 top-0 ml-5 bg-white rounded-full shadow hover:bg-red-500">
1919
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="12pt" height="12pt" viewBox="0 0 24 24" version="1.1">
2020
<g id="surface105499">
2121
<path style=" stroke:none;fill-rule:nonzero;fill:rgb(0%,0%,0%);fill-opacity:1;" d="M 10 2 L 9 3 L 3 3 L 3 5 L 21 5 L 21 3 L 15 3 L 14 2 Z M 4.367188 7 L 5.890625 20.265625 C 6.023438 21.253906 6.878906 22 7.875 22 L 16.121094 22 C 17.121094 22 17.972656 21.253906 18.105469 20.253906 L 19.632812 7 Z M 4.367188 7 "/>

store/notifications.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ export const getters = {
1111
export const mutations = {
1212
SET_NOTIFICATIONS(state, notifications) {
1313
state.notifications = notifications
14+
},
15+
DELETE(state, index) {
16+
state.notifications.splice(index, 1)
1417
}
1518
}
1619

@@ -19,7 +22,8 @@ export const actions = {
1922
const response = await this.$axios.get('/notification/user')
2023
commit('SET_NOTIFICATIONS', response.data)
2124
},
22-
async deleteNotification({commit}, id) {
25+
async deleteNotification({commit}, {id, index}) {
26+
commit('DELETE', index)
2327
await this.$axios.patch(`/notification/user/${id}`)
2428
}
2529
}

0 commit comments

Comments
 (0)