aboutsummaryrefslogtreecommitdiff
path: root/modern/src/components/registration
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-04-17 15:59:50 -0700
committerAnton Tananaev <anton@traccar.org>2022-04-17 15:59:50 -0700
commiteecd28e9513c0376afac4adc4b21fa056efe4230 (patch)
treed15fb6d062e6478eaba7f453dbe18feff7e25f7a /modern/src/components/registration
parentad8484a08ef7eabb41afb33a9774ba8502da1d53 (diff)
downloadtrackermap-web-eecd28e9513c0376afac4adc4b21fa056efe4230.tar.gz
trackermap-web-eecd28e9513c0376afac4adc4b21fa056efe4230.tar.bz2
trackermap-web-eecd28e9513c0376afac4adc4b21fa056efe4230.zip
Add announcement snackbar
Diffstat (limited to 'modern/src/components/registration')
-rw-r--r--modern/src/components/registration/LoginForm.js24
-rw-r--r--modern/src/components/registration/RegisterForm.js3
-rw-r--r--modern/src/components/registration/ResetPasswordForm.js3
3 files changed, 23 insertions, 7 deletions
diff --git a/modern/src/components/registration/LoginForm.js b/modern/src/components/registration/LoginForm.js
index bbb5d5fb..d43d19a8 100644
--- a/modern/src/components/registration/LoginForm.js
+++ b/modern/src/components/registration/LoginForm.js
@@ -1,7 +1,8 @@
import React, { useState } from 'react';
import {
- Grid, useMediaQuery, makeStyles, InputLabel, Select, MenuItem, FormControl, Button, TextField, Link,
+ Grid, useMediaQuery, makeStyles, InputLabel, Select, MenuItem, FormControl, Button, TextField, Link, Snackbar, IconButton,
} from '@material-ui/core';
+import CloseIcon from '@material-ui/icons/Close';
import { useTheme } from '@material-ui/core/styles';
import { useDispatch, useSelector } from 'react-redux';
import { useHistory } from 'react-router-dom';
@@ -38,6 +39,9 @@ const LoginForm = () => {
const registrationEnabled = useSelector((state) => (state.session.server ? state.session.server.registration : false));
const emailEnabled = useSelector((state) => (state.session.server ? state.session.server.emailEnabled : false));
+ const [announcementShown, setAnnouncementShown] = useState(false);
+ const announcement = useSelector((state) => (state.session.server && state.session.server.announcement));
+
const handleSubmit = async (event) => {
event.preventDefault();
const response = await fetch('/api/session', {
@@ -131,12 +135,22 @@ const LoginForm = () => {
</Grid>
</Grid>
{emailEnabled && (
- <Grid item container justify="flex-end">
- <Grid item>
- <Link onClick={() => history.push('/reset-password')} className={classes.resetPassword} underline="none">{t('loginReset')}</Link>
+ <Grid item container justify="flex-end">
+ <Grid item>
+ <Link onClick={() => history.push('/reset-password')} className={classes.resetPassword} underline="none">{t('loginReset')}</Link>
+ </Grid>
</Grid>
- </Grid>
)}
+ <Snackbar
+ anchorOrigin={{ vertical: 'top', horizontal: 'center' }}
+ open={announcement && !announcementShown}
+ message={announcement}
+ action={
+ <IconButton size="small" color="inherit" onClick={() => setAnnouncementShown(true)}>
+ <CloseIcon fontSize="small" />
+ </IconButton>
+ }
+ />
</Grid>
</StartPage>
);
diff --git a/modern/src/components/registration/RegisterForm.js b/modern/src/components/registration/RegisterForm.js
index d515b641..11dd510e 100644
--- a/modern/src/components/registration/RegisterForm.js
+++ b/modern/src/components/registration/RegisterForm.js
@@ -6,6 +6,7 @@ import { useHistory } from 'react-router-dom';
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
import StartPage from '../../StartPage';
import { useTranslation } from '../../LocalizationProvider';
+import { snackBarDurationShortMs } from '../../common/duration';
const useStyles = makeStyles((theme) => ({
title: {
@@ -49,7 +50,7 @@ const RegisterForm = () => {
anchorOrigin={{ vertical: 'top', horizontal: 'center' }}
open={snackbarOpen}
onClose={() => history.push('/login')}
- autoHideDuration={6000}
+ autoHideDuration={snackBarDurationShortMs}
message={t('loginCreated')}
/>
<Grid container direction="column" spacing={2}>
diff --git a/modern/src/components/registration/ResetPasswordForm.js b/modern/src/components/registration/ResetPasswordForm.js
index a3b29f2a..6c41a9ea 100644
--- a/modern/src/components/registration/ResetPasswordForm.js
+++ b/modern/src/components/registration/ResetPasswordForm.js
@@ -7,6 +7,7 @@ import ArrowBackIcon from '@material-ui/icons/ArrowBack';
import StartPage from '../../StartPage';
import { useTranslation } from '../../LocalizationProvider';
import useQuery from '../../common/useQuery';
+import { snackBarDurationShortMs } from '../../common/duration';
const useStyles = makeStyles((theme) => ({
title: {
@@ -60,7 +61,7 @@ const ResetPasswordForm = () => {
anchorOrigin={{ vertical: 'top', horizontal: 'center' }}
open={snackbarOpen}
onClose={() => history.push('/login')}
- autoHideDuration={6000}
+ autoHideDuration={snackBarDurationShortMs}
message={!token ? t('loginResetSuccess') : t('loginUpdateSuccess')}
/>
<Grid container direction="column" spacing={2}>