aboutsummaryrefslogtreecommitdiff
path: root/modern/src/components/registration/RegisterForm.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-09-04 16:50:33 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-09-04 16:50:33 -0700
commite1d618e524680ed5702d6d43bf808b4c665fa157 (patch)
tree6b918b7ec5dbd42dbff547b4089c4881b7b3ca0e /modern/src/components/registration/RegisterForm.js
parent2fd3fb3722cbbeccb5271c2d21e9518233b3961b (diff)
downloadtrackermap-web-e1d618e524680ed5702d6d43bf808b4c665fa157.tar.gz
trackermap-web-e1d618e524680ed5702d6d43bf808b4c665fa157.tar.bz2
trackermap-web-e1d618e524680ed5702d6d43bf808b4c665fa157.zip
Password reset page
Diffstat (limited to 'modern/src/components/registration/RegisterForm.js')
-rw-r--r--modern/src/components/registration/RegisterForm.js19
1 files changed, 8 insertions, 11 deletions
diff --git a/modern/src/components/registration/RegisterForm.js b/modern/src/components/registration/RegisterForm.js
index 2da33a28..d515b641 100644
--- a/modern/src/components/registration/RegisterForm.js
+++ b/modern/src/components/registration/RegisterForm.js
@@ -8,7 +8,7 @@ import StartPage from '../../StartPage';
import { useTranslation } from '../../LocalizationProvider';
const useStyles = makeStyles((theme) => ({
- register: {
+ title: {
fontSize: theme.spacing(3),
fontWeight: 500,
marginLeft: theme.spacing(2),
@@ -32,15 +32,12 @@ const RegisterForm = () => {
const [password, setPassword] = useState('');
const [snackbarOpen, setSnackbarOpen] = useState(false);
- const submitDisabled = () => !name || !/(.+)@(.+)\.(.{2,})/.test(email) || !password;
-
- const handleRegister = async () => {
+ const handleSubmit = async () => {
const response = await fetch('/api/users', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ name, email, password }),
});
-
if (response.ok) {
setSnackbarOpen(true);
}
@@ -65,7 +62,7 @@ const RegisterForm = () => {
</Typography>
</Grid>
<Grid item xs>
- <Typography className={classes.register} color="primary">
+ <Typography className={classes.title} color="primary">
{t('loginRegister')}
</Typography>
</Grid>
@@ -76,7 +73,7 @@ const RegisterForm = () => {
fullWidth
label={t('sharedName')}
name="name"
- value={name || ''}
+ value={name}
autoComplete="name"
autoFocus
onChange={(event) => setName(event.target.value)}
@@ -90,7 +87,7 @@ const RegisterForm = () => {
type="email"
label={t('userEmail')}
name="email"
- value={email || ''}
+ value={email}
autoComplete="email"
onChange={(event) => setEmail(event.target.value)}
variant="filled"
@@ -102,7 +99,7 @@ const RegisterForm = () => {
fullWidth
label={t('userPassword')}
name="password"
- value={password || ''}
+ value={password}
type="password"
autoComplete="current-password"
onChange={(event) => setPassword(event.target.value)}
@@ -113,8 +110,8 @@ const RegisterForm = () => {
<Button
variant="contained"
color="secondary"
- onClick={handleRegister}
- disabled={submitDisabled()}
+ onClick={handleSubmit}
+ disabled={!name || !/(.+)@(.+)\.(.{2,})/.test(email) || !password}
fullWidth
>
{t('loginRegister')}