mirror of
https://github.com/freqtrade/frequi.git
synced 2024-11-27 13:35:17 +00:00
23 lines
677 B
TypeScript
23 lines
677 B
TypeScript
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);
|
|
},
|
|
},
|
|
});
|
|
|
|
export function showAlert(message: string, severity: AlertSeverity = 'warning') {
|
|
const alertsStore = useAlertsStore();
|
|
alertsStore.addAlert({ message, severity, timeout: 5000 });
|
|
}
|