added fixes
This commit is contained in:
@@ -34,7 +34,7 @@ const useStyles = makeStyles(theme => ({
|
|||||||
const CssTextField = withStyles({
|
const CssTextField = withStyles({
|
||||||
root: {
|
root: {
|
||||||
'& label.Mui-focused': {
|
'& label.Mui-focused': {
|
||||||
color: 'white',
|
color: '#FFC800',
|
||||||
},
|
},
|
||||||
'&:hover label': {
|
'&:hover label': {
|
||||||
color: '#FFC800',
|
color: '#FFC800',
|
||||||
@@ -54,7 +54,7 @@ const CssTextField = withStyles({
|
|||||||
borderColor: "#FFC800",
|
borderColor: "#FFC800",
|
||||||
},
|
},
|
||||||
'&.Mui-focused fieldset': {
|
'&.Mui-focused fieldset': {
|
||||||
borderColor: 'white',
|
borderColor: '#FFC800',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -83,9 +83,9 @@ export default function CreateAccount() {
|
|||||||
if (response.status == "200") {
|
if (response.status == "200") {
|
||||||
setLogin(false)
|
setLogin(false)
|
||||||
}
|
}
|
||||||
|
setTimeout(() => { setStatus(null) }, 5000)
|
||||||
}
|
}
|
||||||
const handleClick = (e) => {
|
const handleClick = (e) => {
|
||||||
|
|
||||||
if (username !== "" && password !== "") {
|
if (username !== "" && password !== "") {
|
||||||
putCreateAccount(url, { email: username, password: password })
|
putCreateAccount(url, { email: username, password: password })
|
||||||
|
|
||||||
@@ -93,6 +93,17 @@ export default function CreateAccount() {
|
|||||||
setPassword("")
|
setPassword("")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleKeyDown = (e) => {
|
||||||
|
if (e.keyCode == 13) {
|
||||||
|
if (username !== "" && password !== "") {
|
||||||
|
putCreateAccount(url, { email: username, password: password })
|
||||||
|
|
||||||
|
setUsername("")
|
||||||
|
setPassword("")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
const handleChangeUSR = (e) => {
|
const handleChangeUSR = (e) => {
|
||||||
setUsername(e.target.value)
|
setUsername(e.target.value)
|
||||||
}
|
}
|
||||||
@@ -121,18 +132,21 @@ export default function CreateAccount() {
|
|||||||
<Grid item xs={12} >
|
<Grid item xs={12} >
|
||||||
<Box display="flex" justifyContent="center" >
|
<Box display="flex" justifyContent="center" >
|
||||||
<CssTextField
|
<CssTextField
|
||||||
|
error={status != null && status != "200"}
|
||||||
id="usernameInput"
|
id="usernameInput"
|
||||||
label="Username"
|
label="Username"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
onChange={handleChangeUSR}
|
onChange={handleChangeUSR}
|
||||||
value={username}
|
value={username}
|
||||||
className={classes.input}
|
className={classes.input}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
/>
|
/>
|
||||||
</Box >
|
</Box >
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<Box display="flex" justifyContent="center" >
|
<Box display="flex" justifyContent="center" >
|
||||||
<CssTextField
|
<CssTextField
|
||||||
|
error={status != null && status != "200"}
|
||||||
id="passwordInput"
|
id="passwordInput"
|
||||||
type="password"
|
type="password"
|
||||||
label="Password"
|
label="Password"
|
||||||
@@ -141,12 +155,13 @@ export default function CreateAccount() {
|
|||||||
value={password}
|
value={password}
|
||||||
onChange={handleChangePW}
|
onChange={handleChangePW}
|
||||||
className={classes.input}
|
className={classes.input}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
/>
|
/>
|
||||||
</Box >
|
</Box >
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<Box display="flex" justifyContent="center" >
|
<Box display="flex" justifyContent="center" >
|
||||||
<Button variant="contained" color="secondary" onClick={handleClick}>
|
<Button variant="contained" color="secondary" onClick={handleClick} >
|
||||||
Create Account
|
Create Account
|
||||||
</Button>
|
</Button>
|
||||||
</Box >
|
</Box >
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ export default function Login() {
|
|||||||
const [status, setStatus] = React.useState(null);
|
const [status, setStatus] = React.useState(null);
|
||||||
|
|
||||||
const postLogin = async (url, data) => {
|
const postLogin = async (url, data) => {
|
||||||
|
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url, {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
mode: 'cors',
|
mode: 'cors',
|
||||||
@@ -85,6 +86,8 @@ export default function Login() {
|
|||||||
if (response.status == "200") {
|
if (response.status == "200") {
|
||||||
setLogin(false)
|
setLogin(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setTimeout(() => { setStatus(null) }, 5000)
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleClick = (e) => {
|
const handleClick = (e) => {
|
||||||
@@ -96,6 +99,18 @@ export default function Login() {
|
|||||||
setPassword("")
|
setPassword("")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handleKeyDown = (e) => {
|
||||||
|
if (e.keyCode == 13) {
|
||||||
|
if (username !== "" && password !== "") {
|
||||||
|
postLogin(url, { email: username, password: password })
|
||||||
|
|
||||||
|
setUsername("")
|
||||||
|
setPassword("")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const handleChangeUSR = (e) => {
|
const handleChangeUSR = (e) => {
|
||||||
setUsername(e.target.value)
|
setUsername(e.target.value)
|
||||||
}
|
}
|
||||||
@@ -126,18 +141,21 @@ export default function Login() {
|
|||||||
<Grid item xs={12} >
|
<Grid item xs={12} >
|
||||||
<Box display="flex" justifyContent="center" >
|
<Box display="flex" justifyContent="center" >
|
||||||
<CssTextField
|
<CssTextField
|
||||||
|
error={status != null && status != "200"}
|
||||||
id="usernameInput"
|
id="usernameInput"
|
||||||
label="Username"
|
label="Username"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
value={username}
|
value={username}
|
||||||
onChange={handleChangeUSR}
|
onChange={handleChangeUSR}
|
||||||
className={classes.input}
|
className={classes.input}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
/>
|
/>
|
||||||
</Box >
|
</Box >
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<Box display="flex" justifyContent="center" >
|
<Box display="flex" justifyContent="center" >
|
||||||
<CssTextField
|
<CssTextField
|
||||||
|
error={status != null && status != "200"}
|
||||||
id="passwordInput"
|
id="passwordInput"
|
||||||
type="password"
|
type="password"
|
||||||
label="Password"
|
label="Password"
|
||||||
@@ -146,6 +164,7 @@ export default function Login() {
|
|||||||
value={password}
|
value={password}
|
||||||
onChange={handleChangePW}
|
onChange={handleChangePW}
|
||||||
className={classes.input}
|
className={classes.input}
|
||||||
|
onKeyDown={handleKeyDown}
|
||||||
/>
|
/>
|
||||||
</Box >
|
</Box >
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -10,12 +10,20 @@ export default function LoginFeedback(props) {
|
|||||||
const [login, setLogin] = React.useState(null);
|
const [login, setLogin] = React.useState(null);
|
||||||
const [open, setOpen] = React.useState(true);
|
const [open, setOpen] = React.useState(true);
|
||||||
const [open1, setOpen1] = React.useState(true);
|
const [open1, setOpen1] = React.useState(true);
|
||||||
|
const [output, setOutput] = React.useState(null);
|
||||||
|
const [change, setChange] = React.useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (login != props.login) {
|
if (login != props.login) {
|
||||||
|
setChange(true)
|
||||||
|
setOpen(true)
|
||||||
|
setOpen1(true)
|
||||||
setLogin(props.login)
|
setLogin(props.login)
|
||||||
}
|
}
|
||||||
}, [login, setLogin, props.login]);
|
}, [login, setLogin, props.login]);
|
||||||
|
|
||||||
const handleClose = (event, reason) => {
|
const handleClose = (event, reason) => {
|
||||||
|
|
||||||
setOpen(false);
|
setOpen(false);
|
||||||
};
|
};
|
||||||
const handleClose1 = (event, reason) => {
|
const handleClose1 = (event, reason) => {
|
||||||
@@ -24,26 +32,33 @@ export default function LoginFeedback(props) {
|
|||||||
|
|
||||||
const snack = (login) => {
|
const snack = (login) => {
|
||||||
if (login == "200") {
|
if (login == "200") {
|
||||||
return (
|
setOutput(
|
||||||
<Snackbar open={open} autoHideDuration={2000} onClose={handleClose}>
|
<Snackbar open={open} autoHideDuration={2000} onClose={handleClose}>
|
||||||
<Alert onClose={handleClose} severity="success">
|
<Alert onClose={handleClose} severity="success">
|
||||||
{props.successText}
|
{props.successText}
|
||||||
</Alert>
|
</Alert>
|
||||||
</Snackbar>)
|
</Snackbar>)
|
||||||
} else if (login != null) {
|
} else if (login != null) {
|
||||||
return (
|
setOutput(
|
||||||
<Snackbar open={open1} autoHideDuration={3000} onClose={handleClose1}>
|
<Snackbar open={open1} autoHideDuration={3000} onClose={handleClose1}>
|
||||||
<Alert onClose={handleClose1} severity="error">
|
<Alert onClose={handleClose1} severity="error">
|
||||||
{props.errorText}
|
{props.errorText}
|
||||||
</Alert>
|
</Alert>
|
||||||
</Snackbar>
|
</Snackbar>
|
||||||
)
|
)
|
||||||
|
} else {
|
||||||
|
setOutput(null)
|
||||||
}
|
}
|
||||||
|
setChange(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (change == true) {
|
||||||
|
snack(login)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
{snack(login)}
|
{output}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user