From fd7e4817cd0e0160e85ad98ad81f406c66a94800 Mon Sep 17 00:00:00 2001 From: eug-vs Date: Thu, 8 Oct 2020 20:21:35 +0300 Subject: feat: correctly wire modal logic --- src/components/ModalScreen/ModalScreen.tsx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src/components/ModalScreen/ModalScreen.tsx') diff --git a/src/components/ModalScreen/ModalScreen.tsx b/src/components/ModalScreen/ModalScreen.tsx index 7090980..6c514cd 100644 --- a/src/components/ModalScreen/ModalScreen.tsx +++ b/src/components/ModalScreen/ModalScreen.tsx @@ -17,7 +17,9 @@ import CloseIcon from '@material-ui/icons/Close'; interface PropTypes { title: string; - rightIcon?: JSX.Element; + actionIcon?: JSX.Element; + handleAction?: () => void; + isActionDisabled?: boolean; } const useStyles = makeStyles(theme => ({ @@ -38,7 +40,7 @@ const Transition = React.forwardRef(( ref: React.Ref ) => ); -const ModalScreen: React.FC = ({ title, rightIcon, children }) => { +const ModalScreen: React.FC = ({ title, actionIcon, handleAction, isActionDisabled, children }) => { const [isOpen, setIsOpen] = useState(true); const classes = useStyles(); const theme = useTheme(); @@ -48,6 +50,11 @@ const ModalScreen: React.FC = ({ title, rightIcon, children }) => { const handleClose = useCallback(() => setIsOpen(false), [setIsOpen]); const onExited = useCallback(() => history.goBack(), [history]); + const handleClickAction = useCallback(async () => { + if (handleAction) await handleAction(); + return handleClose(); + }, [handleAction, handleClose]); + return ( = ({ title, rightIcon, children }) => { { title } - { rightIcon || ( - - - - )} + + { actionIcon } + -- cgit v1.2.3