diff options
Diffstat (limited to 'modern/src/login')
-rw-r--r-- | modern/src/login/RegisterPage.js | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/modern/src/login/RegisterPage.js b/modern/src/login/RegisterPage.js index 08ff3e8f..6dfe40a4 100644 --- a/modern/src/login/RegisterPage.js +++ b/modern/src/login/RegisterPage.js @@ -1,4 +1,5 @@ import React, { useState } from 'react'; +import { useDispatch, useSelector } from 'react-redux'; import { Button, TextField, Typography, Snackbar, IconButton, } from '@mui/material'; @@ -9,6 +10,7 @@ import LoginLayout from './LoginLayout'; import { useTranslation } from '../common/components/LocalizationProvider'; import { snackBarDurationShortMs } from '../common/util/duration'; import { useCatch } from '../reactHelper'; +import { sessionActions } from '../store'; const useStyles = makeStyles((theme) => ({ container: { @@ -30,9 +32,12 @@ const useStyles = makeStyles((theme) => ({ const RegisterPage = () => { const classes = useStyles(); + const dispatch = useDispatch(); const navigate = useNavigate(); const t = useTranslation(); + const server = useSelector((state) => state.session.server); + const [name, setName] = useState(''); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); @@ -55,9 +60,11 @@ const RegisterPage = () => { <LoginLayout> <div className={classes.container}> <div className={classes.header}> - <IconButton color="primary" onClick={() => navigate('/login')}> - <ArrowBackIcon /> - </IconButton> + {!server.newServer && ( + <IconButton color="primary" onClick={() => navigate('/login')}> + <ArrowBackIcon /> + </IconButton> + )} <Typography className={classes.title} color="primary"> {t('loginRegister')} </Typography> @@ -93,7 +100,7 @@ const RegisterPage = () => { variant="contained" color="secondary" onClick={handleSubmit} - disabled={!name || !/(.+)@(.+)\.(.{2,})/.test(email) || !password} + disabled={!name || !password || !(server.newServer || /(.+)@(.+)\.(.{2,})/.test(email))} fullWidth > {t('loginRegister')} @@ -101,7 +108,10 @@ const RegisterPage = () => { </div> <Snackbar open={snackbarOpen} - onClose={() => navigate('/login')} + onClose={() => { + dispatch(sessionActions.updateServer({ ...server, newServer: false })); + navigate('/login'); + }} autoHideDuration={snackBarDurationShortMs} message={t('loginCreated')} /> |