import Modal from "../react/Modal"; import Button from "../react/Button"; import { t } from "../../services/i18n"; import { useState } from "preact/hooks"; import FormCheckbox from "../react/FormCheckbox"; import { useTriliumEvent } from "../react/hooks"; import { isValidElement, type VNode } from "preact"; import { RawHtmlBlock } from "../react/RawHtml"; interface ConfirmDialogProps { title?: string; message?: MessageType; callback?: ConfirmDialogCallback; isConfirmDeleteNoteBox?: boolean; } export default function ConfirmDialog() { const [ opts, setOpts ] = useState(); const [ isDeleteNoteChecked, setIsDeleteNoteChecked ] = useState(false); const [ shown, setShown ] = useState(false); function showDialog(title: string | null, message: MessageType, callback: ConfirmDialogCallback, isConfirmDeleteNoteBox: boolean) { setOpts({ title: title ?? undefined, message, callback, isConfirmDeleteNoteBox }); setShown(true); } useTriliumEvent("showConfirmDialog", ({ message, callback }) => showDialog(null, message, callback, false)); useTriliumEvent("showConfirmDeleteNoteBoxWithNoteDialog", ({ title, callback }) => showDialog(title, t("confirm.are_you_sure_remove_note", { title: title }), callback, true)); return ( { opts?.callback?.({ confirmed: false, isDeleteNoteChecked }); setShown(false); }} footer={<>