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, AlertType } from '@/types/alertTypes';
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);
},
},
});
import { AlertSeverity } from '@/types/alertTypes';
import { useToast } from 'bootstrap-vue-next';
export function showAlert(message: string, severity: AlertSeverity = 'warning') {
const alertsStore = useAlertsStore();
alertsStore.addAlert({ message, severity, timeout: 5000 });
const { show } = useToast();
show(message, { title: 'Msg', variant: severity, animation: true, value: true });
}