Remove alert store logic

This commit is contained in:
Matthias 2023-09-23 16:21:16 +02:00
parent 9682d76c11
commit 491b6d19bb

View File

@ -1,22 +1,8 @@
import { defineStore } from 'pinia'; import { AlertSeverity } from '@/types/alertTypes';
import { AlertSeverity, AlertType } from '@/types/alertTypes'; import { useToast } from 'bootstrap-vue-next';
export const useAlertsStore = defineStore('alerts', {
state: () => {
return { activeMessages: [] as AlertType[] };
},
actions: {
addAlert(message: AlertType) {
this.activeMessages.push(message);
},
removeAlert(alert: AlertType) {
console.log('dismissed', alert);
this.activeMessages = this.activeMessages.filter((v) => v !== alert);
},
},
});
export function showAlert(message: string, severity: AlertSeverity = 'warning') { export function showAlert(message: string, severity: AlertSeverity = 'warning') {
const alertsStore = useAlertsStore(); const { show } = useToast();
alertsStore.addAlert({ message, severity, timeout: 5000 });
show(message, { title: 'Msg', variant: severity, animation: true, value: true });
} }