From 65af8bad51851ff7f15319d5ce14ff24697aaded Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Mon, 1 Feb 2021 10:58:11 -0800 Subject: Registration flow updates --- modern/src/RegisterDialog.js | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) (limited to 'modern/src/RegisterDialog.js') 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 ( { onClose={() => { onResult(true) }} message={t('loginCreated')} /> ); + } else if (showDialog) { + return ( { value={name || ''} autoComplete='name' autoFocus - onChange={handleNameChange} /> + onChange={event => setName(event.target.value)} /> { name='email' value={email || ''} autoComplete='email' - onChange={handleEmailChange} /> + onChange={event => setEmail(event.target.value)} /> { value={password || ''} type='password' autoComplete='current-password' - onChange={handlePasswordChange} /> + onChange={event => setPassword(event.target.value)} /> @@ -97,8 +87,8 @@ const RegisterDialog = ({ showDialog, onResult }) => { ) - } else return null; + } }; export default RegisterDialog; -- cgit v1.2.3