import { createPortal } from 'react-dom' import { useState, useEffect } from 'react' import PropTypes from 'prop-types' import { Button, Dialog, DialogActions, DialogContent, OutlinedInput, DialogTitle } from '@mui/material' import { StyledButton } from 'ui-component/button/StyledButton' const SaveChatflowDialog = ({ show, dialogProps, onCancel, onConfirm }) => { const portalElement = document.getElementById('portal') const [chatflowName, setChatflowName] = useState('') const [isReadyToSave, setIsReadyToSave] = useState(false) useEffect(() => { if (chatflowName) setIsReadyToSave(true) else setIsReadyToSave(false) }, [chatflowName]) const component = show ? ( {dialogProps.title} setChatflowName(e.target.value)} /> onConfirm(chatflowName)}> {dialogProps.confirmButtonName} ) : null return createPortal(component, portalElement) } SaveChatflowDialog.propTypes = { show: PropTypes.bool, dialogProps: PropTypes.object, onCancel: PropTypes.func, onConfirm: PropTypes.func } export default SaveChatflowDialog