Files
Checkmate/Client/src/Components/Dialog/index.jsx
T

82 lines
1.7 KiB
React
Raw Normal View History

2024-10-11 14:28:09 -04:00
import LoadingButton from "@mui/lab/LoadingButton";
2024-10-22 05:58:21 -04:00
import { Button, Stack, Typography } from "@mui/material";
2024-10-11 14:28:09 -04:00
import PropTypes from "prop-types";
2024-10-22 05:58:21 -04:00
import { GenericDialog } from "./genericDialog";
import { useId } from "react";
const Dialog = ({
open,
onClose,
theme,
title,
description,
onCancel,
confirmationButtonLabel,
onConfirm,
isLoading,
}) => {
const titleId = useId();
const descriptionId = useId();
return (
2024-10-22 05:58:21 -04:00
<GenericDialog
title={titleId}
description={descriptionId}
open={open}
onClose={onClose}
2024-10-22 05:58:21 -04:00
theme={theme}
>
2024-10-22 05:58:21 -04:00
<Typography
id={titleId}
2024-10-22 05:58:21 -04:00
component="h2"
fontSize={16}
color={theme.palette.text.primary}
fontWeight={600}
>
2024-10-22 05:58:21 -04:00
{title}
</Typography>
{description && (
<Typography
id={descriptionId}
2024-10-22 05:58:21 -04:00
color={theme.palette.text.tertiary}
>
2024-10-22 05:58:21 -04:00
{description}
</Typography>
2024-10-22 05:58:21 -04:00
)}
<Stack
direction="row"
gap={theme.spacing(4)}
mt={theme.spacing(12)}
justifyContent="flex-end"
>
<Button
variant="text"
color="info"
onClick={onCancel}
2024-10-22 05:58:21 -04:00
>
Cancel
2024-10-22 05:58:21 -04:00
</Button>
<LoadingButton
variant="contained"
color="error"
loading={isLoading}
onClick={onConfirm}
>
{confirmationButtonLabel}
2024-10-22 05:58:21 -04:00
</LoadingButton>
</Stack>
2024-10-22 05:58:21 -04:00
</GenericDialog>
);
};
2024-10-11 14:28:09 -04:00
Dialog.propTypes = {
open: PropTypes.bool.isRequired,
onClose: PropTypes.func.isRequired,
theme: PropTypes.object.isRequired,
title: PropTypes.string.isRequired,
description: PropTypes.string,
onCancel: PropTypes.func.isRequired,
confirmationButtonLabel: PropTypes.string.isRequired,
onConfirm: PropTypes.func.isRequired,
isLoading: PropTypes.bool.isRequired,
};
2024-10-11 14:28:09 -04:00
export default Dialog;