import { createPortal } from 'react-dom' import { useState } from 'react' import PropTypes from 'prop-types' import { Dialog, DialogActions, DialogContent, Typography, DialogTitle } from '@mui/material' import { StyledButton } from 'ui-component/button/StyledButton' import { Input } from 'ui-component/input/Input' const LoginDialog = ({ show, dialogProps, onConfirm }) => { const portalElement = document.getElementById('portal') const usernameInput = { label: 'Username', name: 'username', type: 'string', placeholder: 'john doe' } const passwordInput = { label: 'Password', name: 'password', type: 'password' } const [usernameVal, setUsernameVal] = useState('') const [passwordVal, setPasswordVal] = useState('') const component = show ? ( { if (e.key === 'Enter') { onConfirm(usernameVal, passwordVal) } }} open={show} fullWidth maxWidth='xs' aria-labelledby='alert-dialog-title' aria-describedby='alert-dialog-description' > {dialogProps.title} Username setUsernameVal(newValue)} value={usernameVal} showDialog={false} />
Password setPasswordVal(newValue)} value={passwordVal} />
onConfirm(usernameVal, passwordVal)}> {dialogProps.confirmButtonName}
) : null return createPortal(component, portalElement) } LoginDialog.propTypes = { show: PropTypes.bool, dialogProps: PropTypes.object, onConfirm: PropTypes.func } export default LoginDialog