Add confirm dialog to reminder button.

Add a show function in alertStore so we can use alerts in a defined way everywhere.
#12 #33
This commit is contained in:
2025-10-30 10:15:02 +01:00
parent 9439d14b59
commit f688e3fb17
4 changed files with 100 additions and 39 deletions
+31 -2
View File
@@ -1,11 +1,20 @@
import { options } from '@coders-tm/vue-number-format';
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: "",
message: "" as string | null,
cancelText: "Abbrechen",
onCancel: () => { },
actionText: "Ok",
@@ -13,5 +22,25 @@ export const alertStore = defineStore('alert', {
onAction: () => { }
}
},
actions: {}
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;
}
}
})