Some checks failed
No response / noResponse (push) Has been cancelled
CI / Continuous releases (push) Has been cancelled
CI / test-dev (macos-latest) (push) Has been cancelled
CI / test-dev (ubuntu-latest) (push) Has been cancelled
CI / test-dev (windows-latest) (push) Has been cancelled
Maintenance / main (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
66 lines
1.9 KiB
TypeScript
66 lines
1.9 KiB
TypeScript
import * as React from 'react';
|
|
import Button from '@mui/material/Button';
|
|
import TextField from '@mui/material/TextField';
|
|
import Dialog from '@mui/material/Dialog';
|
|
import DialogActions from '@mui/material/DialogActions';
|
|
import DialogContent from '@mui/material/DialogContent';
|
|
import DialogContentText from '@mui/material/DialogContentText';
|
|
import DialogTitle from '@mui/material/DialogTitle';
|
|
|
|
export default function FormDialog() {
|
|
const [open, setOpen] = React.useState(false);
|
|
|
|
const handleClickOpen = () => {
|
|
setOpen(true);
|
|
};
|
|
|
|
const handleClose = () => {
|
|
setOpen(false);
|
|
};
|
|
|
|
const handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
|
|
event.preventDefault();
|
|
const formData = new FormData(event.currentTarget);
|
|
const formJson = Object.fromEntries((formData as any).entries());
|
|
const email = formJson.email;
|
|
console.log(email);
|
|
handleClose();
|
|
};
|
|
|
|
return (
|
|
<React.Fragment>
|
|
<Button variant="outlined" onClick={handleClickOpen}>
|
|
Open form dialog
|
|
</Button>
|
|
<Dialog open={open} onClose={handleClose}>
|
|
<DialogTitle>Subscribe</DialogTitle>
|
|
<DialogContent>
|
|
<DialogContentText>
|
|
To subscribe to this website, please enter your email address here. We
|
|
will send updates occasionally.
|
|
</DialogContentText>
|
|
<form onSubmit={handleSubmit} id="subscription-form">
|
|
<TextField
|
|
autoFocus
|
|
required
|
|
margin="dense"
|
|
id="name"
|
|
name="email"
|
|
label="Email Address"
|
|
type="email"
|
|
fullWidth
|
|
variant="standard"
|
|
/>
|
|
</form>
|
|
</DialogContent>
|
|
<DialogActions>
|
|
<Button onClick={handleClose}>Cancel</Button>
|
|
<Button type="submit" form="subscription-form">
|
|
Subscribe
|
|
</Button>
|
|
</DialogActions>
|
|
</Dialog>
|
|
</React.Fragment>
|
|
);
|
|
}
|