aboutsummaryrefslogtreecommitdiff
path: root/modern/src/components/registration/RegisterForm.js
diff options
context:
space:
mode:
Diffstat (limited to 'modern/src/components/registration/RegisterForm.js')
-rw-r--r--modern/src/components/registration/RegisterForm.js82
1 files changed, 43 insertions, 39 deletions
diff --git a/modern/src/components/registration/RegisterForm.js b/modern/src/components/registration/RegisterForm.js
index b2a8222..06f5355 100644
--- a/modern/src/components/registration/RegisterForm.js
+++ b/modern/src/components/registration/RegisterForm.js
@@ -1,27 +1,28 @@
import React, { useState } from 'react';
-import { Grid, Button, TextField, Typography, Link, makeStyles, Snackbar } from '@material-ui/core';
+import {
+ Grid, Button, TextField, Typography, Link, makeStyles, Snackbar,
+} from '@material-ui/core';
import { useHistory } from 'react-router-dom';
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
-import StartPage from './../../StartPage';
-import t from './../../common/localization';
+import StartPage from '../../StartPage';
+import t from '../../common/localization';
-const useStyles = makeStyles(theme => ({
+const useStyles = makeStyles((theme) => ({
register: {
fontSize: theme.spacing(3),
fontWeight: 500,
marginLeft: theme.spacing(2),
- textTransform: "uppercase"
+ textTransform: 'uppercase',
},
link: {
fontSize: theme.spacing(3),
fontWeight: 500,
marginTop: theme.spacing(0.5),
- cursor: 'pointer'
- }
+ cursor: 'pointer',
+ },
}));
const RegisterForm = () => {
-
const classes = useStyles();
const history = useHistory();
@@ -30,21 +31,19 @@ const RegisterForm = () => {
const [password, setPassword] = useState('');
const [snackbarOpen, setSnackbarOpen] = useState(false);
- const submitDisabled = () => {
- return !name || !/(.+)@(.+)\.(.{2,})/.test(email) || !password;
- }
+ const submitDisabled = () => !name || !/(.+)@(.+)\.(.{2,})/.test(email) || !password;
const handleRegister = async () => {
const response = await fetch('/api/users', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({name, email, password})
+ body: JSON.stringify({ name, email, password }),
});
if (response.ok) {
setSnackbarOpen(true);
- }
- }
+ }
+ };
return (
<StartPage>
@@ -53,18 +52,19 @@ const RegisterForm = () => {
open={snackbarOpen}
onClose={() => history.push('/login')}
autoHideDuration={6000}
- message={t('loginCreated')} />
- <Grid container direction='column' spacing={2}>
+ message={t('loginCreated')}
+ />
+ <Grid container direction="column" spacing={2}>
<Grid container item>
<Grid item>
- <Typography className={classes.link} color='primary'>
+ <Typography className={classes.link} color="primary">
<Link onClick={() => history.push('/login')}>
<ArrowBackIcon />
</Link>
</Typography>
</Grid>
<Grid item xs>
- <Typography className={classes.register} color='primary'>
+ <Typography className={classes.register} color="primary">
{t('loginRegister')}
</Typography>
</Grid>
@@ -74,50 +74,54 @@ const RegisterForm = () => {
required
fullWidth
label={t('sharedName')}
- name='name'
+ name="name"
value={name || ''}
- autoComplete='name'
+ autoComplete="name"
autoFocus
- onChange={event => setName(event.target.value)}
- variant='filled' />
+ onChange={(event) => setName(event.target.value)}
+ variant="filled"
+ />
</Grid>
<Grid item>
<TextField
required
fullWidth
- type='email'
+ type="email"
label={t('userEmail')}
- name='email'
+ name="email"
value={email || ''}
- autoComplete='email'
- onChange={event => setEmail(event.target.value)}
- variant='filled' />
+ autoComplete="email"
+ onChange={(event) => setEmail(event.target.value)}
+ variant="filled"
+ />
</Grid>
<Grid item>
<TextField
required
fullWidth
label={t('userPassword')}
- name='password'
+ name="password"
value={password || ''}
- type='password'
- autoComplete='current-password'
- onChange={event => setPassword(event.target.value)}
- variant='filled' />
+ type="password"
+ autoComplete="current-password"
+ onChange={(event) => setPassword(event.target.value)}
+ variant="filled"
+ />
</Grid>
<Grid item>
<Button
- variant='contained'
- color="secondary"
- onClick={handleRegister}
+ variant="contained"
+ color="secondary"
+ onClick={handleRegister}
disabled={submitDisabled()}
- fullWidth>
- {t('loginRegister')}
+ fullWidth
+ >
+ {t('loginRegister')}
</Button>
</Grid>
</Grid>
</StartPage>
- )
-}
+ );
+};
export default RegisterForm;