This repository has been archived on 2025-12-04. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
Caramel-CRM-Backup/resources/js/stores/alertStore.ts
T
vollstock f688e3fb17 Add confirm dialog to reminder button.
Add a show function in alertStore so we can use alerts in a defined way everywhere.
#12 #33
2025-10-30 10:15:02 +01:00

46 lines
1.4 KiB
TypeScript

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: "" 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;
}
}
})