File size: 1,245 Bytes
b24b684
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
53
54
55
import {
  Button,
  Dialog,
  DialogActions,
  DialogContent,
  DialogContentText,
  DialogTitle,
} from "@mui/material";

interface Props {
  open: boolean;
  title: string;
  message: string;
  confirmLabel?: string;
  confirmColor?: "primary" | "error" | "warning" | "success";
  loading?: boolean;
  onConfirm: () => void;
  onClose: () => void;
}

export default function ConfirmDialog({

  open,

  title,

  message,

  confirmLabel = "Confirm",

  confirmColor = "primary",

  loading = false,

  onConfirm,

  onClose,

}: Props) {
  return (
    <Dialog open={open} onClose={onClose} maxWidth="xs" fullWidth>

      <DialogTitle sx={{ fontFamily: "Plus Jakarta Sans", fontWeight: 700 }}>

        {title}

      </DialogTitle>

      <DialogContent>

        <DialogContentText>{message}</DialogContentText>

      </DialogContent>

      <DialogActions sx={{ px: 3, pb: 2 }}>

        <Button onClick={onClose} color="inherit">

          Cancel

        </Button>

        <Button

          onClick={onConfirm}

          variant="contained"

          color={confirmColor}

          disabled={loading}

        >

          {confirmLabel}

        </Button>

      </DialogActions>

    </Dialog>
  );
}