-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.tsx
52 lines (51 loc) · 1.35 KB
/
index.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import React from "react";
import { Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, Button } from '@mui/material';
interface IProps {
message: string | JSX.Element;
options: {
title?: string | JSX.Element;
actions?: {
copy: string;
onClick: any;
}[];
closeCopy?: string;
};
close: any;
}
const AlertDialog = ({ close, message, options }: IProps) => {
return (
<Dialog
open={true}
onClose={close}
keepMounted
aria-labelledby="alert-dialog-slide-title"
aria-describedby="alert-dialog-slide-description"
>
<DialogTitle id="alert-dialog-slide-title">{options.title}</DialogTitle>
<DialogContent>
<DialogContentText id="alert-dialog-slide-description">
{message}
</DialogContentText>
</DialogContent>
<DialogActions>
{options.actions &&
options.actions.map((action, index) => (
<Button
onClick={() => {
action.onClick();
close();
}}
color="primary"
key={index}
>
{action.copy}
</Button>
))}
<Button onClick={close} color="primary">
{options.closeCopy || "Okay"}
</Button>
</DialogActions>
</Dialog>
);
};
export default AlertDialog;