2024-10-11 14:28:09 -04:00
|
|
|
import LoadingButton from "@mui/lab/LoadingButton";
|
|
|
|
|
import { Button, Modal, Stack, Typography } from "@mui/material";
|
|
|
|
|
import PropTypes from "prop-types";
|
2024-10-15 14:16:47 -04:00
|
|
|
const Dialog = ({ modelTitle, modelDescription,
|
|
|
|
|
open, onClose, title, confirmationBtnLbl, confirmationBtnOnClick, cancelBtnLbl, cancelBtnOnClick, theme, isLoading, description }) => {
|
2024-10-11 14:28:09 -04:00
|
|
|
return <Modal
|
2024-10-15 14:16:47 -04:00
|
|
|
aria-labelledby={modelTitle}
|
|
|
|
|
aria-describedby={modelDescription}
|
2024-10-11 14:28:09 -04:00
|
|
|
open={open}
|
|
|
|
|
onClose={onClose} >
|
|
|
|
|
<Stack
|
|
|
|
|
gap={theme.spacing(2)}
|
|
|
|
|
sx={{
|
|
|
|
|
position: "absolute",
|
|
|
|
|
top: "50%",
|
|
|
|
|
left: "50%",
|
|
|
|
|
transform: "translate(-50%, -50%)",
|
|
|
|
|
width: 400,
|
|
|
|
|
bgcolor: theme.palette.background.main,
|
|
|
|
|
border: 1,
|
|
|
|
|
borderColor: theme.palette.border.light,
|
|
|
|
|
borderRadius: theme.shape.borderRadius,
|
|
|
|
|
boxShadow: 24,
|
|
|
|
|
p: theme.spacing(15),
|
|
|
|
|
"&:focus": {
|
|
|
|
|
outline: "none",
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
>
|
2024-10-15 14:16:47 -04:00
|
|
|
<Typography id={modelTitle} component="h2"
|
2024-10-11 14:28:09 -04:00
|
|
|
fontSize={16}
|
|
|
|
|
color={theme.palette.text.primary}
|
|
|
|
|
fontWeight={600}>
|
2024-10-15 14:16:47 -04:00
|
|
|
{title}
|
2024-10-11 14:28:09 -04:00
|
|
|
</Typography>
|
2024-10-15 14:16:47 -04:00
|
|
|
{description && <Typography id={modelDescription} color={theme.palette.text.tertiary}>
|
|
|
|
|
{description}
|
2024-10-11 14:28:09 -04:00
|
|
|
</Typography>}
|
|
|
|
|
<Stack
|
|
|
|
|
direction="row"
|
|
|
|
|
gap={theme.spacing(4)}
|
|
|
|
|
mt={theme.spacing(12)}
|
|
|
|
|
justifyContent="flex-end"
|
|
|
|
|
>
|
|
|
|
|
<Button
|
|
|
|
|
variant="text"
|
|
|
|
|
color="info"
|
2024-10-15 14:16:47 -04:00
|
|
|
onClick={cancelBtnOnClick}
|
2024-10-11 14:28:09 -04:00
|
|
|
>
|
2024-10-15 14:16:47 -04:00
|
|
|
{cancelBtnLbl}
|
2024-10-11 14:28:09 -04:00
|
|
|
</Button>
|
|
|
|
|
<LoadingButton
|
|
|
|
|
variant="contained"
|
|
|
|
|
color="error"
|
|
|
|
|
loading= {isLoading}
|
2024-10-15 14:16:47 -04:00
|
|
|
onClick={confirmationBtnOnClick}
|
2024-10-11 14:28:09 -04:00
|
|
|
>
|
2024-10-15 14:16:47 -04:00
|
|
|
{confirmationBtnLbl}
|
2024-10-11 14:28:09 -04:00
|
|
|
</LoadingButton>
|
|
|
|
|
</Stack>
|
|
|
|
|
</Stack>
|
|
|
|
|
</Modal>
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-16 09:52:59 -04:00
|
|
|
Dialog.propTypes = {
|
2024-10-15 14:16:47 -04:00
|
|
|
modelTitle: PropTypes.string.isRequired,
|
|
|
|
|
modelDescription: PropTypes.string.isRequired,
|
2024-10-11 14:28:09 -04:00
|
|
|
open: PropTypes.bool.isRequired,
|
|
|
|
|
onClose: PropTypes.func.isRequired,
|
2024-10-15 14:16:47 -04:00
|
|
|
title: PropTypes.string.isRequired,
|
|
|
|
|
confirmationBtnLbl: PropTypes.string.isRequired,
|
|
|
|
|
confirmationBtnOnClick: PropTypes.func.isRequired,
|
|
|
|
|
cancelBtnLbl: PropTypes.string.isRequired,
|
|
|
|
|
cancelBtnOnClick: PropTypes.func.isRequired,
|
2024-10-11 14:28:09 -04:00
|
|
|
theme: PropTypes.object.isRequired,
|
|
|
|
|
isLoading: PropTypes.bool.isRequired,
|
2024-10-15 14:16:47 -04:00
|
|
|
description: PropTypes.string
|
2024-10-11 14:28:09 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Dialog
|