added fixes

This commit is contained in:
2020-04-30 21:27:54 +02:00
parent 6d24cb5c53
commit 083f73ec2b
3 changed files with 56 additions and 7 deletions

View File

@@ -34,7 +34,7 @@ const useStyles = makeStyles(theme => ({
const CssTextField = withStyles({
root: {
'& label.Mui-focused': {
color: 'white',
color: '#FFC800',
},
'&:hover label': {
color: '#FFC800',
@@ -54,7 +54,7 @@ const CssTextField = withStyles({
borderColor: "#FFC800",
},
'&.Mui-focused fieldset': {
borderColor: 'white',
borderColor: '#FFC800',
},
},
},
@@ -83,9 +83,9 @@ export default function CreateAccount() {
if (response.status == "200") {
setLogin(false)
}
setTimeout(() => { setStatus(null) }, 5000)
}
const handleClick = (e) => {
if (username !== "" && password !== "") {
putCreateAccount(url, { email: username, password: password })
@@ -93,6 +93,17 @@ export default function CreateAccount() {
setPassword("")
}
}
const handleKeyDown = (e) => {
if (e.keyCode == 13) {
if (username !== "" && password !== "") {
putCreateAccount(url, { email: username, password: password })
setUsername("")
setPassword("")
}
}
}
const handleChangeUSR = (e) => {
setUsername(e.target.value)
}
@@ -121,18 +132,21 @@ export default function CreateAccount() {
<Grid item xs={12} >
<Box display="flex" justifyContent="center" >
<CssTextField
error={status != null && status != "200"}
id="usernameInput"
label="Username"
variant="outlined"
onChange={handleChangeUSR}
value={username}
className={classes.input}
onKeyDown={handleKeyDown}
/>
</Box >
</Grid>
<Grid item xs={12}>
<Box display="flex" justifyContent="center" >
<CssTextField
error={status != null && status != "200"}
id="passwordInput"
type="password"
label="Password"
@@ -141,12 +155,13 @@ export default function CreateAccount() {
value={password}
onChange={handleChangePW}
className={classes.input}
onKeyDown={handleKeyDown}
/>
</Box >
</Grid>
<Grid item xs={12}>
<Box display="flex" justifyContent="center" >
<Button variant="contained" color="secondary" onClick={handleClick}>
<Button variant="contained" color="secondary" onClick={handleClick} >
Create Account
</Button>
</Box >