5180 fichiers 38.5 Mo 0 téléchargements 262 vues mis à jour il y a 5 heures ui
nitro-v36-with-renderer-v36 / src / hooks / housekeeping / useHousekeepingConfirm.ts
useHousekeepingConfirm.ts 1.4 Ko Télécharger le fichier
import { useCallback } from 'react';
import { LocalizeText } from '../../api';
import { useNotification } from '../notification';

/**
 * Themed confirmation wrapper around `useNotification().showConfirm`.
 *
 * Destructive HK actions (delete room, kick-all, bulk ban) used to
 * call `window.confirm` directly — that's a system-modal that breaks
 * out of the client visually and doesn't honor the LocalizeText
 * dictionary. `useHousekeepingConfirm` swaps in the in-client
 * NotificationConfirm modal, with the HK button labels and a
 * sensible default title.
 *
 * Returns a single function `confirm(message, onConfirm)` to keep
 * the call sites tight. Pass an `options.confirmText` override when
 * the action needs a custom label (e.g. "Delete forever" instead of
 * the generic confirm).
 */
export const useHousekeepingConfirm = () => {
    const { showConfirm } = useNotification();

    return useCallback(
        (message: string, onConfirm: () => void, options: { confirmText?: string; cancelText?: string; title?: string } = {}) => {
            const confirmText = options.confirmText ?? LocalizeText('housekeeping.confirm.proceed');
            const cancelText = options.cancelText ?? LocalizeText('housekeeping.confirm.cancel');
            const title = options.title ?? LocalizeText('housekeeping.confirm.title');

            showConfirm(message, onConfirm, () => {}, confirmText, cancelText, title);
        },
        [showConfirm]
    );
};
15Sujets
1Dépôts
20Membres
2En ligne
Profile
Inscrit
Dernière visite
Messages
0
Votes positifs
0
Votes négatifs
0

Nous utilisons des cookies pour assurer le bon fonctionnement du site et améliorer votre expérience. en savoir plus

Autoriser