mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
refactor: ts on pinia store
This commit is contained in:
23
src/renderer/stores/notifications.ts
Normal file
23
src/renderer/stores/notifications.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { defineStore } from 'pinia';
|
||||
import { uidGen } from 'common/libs/uidGen';
|
||||
|
||||
export interface Notification {
|
||||
uid: string;
|
||||
status: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export const useNotificationsStore = defineStore('notifications', {
|
||||
state: () => ({
|
||||
notifications: [] as Notification[]
|
||||
}),
|
||||
actions: {
|
||||
addNotification (payload: { status: string; message: string }) {
|
||||
const notification: Notification = { uid: uidGen('N'), ...payload };
|
||||
this.notifications.unshift(notification);
|
||||
},
|
||||
removeNotification (uid: string) {
|
||||
this.notifications = (this.notifications as Notification[]).filter(item => item.uid !== uid);
|
||||
}
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user