diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-02-01 10:58:11 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2021-02-01 10:58:11 -0800 |
commit | 65af8bad51851ff7f15319d5ce14ff24697aaded (patch) | |
tree | 935830fdad9a4d01cf4b1e9182e7542bdcca3262 /modern/src/RegisterDialog.js | |
parent | 05c3cd4e7bb395970b395c719c1e6a671574c75b (diff) | |
download | trackermap-web-65af8bad51851ff7f15319d5ce14ff24697aaded.tar.gz trackermap-web-65af8bad51851ff7f15319d5ce14ff24697aaded.tar.bz2 trackermap-web-65af8bad51851ff7f15319d5ce14ff24697aaded.zip |
Registration flow updatesv4.12
Diffstat (limited to 'modern/src/RegisterDialog.js')
-rw-r--r-- | modern/src/RegisterDialog.js | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/modern/src/RegisterDialog.js b/modern/src/RegisterDialog.js index 53174360..c640c515 100644 --- a/modern/src/RegisterDialog.js +++ b/modern/src/RegisterDialog.js @@ -14,24 +14,11 @@ const RegisterDialog = ({ showDialog, onResult }) => { const [password, setPassword] = useState(''); const [snackbarOpen, setSnackbarOpen] = useState(false); - const handleNameChange = (event) => { - setName(event.target.value); - } - - const handleEmailChange = (event) => { - setEmail(event.target.value); - } - - const handlePasswordChange = (event) => { - setPassword(event.target.value); - } - const submitDisabled = () => { - return (!name || !/(.+)@(.+)\.(.{2,})/.test(email) || !password); + return !name || !/(.+)@(.+)\.(.{2,})/.test(email) || !password; } - const handleRegister = async (event) => { - + const handleRegister = async () => { const response = await fetch('/api/users', { method: 'POST', headers: { 'Content-Type': 'application/json' }, @@ -45,6 +32,7 @@ const RegisterDialog = ({ showDialog, onResult }) => { } if (snackbarOpen) { + return ( <Snackbar anchorOrigin={{ vertical: 'bottom', horizontal: 'center' }} @@ -53,7 +41,9 @@ const RegisterDialog = ({ showDialog, onResult }) => { onClose={() => { onResult(true) }} message={t('loginCreated')} /> ); + } else if (showDialog) { + return ( <Dialog open={true} @@ -69,7 +59,7 @@ const RegisterDialog = ({ showDialog, onResult }) => { value={name || ''} autoComplete='name' autoFocus - onChange={handleNameChange} /> + onChange={event => setName(event.target.value)} /> <TextField margin='normal' required @@ -79,7 +69,7 @@ const RegisterDialog = ({ showDialog, onResult }) => { name='email' value={email || ''} autoComplete='email' - onChange={handleEmailChange} /> + onChange={event => setEmail(event.target.value)} /> <TextField margin='normal' required @@ -89,7 +79,7 @@ const RegisterDialog = ({ showDialog, onResult }) => { value={password || ''} type='password' autoComplete='current-password' - onChange={handlePasswordChange} /> + onChange={event => setPassword(event.target.value)} /> </DialogContent> <DialogActions> <Button color="primary" onClick={handleRegister} disabled={submitDisabled()}>{t('loginRegister')}</Button> @@ -97,8 +87,8 @@ const RegisterDialog = ({ showDialog, onResult }) => { </DialogActions> </Dialog> ) - } else return null; + } }; export default RegisterDialog; |