aboutsummaryrefslogtreecommitdiffstats
path: root/src/views/Modals/Inputs/ConfirmationModal.jsx
blob: 10f9beeeebfe33c305a6ce8f8e06b0ad28a3f813 (plain) (blame)
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
import { Box, Button, Modal, ModalDialog, Typography } from '@mui/joy'
import React from 'react'

function ConfirmationModal({ config }) {
  const handleAction = isConfirmed => {
    config.onClose(isConfirmed)
  }

  return (
    <Modal open={config?.isOpen} onClose={config?.onClose}>
      <ModalDialog>
        <Typography level='h4' mb={1}>
          {config?.title}
        </Typography>

        <Typography level='body-md' gutterBottom>
          {config?.message}
        </Typography>

        <Box display={'flex'} justifyContent={'space-around'} mt={1}>
          <Button
            onClick={() => {
              handleAction(true)
            }}
            fullWidth
            sx={{ mr: 1 }}
          >
            {config?.confirmText}
          </Button>
          <Button
            onClick={() => {
              handleAction(false)
            }}
            variant='outlined'
          >
            {config?.cancelText}
          </Button>
        </Box>
      </ModalDialog>
    </Modal>
  )
}
export default ConfirmationModal