feat(mui): ConfirmDialog optional children (extra content below message)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
BOHA
2026-06-06 22:24:12 +02:00
parent fbcd5a8939
commit c0e1b718e6

View File

@@ -1,4 +1,4 @@
import { useState } from "react";
import { useState, type ReactNode } from "react";
import Dialog from "@mui/material/Dialog";
import DialogTitle from "@mui/material/DialogTitle";
import DialogContent from "@mui/material/DialogContent";
@@ -17,6 +17,8 @@ export interface ConfirmDialogProps {
cancelText?: string;
confirmVariant?: "primary" | "danger";
loading?: boolean;
/** Optional extra content rendered below the message (e.g. a checkbox). */
children?: ReactNode;
}
/** Confirmation dialog over MUI Dialog. Preserves the legacy ConfirmModal prop shape. */
@@ -30,6 +32,7 @@ export default function ConfirmDialog({
cancelText = "Zrušit",
confirmVariant = "primary",
loading = false,
children,
}: ConfirmDialogProps) {
useDialogScrollLock(isOpen);
// Freeze content + label + loading while open, so neither the message NOR the
@@ -59,6 +62,7 @@ export default function ConfirmDialog({
<DialogTitle>{shown.title}</DialogTitle>
<DialogContent>
<DialogContentText>{shown.message}</DialogContentText>
{children}
</DialogContent>
<DialogActions sx={{ px: 3, pb: 2 }}>
<MuiButton onClick={onClose} color="inherit" disabled={shown.loading}>