42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
/** Переиспользуемое модальное подтверждение (без нативного confirm()). */
|
|
export function ConfirmDialog({
|
|
open,
|
|
title,
|
|
message,
|
|
confirmLabel = "Подтвердить",
|
|
cancelLabel = "Отмена",
|
|
danger = false,
|
|
onConfirm,
|
|
onCancel,
|
|
}: {
|
|
open: boolean;
|
|
title: string;
|
|
message?: string;
|
|
confirmLabel?: string;
|
|
cancelLabel?: string;
|
|
danger?: boolean;
|
|
onConfirm: () => void;
|
|
onCancel: () => void;
|
|
}) {
|
|
if (!open) return null;
|
|
return (
|
|
<div className="modal-overlay" onClick={onCancel}>
|
|
<div className="modal" onClick={(e) => e.stopPropagation()}>
|
|
<div className="modal-title">{title}</div>
|
|
{message && <p className="modal-msg">{message}</p>}
|
|
<div className="modal-actions">
|
|
<button className="btn btn-ghost" onClick={onCancel}>
|
|
{cancelLabel}
|
|
</button>
|
|
<button
|
|
className={"btn " + (danger ? "btn-danger-solid" : "btn-primary")}
|
|
onClick={onConfirm}
|
|
>
|
|
{confirmLabel}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|