import { defineStore } from 'pinia' export interface AlertOptions { cancelText?: string; onCancel?: () => void; actionText?: string; actionVariant?: "action" | "destructive"; onAction?: () => void; } export const alertStore = defineStore('alert', { state: () => { return { open: false, title: "", message: "" as string | null, cancelText: "Abbrechen", onCancel: () => { }, actionText: "Ok", actionVariant: "action" as "action" | "destructive", onAction: () => { } } }, actions: { show(title: string, message: string | null, options?: AlertOptions) { this.title = title; this.message = message; this.cancelText = options?.cancelText ? options.cancelText : "Abbrechen" this.onCancel = options?.onCancel ? options.onCancel : () => { } this.actionText = options?.actionText ? options.actionText : "Ok" this.actionVariant = options?.actionVariant ? options.actionVariant : "action" this.onAction = options?.onAction ? options.onAction : () => { } this.open = true; }, cancel() { this.onCancel(); this.open = false; }, action() { this.onAction(); this.open = false; } } })