Files
InvoiceShelf/resources/scripts/stores/notification.js
Darko Gjorgjijoski 3ceb08bc31 Upgrade Pinia from v2 to v3 (#596)
Migrate all 37 store definitions from the deprecated object-with-id
signature to the string-id-first signature required by Pinia 3:

  defineStore({ id: 'name', ... }) → defineStore('name', { ... })
2026-04-02 16:12:11 +02:00

29 lines
716 B
JavaScript
Vendored

import { defineStore } from 'pinia'
export const useNotificationStore = (useWindow = false) => {
const defineStoreFunc = useWindow ? window.pinia.defineStore : defineStore
return defineStoreFunc('notification', {
state: () => ({
active: false,
autoHide: true,
notifications: [],
}),
actions: {
showNotification(notification) {
this.notifications.push({
...notification,
id: (Math.random().toString(36) + Date.now().toString(36)).substr(2),
})
},
hideNotification(data) {
this.notifications = this.notifications.filter((notification) => {
return notification.id != data.id
})
}
}
})()
}