import { createPortal } from 'react-dom' import { useDispatch } from 'react-redux' import { useEffect } from 'react' import PropTypes from 'prop-types' // material-ui import { Dialog, DialogContent, DialogTitle } from '@mui/material' // store import { HIDE_CANVAS_DIALOG, SHOW_CANVAS_DIALOG } from '@/store/actions' import useNotifier from '@/utils/useNotifier' // Project imports import SpeechToText from '@/ui-component/extended/SpeechToText' const SpeechToTextDialog = ({ show, dialogProps, onCancel, onConfirm }) => { const portalElement = document.getElementById('portal') const dispatch = useDispatch() useNotifier() useEffect(() => { if (show) dispatch({ type: SHOW_CANVAS_DIALOG }) else dispatch({ type: HIDE_CANVAS_DIALOG }) return () => dispatch({ type: HIDE_CANVAS_DIALOG }) }, [show, dispatch]) const component = show ? ( {dialogProps.title || 'Allowed Domains'} ) : null return createPortal(component, portalElement) } SpeechToTextDialog.propTypes = { show: PropTypes.bool, dialogProps: PropTypes.object, onCancel: PropTypes.func, onConfirm: PropTypes.func } export default SpeechToTextDialog