-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #134 from Tauffer-Consulting/dev
Dev
- Loading branch information
Showing
33 changed files
with
845 additions
and
424 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { | ||
Button, | ||
Dialog, | ||
DialogActions, | ||
DialogContent, | ||
DialogContentText, | ||
DialogTitle, | ||
Grid, | ||
} from "@mui/material"; | ||
import React, { useCallback, useImperativeHandle, useState } from "react"; | ||
|
||
interface Props { | ||
title: string; | ||
content?: string | React.ReactNode; | ||
|
||
confirmFn?: () => void; | ||
cancelFn?: () => void; | ||
} | ||
|
||
export interface ModalRef { | ||
open: () => void; | ||
close: () => void; | ||
} | ||
|
||
export const Modal = React.forwardRef<ModalRef, Props>( | ||
({ cancelFn, confirmFn, title, content }, ref) => { | ||
const [isOpen, setIsOpen] = useState(false); | ||
|
||
const open = () => { | ||
setIsOpen(true); | ||
}; | ||
|
||
const handleClose = useCallback(() => { | ||
if (cancelFn) { | ||
cancelFn(); | ||
} | ||
|
||
setIsOpen(false); | ||
}, []); | ||
|
||
const handleConfirm = useCallback(() => { | ||
if (confirmFn) { | ||
confirmFn(); | ||
} | ||
|
||
setIsOpen(false); | ||
}, []); | ||
|
||
useImperativeHandle(ref, () => ({ | ||
open, | ||
close: handleClose, | ||
})); | ||
|
||
return ( | ||
<Dialog open={isOpen} onClose={handleClose}> | ||
<DialogTitle>{title}</DialogTitle> | ||
<DialogContent> | ||
<DialogContentText>{content}</DialogContentText> | ||
</DialogContent> | ||
<DialogActions> | ||
<Grid container justifyContent="center" spacing={4}> | ||
{cancelFn && ( | ||
<Grid item> | ||
<Button onClick={handleClose} variant="contained"> | ||
Cancel | ||
</Button> | ||
</Grid> | ||
)} | ||
<Grid item> | ||
<Button onClick={handleConfirm} variant="contained"> | ||
OK | ||
</Button> | ||
</Grid> | ||
</Grid> | ||
</DialogActions> | ||
</Dialog> | ||
); | ||
}, | ||
); | ||
|
||
Modal.displayName = "Modal"; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.