diff --git a/src/stores/notification-store.ts b/src/stores/notification-store.ts new file mode 100644 index 0000000..22427a6 --- /dev/null +++ b/src/stores/notification-store.ts @@ -0,0 +1,19 @@ +import { defineStore } from 'pinia'; + +export const useNotificationStore = defineStore('notificationStore',{ + state:() => ({ + decision: false, + isTabActive: true, + }), + actions: { + saveDecision(decision : boolean) { + this.decision = decision; + }, + + sendNotificationIfAllowed(image : string, headline : string, message : string) { + if(this.decision && !this.isTabActive){ + new Notification(headline, { body: message, icon: image }); + } + } + } +});