-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create base LoginForm -- nonfunctional
- Loading branch information
Justin Campbell
committed
Nov 13, 2020
1 parent
4757b28
commit 4e40b02
Showing
3 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import React, { useState } from "react"; | ||
import { Box, Paper, TextField, Button, Avatar, Typography, useTheme, makeStyles } from "@material-ui/core"; | ||
import { Redirect } from "react-router-dom"; | ||
import { useLogin } from "../AuthProvider/"; | ||
|
||
export default function LoginForm() { | ||
const [username, setUsername] = useState(""); | ||
const [password, setPassword] = useState(""); | ||
|
||
const handleUsernameChange = (event) => setUsername(event.target.value); | ||
const handlePasswordChange = (event) => setPassword(event.target.value); | ||
|
||
const handleSubmit = (event) => { | ||
event.preventDefault(); | ||
return true; | ||
} | ||
|
||
const theme = useTheme(); | ||
const useStyles = makeStyles({ | ||
"box_root": { | ||
background: `linear-gradient(120deg, ${theme.palette.secondary.main}30 0%, ${theme.palette.primary.main}10 100%)`, | ||
width: "100%", | ||
height: "100vh", | ||
display: "flex", | ||
justifyContent: "center", | ||
alignItems: "center" | ||
}, | ||
"avatar_root": { | ||
padding: theme.spacing(1), | ||
width: theme.spacing(10), | ||
height: theme.spacing(10) | ||
}, | ||
"paper_root": { | ||
minWidth: theme.breakpoints.values.sm/2, | ||
padding: theme.spacing(3), | ||
display: "flex", | ||
flexDirection: "column", | ||
justifyContent: "center", | ||
alignItems: "center", | ||
}, | ||
"button_root": { | ||
marginTop: theme.spacing(2) | ||
} | ||
}) | ||
const classes = useStyles(); | ||
|
||
const isLoggedIn = useLogin(); | ||
if (isLoggedIn) { | ||
return <Redirect to="/"/> | ||
} | ||
|
||
return ( | ||
<Box classes={{ root: classes.box_root }}> | ||
<form onSubmit={handleSubmit}> | ||
<Paper classes={{ root: classes.paper_root }}> | ||
<Avatar | ||
src={process.env.PUBLIC_URL + "/logo512.png"} | ||
classes={{ root: classes.avatar_root }} | ||
/> | ||
<Typography variant="h4"> | ||
Sign In | ||
</Typography> | ||
<TextField | ||
type="text" | ||
id="username" | ||
name="username" | ||
label="Username" | ||
fullWidth | ||
value={username} | ||
onChange={handleUsernameChange} | ||
autoFocus | ||
margin="normal" | ||
variant="outlined" | ||
/> | ||
<TextField | ||
type="password" | ||
id="password" | ||
name="password" | ||
label="Password" | ||
fullWidth | ||
value={password} | ||
onChange={handlePasswordChange} | ||
margin="normal" | ||
variant="outlined" | ||
/> | ||
<Button | ||
color="primary" | ||
size="large" | ||
variant="contained" | ||
fullWidth | ||
classes={{ root: classes.button_root }} | ||
type="submit" | ||
> | ||
Sign In | ||
</Button> | ||
</Paper> | ||
</form> | ||
</Box> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
The LoginForm acts as the only public facing page for the webqueue2. If any part of the app is access without access tokens, the user will be redirected here. It takes a username and password, attempts to login an, if successful, sets access tokens and redirects users to webqueue2. | ||
|
||
--- | ||
```jsx | ||
import LoginForm from "./LoginForm"; | ||
|
||
<LoginForm /> | ||
``` | ||
```jsx static | ||
<LoginForm /> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "./LoginForm"; |