1
0
forked from noxious/client
noxious_client/src/stores/notifications.ts
2024-06-02 02:35:42 +02:00

20 lines
600 B
TypeScript

import { defineStore, type StoreDefinition } from 'pinia'
import type { Notification } from '@/types'
export const useNotificationStore: StoreDefinition = defineStore('notifications', {
state: () => ({
notifications: [] as Notification[]
}),
getters: {
getNotifications: (state: any) => state.notifications
},
actions: {
addNotification(notification: Notification) {
this.notifications.push(notification)
},
removeNotification(id: string) {
this.notifications = this.notifications.filter((notification: Notification) => notification.id !== id)
}
}
})