mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-04-07 05:31:24 +00:00
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', { ... })
29 lines
716 B
JavaScript
Vendored
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
|
|
})
|
|
}
|
|
}
|
|
})()
|
|
}
|