feat(common): customize labels of confimation modal

This commit is contained in:
2026-02-03 21:44:35 +01:00
parent 87da5753c6
commit 35861d69a4
2 changed files with 14 additions and 3 deletions

View File

@@ -64,10 +64,15 @@ onUnmounted(() => {
<template> <template>
<Buttons <Buttons
v-if="confirmationModal.onConfirm" v-if="
confirmationModal.onCancel ||
confirmationModal.onConfirm ||
confirmationModal.bLabel ||
confirmationModal.aLabel
"
:y-offset="confirmationModal.modalButtonsYOffset" :y-offset="confirmationModal.modalButtonsYOffset"
:b-label="$t('common.cancel')" :b-label="confirmationModal.bLabel ?? $t('common.cancel')"
:a-label="$t('common.confirm')" :a-label="confirmationModal.aLabel ?? $t('common.confirm')"
@activate-a="handleActivateA" @activate-a="handleActivateA"
@activate-b="handleActivateB" @activate-b="handleActivateB"
/> />

View File

@@ -9,6 +9,8 @@ export const useConfirmationModal = defineStore("confirmationModal", {
state: () => ({ state: () => ({
isOpen: false, isOpen: false,
text: "", text: "",
aLabel: null as string | null,
bLabel: null as string | null,
onConfirm: null as (() => void) | null, onConfirm: null as (() => void) | null,
onCancel: null as (() => void) | null, onCancel: null as (() => void) | null,
onClosed: null as ((choice: "confirm" | "cancel") => void) | null, onClosed: null as ((choice: "confirm" | "cancel") => void) | null,
@@ -22,6 +24,8 @@ export const useConfirmationModal = defineStore("confirmationModal", {
actions: { actions: {
open(options: { open(options: {
text: string; text: string;
aLabel?: string;
bLabel?: string;
onCancel?: () => void; onCancel?: () => void;
onConfirm?: () => void; onConfirm?: () => void;
onClosed?: (choice: "confirm" | "cancel") => void; onClosed?: (choice: "confirm" | "cancel") => void;
@@ -29,6 +33,8 @@ export const useConfirmationModal = defineStore("confirmationModal", {
}) { }) {
gsap.killTweensOf(this); gsap.killTweensOf(this);
this.text = options.text; this.text = options.text;
this.aLabel = options.aLabel ?? null;
this.bLabel = options.bLabel ?? null;
this.onConfirm = options.onConfirm ?? null; this.onConfirm = options.onConfirm ?? null;
this.onCancel = options.onCancel ?? null; this.onCancel = options.onCancel ?? null;
this.onClosed = options.onClosed ?? null; this.onClosed = options.onClosed ?? null;