aboutsummaryrefslogtreecommitdiffstats
path: root/src/views/Modals/Inputs/TextModal.jsx
blob: 2b44f7873080876558c420db2c005b625e240e21 (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
44
45
46
import { Box, Button, Modal, ModalDialog, Textarea, Typography } from '@mui/joy'
import { useState } from 'react'

function TextModal({
  isOpen,
  onClose,
  onSave,
  current,
  title,
  okText,
  cancelText,
}) {
  const [text, setText] = useState(current)

  const handleSave = () => {
    onSave(text)
    onClose()
  }

  return (
    <Modal open={isOpen} onClose={onClose}>
      <ModalDialog>
        {/* <ModalClose /> */}
        <Typography variant='h4'>{title}</Typography>
        <Textarea
          placeholder='Type in here…'
          value={text}
          onChange={e => setText(e.target.value)}
          minRows={2}
          maxRows={4}
          sx={{ minWidth: 300 }}
        />

        <Box display={'flex'} justifyContent={'space-around'} mt={1}>
          <Button onClick={handleSave} fullWidth sx={{ mr: 1 }}>
            {okText ? okText : 'Save'}
          </Button>
          <Button onClick={onClose} variant='outlined'>
            {cancelText ? cancelText : 'Cancel'}
          </Button>
        </Box>
      </ModalDialog>
    </Modal>
  )
}
export default TextModal