This commit is contained in:
nurmuhammet committed 2024-09-01 18:54:23 +05:00
1 parent 76d18365a5
commit 061f09eca1
1597 files changed
+109451 -1

No files matched your search

+56
View File
@@ -0,0 +1,56 @@
export default {
state: () => ({
notifications: [],
notificationsShown: false,
unreadNotifications: false,
}),
getters: {
notifications: s => s.notifications,
notificationsShown: s => s.notificationsShown,
unreadNotifications: s => s.unreadNotifications,
},
mutations: {
toggleNotifications(state) {
state.notificationsShown = !state.notificationsShown
localStorage.setItem('nova.mainMenu.open', state.notificationsShown)
},
},
actions: {
async fetchNotifications({ state }) {
const {
data: { notifications, unread },
} = await Nova.request().get(`/nova-api/nova-notifications`)
state.notifications = notifications
state.unreadNotifications = unread
},
async markNotificationAsUnread({ state, dispatch }, id) {
await Nova.request().post(`/nova-api/nova-notifications/${id}/unread`)
dispatch('fetchNotifications')
},
async markNotificationAsRead({ state, dispatch }, id) {
await Nova.request().post(`/nova-api/nova-notifications/${id}/read`)
dispatch('fetchNotifications')
},
async deleteNotification({ state, dispatch }, id) {
await Nova.request().delete(`/nova-api/nova-notifications/${id}`)
dispatch('fetchNotifications')
},
async deleteAllNotifications({ state, dispatch }, id) {
await Nova.request().delete(`/nova-api/nova-notifications`)
dispatch('fetchNotifications')
},
async markAllNotificationsAsRead({ state, dispatch }, id) {
await Nova.request().post(`/nova-api/nova-notifications/read-all`)
dispatch('fetchNotifications')
},
},
}