aboutsummaryrefslogtreecommitdiffstats
path: root/src/views/Modals/Inputs/SelectModal.jsx
diff options
context:
space:
mode:
authorLibravatar Mo Tarbin <mhed.t91@gmail.com>2024-06-30 18:55:39 -0400
committerLibravatar Mo Tarbin <mhed.t91@gmail.com>2024-06-30 18:55:39 -0400
commit2657469964e24ffbeb905024532120395f6e797c (patch)
tree2fe9db8a4ecfa92d854ca94f7586d81163c8bd25 /src/views/Modals/Inputs/SelectModal.jsx
downloaddonetick-frontend-2657469964e24ffbeb905024532120395f6e797c.tar.gz
donetick-frontend-2657469964e24ffbeb905024532120395f6e797c.tar.bz2
donetick-frontend-2657469964e24ffbeb905024532120395f6e797c.zip
move to Donetick Org, First commit frontend
Diffstat (limited to 'src/views/Modals/Inputs/SelectModal.jsx')
-rw-r--r--src/views/Modals/Inputs/SelectModal.jsx49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/views/Modals/Inputs/SelectModal.jsx b/src/views/Modals/Inputs/SelectModal.jsx
new file mode 100644
index 0000000..61e7ae9
--- /dev/null
+++ b/src/views/Modals/Inputs/SelectModal.jsx
@@ -0,0 +1,49 @@
+import {
+ Box,
+ Button,
+ Modal,
+ ModalDialog,
+ Option,
+ Select,
+ Typography,
+} from '@mui/joy'
+import React from 'react'
+
+function SelectModal({ isOpen, onClose, onSave, options, title, displayKey }) {
+ const [selected, setSelected] = React.useState(null)
+ const handleSave = () => {
+ onSave(options.find(item => item.id === selected))
+ onClose()
+ }
+
+ return (
+ <Modal open={isOpen} onClose={onClose}>
+ <ModalDialog>
+ <Typography variant='h4'>{title}</Typography>
+ <Select>
+ {options.map((item, index) => (
+ <Option
+ value={item.id}
+ key={item[displayKey]}
+ onClick={() => {
+ setSelected(item.id)
+ }}
+ >
+ {item[displayKey]}
+ </Option>
+ ))}
+ </Select>
+
+ <Box display={'flex'} justifyContent={'space-around'} mt={1}>
+ <Button onClick={handleSave} fullWidth sx={{ mr: 1 }}>
+ Save
+ </Button>
+ <Button onClick={onClose} variant='outlined'>
+ Cancel
+ </Button>
+ </Box>
+ </ModalDialog>
+ </Modal>
+ )
+}
+export default SelectModal