diff options
author | Anton Tananaev <anton@traccar.org> | 2023-01-15 17:37:20 -0800 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2023-01-15 17:37:20 -0800 |
commit | 4290739f81aaed0a56fc5f575f558e5339b2ccf9 (patch) | |
tree | bf010481b6e6686c2a7ad8e3f287385bc17acff4 /modern/src/login | |
parent | 117ded36572449077da6176754f29ea510bec900 (diff) | |
download | trackermap-web-4290739f81aaed0a56fc5f575f558e5339b2ccf9.tar.gz trackermap-web-4290739f81aaed0a56fc5f575f558e5339b2ccf9.tar.bz2 trackermap-web-4290739f81aaed0a56fc5f575f558e5339b2ccf9.zip |
Remove default admin
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')} /> |