Deletions, group moves and validation
This commit is contained in:
@ -4,7 +4,17 @@ import { defineStore } from 'pinia'
|
||||
interface Alert {
|
||||
id: number
|
||||
message: string
|
||||
type: 'info' | 'success' | 'warning' | 'error'
|
||||
title?: string
|
||||
type: 'info' | 'success' | 'warning' | 'error' | 'danger'
|
||||
icon: string
|
||||
}
|
||||
|
||||
const iconMap = {
|
||||
'info': 'info-circle',
|
||||
'success': 'check2-circle',
|
||||
'warning': 'exclamation-triangle',
|
||||
'error': 'exclamation-octagon',
|
||||
'danger': 'exclamation-octagon',
|
||||
}
|
||||
|
||||
export const useAlertsStore = defineStore('alerts', {
|
||||
@ -12,11 +22,24 @@ export const useAlertsStore = defineStore('alerts', {
|
||||
alerts: [] as Alert[],
|
||||
}),
|
||||
actions: {
|
||||
showAlert(message: string, type: Alert['type'] = 'info') {
|
||||
showAlert(message: string, type: Alert['type'] = 'info', title?: string) {
|
||||
if (type === 'error') {
|
||||
type = 'danger'
|
||||
}
|
||||
if (!title) {
|
||||
if (type === 'danger') {
|
||||
title = 'Error'
|
||||
} else {
|
||||
title = type
|
||||
}
|
||||
}
|
||||
const icon = iconMap[type]
|
||||
this.alerts.push({
|
||||
id: Date.now(),
|
||||
message,
|
||||
title,
|
||||
type,
|
||||
icon,
|
||||
})
|
||||
},
|
||||
removeAlert(id: number) {
|
||||
|
||||
Reference in New Issue
Block a user