Skip to content
Snippets Groups Projects
Verified Commit 946f5bb4 authored by Defendi Alberto's avatar Defendi Alberto
Browse files

Attach form. Prepare onSubmit. Replace TextFields.

parent 9c822c57
No related branches found
No related tags found
2 merge requests!56Refined auth flow and new website pages.,!55Refactoring to reservation page.
Pipeline #12492 passed
...@@ -22,6 +22,9 @@ import Fab from '@material-ui/core/Fab'; ...@@ -22,6 +22,9 @@ import Fab from '@material-ui/core/Fab';
import { NavBar } from 'components/Dashboard/HomePage/NavBar'; import { NavBar } from 'components/Dashboard/HomePage/NavBar';
import { Reservation } from 'components/Dashboard/ReservationPage/Reservation/Reservation'; import { Reservation } from 'components/Dashboard/ReservationPage/Reservation/Reservation';
import { useReservations } from 'hooks/useReservations'; import { useReservations } from 'hooks/useReservations';
import { ReservationProps } from 'components/Dashboard/ReservationPage/Reservation/ReservationProps';
import { SubmitHandler, useForm } from 'react-hook-form';
import { InputField } from 'components/Auth/InputField/InputField';
let themeResp = createMuiTheme(); let themeResp = createMuiTheme();
themeResp = responsiveFontSizes(themeResp); themeResp = responsiveFontSizes(themeResp);
...@@ -78,6 +81,7 @@ const useStyles = makeStyles(() => ({ ...@@ -78,6 +81,7 @@ const useStyles = makeStyles(() => ({
export const ReservationPage: FC = () => { export const ReservationPage: FC = () => {
const classes = useStyles(); const classes = useStyles();
const { control, handleSubmit } = useForm<ReservationProps>();
const [open, setOpen] = React.useState(false); const [open, setOpen] = React.useState(false);
...@@ -91,6 +95,12 @@ export const ReservationPage: FC = () => { ...@@ -91,6 +95,12 @@ export const ReservationPage: FC = () => {
setOpen(false); setOpen(false);
}; };
const onSubmit: SubmitHandler<ReservationProps> = (
data: ReservationProps,
) => {
console.log(data);
};
return ( return (
<div data-testid="Reservation"> <div data-testid="Reservation">
<Grid container direction="column" className={classes.paddingBottom}> <Grid container direction="column" className={classes.paddingBottom}>
...@@ -106,56 +116,54 @@ export const ReservationPage: FC = () => { ...@@ -106,56 +116,54 @@ export const ReservationPage: FC = () => {
onClose={handleOpen} onClose={handleOpen}
aria-labelledby="form-dialog-title" aria-labelledby="form-dialog-title"
> >
<DialogTitle id="form-dialog-title"> <form onSubmit={handleSubmit(onSubmit)} data-testid="Form">
Book New Reservation <DialogTitle id="form-dialog-title">
</DialogTitle> Book New Reservation
<DialogContent> </DialogTitle>
<DialogContentText> <DialogContent>
Write here below the details of your next reservation <DialogContentText>
</DialogContentText> Write here below the details of your next reservation
<TextField </DialogContentText>
autoFocus
margin="dense" <InputField
id="name" name="name"
label="Name Reservation" label="Name Reservation"
type="text" type="text"
fullWidth control={control}
/> />
<TextField <InputField
autoFocus name="date"
margin="dense" label="Reservation date"
id="name" type="date"
label="Date" control={control}
type="date" />
fullWidth <InputField
InputLabelProps={{ shrink: true }} name="time"
/> label="Department Time"
<TextField type="time"
autoFocus control={control}
margin="dense" />
id="name" <InputField
label="Department Time" name="destination"
type="time" label="Destination"
fullWidth type="text"
InputLabelProps={{ shrink: true }} control={control}
/> />
<TextField </DialogContent>
autoFocus <DialogActions>
margin="dense" <Button onClick={handleClose} color="primary">
id="name" Cancel
label="Destination" </Button>
type="text" <Button
fullWidth type="submit"
/> fullWidth
</DialogContent> variant="contained"
<DialogActions> color="primary"
<Button onClick={handleClose} color="primary"> >
Cancel Insert
</Button> </Button>
<Button onClick={handleClose} color="primary" variant="contained"> </DialogActions>
Subscribe </form>
</Button>
</DialogActions>
</Dialog> </Dialog>
<MuiThemeProvider theme={themeResp}> <MuiThemeProvider theme={themeResp}>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment