aboutsummaryrefslogtreecommitdiff
path: root/modern/src/RegisterDialog.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-07-10 15:24:10 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-07-10 15:24:10 -0700
commit0512964d71a25c172735f2149ef60c3a8b20f683 (patch)
treef47b42326a7e6a0eaa2715ca8066cb3ca7e7bb90 /modern/src/RegisterDialog.js
parent627cf95d59f625dcb0544bfd4c067d99dee4bb93 (diff)
downloadtrackermap-web-0512964d71a25c172735f2149ef60c3a8b20f683.tar.gz
trackermap-web-0512964d71a25c172735f2149ef60c3a8b20f683.tar.bz2
trackermap-web-0512964d71a25c172735f2149ef60c3a8b20f683.zip
Use modified airbnb eslint
Diffstat (limited to 'modern/src/RegisterDialog.js')
-rw-r--r--modern/src/RegisterDialog.js62
1 files changed, 31 insertions, 31 deletions
diff --git a/modern/src/RegisterDialog.js b/modern/src/RegisterDialog.js
index c640c515..aafec66b 100644
--- a/modern/src/RegisterDialog.js
+++ b/modern/src/RegisterDialog.js
@@ -1,4 +1,3 @@
-import t from './common/localization'
import React, { useState } from 'react';
import Button from '@material-ui/core/Button';
import Dialog from '@material-ui/core/Dialog';
@@ -7,6 +6,7 @@ import DialogContent from '@material-ui/core/DialogContent';
import DialogContentText from '@material-ui/core/DialogContentText';
import TextField from '@material-ui/core/TextField';
import Snackbar from '@material-ui/core/Snackbar';
+import t from './common/localization';
const RegisterDialog = ({ showDialog, onResult }) => {
const [name, setName] = useState('');
@@ -14,81 +14,81 @@ const RegisterDialog = ({ showDialog, onResult }) => {
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) {
showDialog = false;
setSnackbarOpen(true);
- }
- }
+ }
+ };
if (snackbarOpen) {
-
return (
<Snackbar
anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }}
open={snackbarOpen}
autoHideDuration={6000}
- onClose={() => { onResult(true) }}
- message={t('loginCreated')} />
+ onClose={() => { onResult(true); }}
+ message={t('loginCreated')}
+ />
);
-
- } else if (showDialog) {
-
+ } if (showDialog) {
return (
<Dialog
- open={true}
- onClose={() => { onResult(false) }}>
+ open
+ onClose={() => { onResult(false); }}
+ >
<DialogContent>
<DialogContentText>{t('loginRegister')}</DialogContentText>
<TextField
- margin='normal'
+ margin="normal"
required
fullWidth
label={t('sharedName')}
- name='name'
+ name="name"
value={name || ''}
- autoComplete='name'
+ autoComplete="name"
autoFocus
- onChange={event => setName(event.target.value)} />
+ onChange={(event) => setName(event.target.value)}
+ />
<TextField
- margin='normal'
+ margin="normal"
required
fullWidth
- type='email'
+ type="email"
label={t('userEmail')}
- name='email'
+ name="email"
value={email || ''}
- autoComplete='email'
- onChange={event => setEmail(event.target.value)} />
+ autoComplete="email"
+ onChange={(event) => setEmail(event.target.value)}
+ />
<TextField
- margin='normal'
+ margin="normal"
required
fullWidth
label={t('userPassword')}
- name='password'
+ name="password"
value={password || ''}
- type='password'
- autoComplete='current-password'
- onChange={event => setPassword(event.target.value)} />
+ type="password"
+ autoComplete="current-password"
+ onChange={(event) => setPassword(event.target.value)}
+ />
</DialogContent>
<DialogActions>
<Button color="primary" onClick={handleRegister} disabled={submitDisabled()}>{t('loginRegister')}</Button>
<Button autoFocus onClick={() => onResult(false)}>{t('sharedCancel')}</Button>
</DialogActions>
</Dialog>
- )
-
+ );
}
+ return null;
};
export default RegisterDialog;