|
| 1 | +import React, { useState } from "react"; |
| 2 | +import { createStyles, makeStyles, Theme } from "@material-ui/core/styles"; |
| 3 | +import Dialog from "@material-ui/core/Dialog"; |
| 4 | +import Typography from "@material-ui/core/Typography"; |
| 5 | +import GoogleButton from "../Buttons/GoogleButton"; |
| 6 | +import Login from "./Login"; |
| 7 | +import ResetPassword from "./ResetPassword"; |
| 8 | +import Signup from "./Signup"; |
| 9 | +import { DialogContent } from "@material-ui/core"; |
| 10 | + |
| 11 | +const useStyles = makeStyles((theme: Theme) => |
| 12 | + createStyles({ |
| 13 | + title: { |
| 14 | + margin: "4vh", |
| 15 | + fontWeight: "bold", |
| 16 | + fontSize: "1.4rem", |
| 17 | + }, |
| 18 | + main: { |
| 19 | + width: "30vw", |
| 20 | + [theme.breakpoints.down("sm")]: { |
| 21 | + width: "70vw", |
| 22 | + }, |
| 23 | + }, |
| 24 | + or: { |
| 25 | + margin: "2vh", |
| 26 | + }, |
| 27 | + }) |
| 28 | +); |
| 29 | + |
| 30 | +interface AuthDialogProps { |
| 31 | + isOpen: boolean; |
| 32 | +} |
| 33 | +const AuthDialog: React.FC<AuthDialogProps> = ({ isOpen }) => { |
| 34 | + const classes = useStyles(); |
| 35 | + const [page, setPage] = useState(0); |
| 36 | + const heading = ["Login", "Sign Up", "Reset Password"]; |
| 37 | + const component = [ |
| 38 | + <Login setPage={setPage} />, |
| 39 | + <Signup setPage={setPage} />, |
| 40 | + <ResetPassword setPage={setPage} />, |
| 41 | + ]; |
| 42 | + |
| 43 | + return ( |
| 44 | + <Dialog |
| 45 | + aria-labelledby="customized-dialog-title" |
| 46 | + open={isOpen} |
| 47 | + maxWidth={false} |
| 48 | + > |
| 49 | + <DialogContent className={classes.main}> |
| 50 | + <Typography className={classes.title} align="center"> |
| 51 | + {heading[page]} |
| 52 | + </Typography> |
| 53 | + <GoogleButton /> |
| 54 | + <Typography className={classes.or} align="center"> |
| 55 | + OR |
| 56 | + </Typography> |
| 57 | + {component[page]} |
| 58 | + </DialogContent> |
| 59 | + </Dialog> |
| 60 | + ); |
| 61 | +}; |
| 62 | + |
| 63 | +export default AuthDialog; |
0 commit comments