fix(frontend): update dialog close button

This commit is contained in:
yassinedorbozgithub 2025-02-03 15:02:24 +01:00
parent 89f0811116
commit 7ef81e7999

View File

@ -6,7 +6,6 @@
* 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file). * 2. All derivative works must include clear attribution to the original creator and software, Hexastack and Hexabot, in a prominent location (e.g., in the software's "About" section, documentation, and README file).
*/ */
import CloseIcon from "@mui/icons-material/Close"; import CloseIcon from "@mui/icons-material/Close";
import { import {
IconButton, IconButton,
@ -23,31 +22,16 @@ const StyledDialogTitle = styled(Typography)(() => ({
export const DialogTitle = ({ export const DialogTitle = ({
children, children,
onClose, onClose,
onCloseV2,
}: { }: {
children: React.ReactNode; children: React.ReactNode;
onClose?: () => void; onClose?: () => void;
onCloseV2?:
| ((event: {}, reason: "backdropClick" | "escapeKeyDown") => void)
| undefined;
}) => ( }) => (
<MuiDialogTitle> <MuiDialogTitle>
<StyledDialogTitle>{children}</StyledDialogTitle> <StyledDialogTitle>{children}</StyledDialogTitle>
{onClose && ( {onClose ? (
<IconButton <IconButton size="small" aria-label="close" onClick={onClose}>
size="small"
aria-label="close"
onClick={(e) => {
if (onCloseV2) {
onCloseV2(e, "backdropClick");
} else {
//TODO: the old onClose prop can be replaced by the new one after the full implementation of the useDialogs hook
onClose();
}
}}
>
<CloseIcon /> <CloseIcon />
</IconButton> </IconButton>
)} ) : null}
</MuiDialogTitle> </MuiDialogTitle>
); );