From d173b13bb9d1fcb8704c4835207893ac5d9a8bf7 Mon Sep 17 00:00:00 2001 From: James Pattinson Date: Mon, 10 Nov 2025 19:55:29 +0000 Subject: [PATCH] reg workflow improvements --- frontend/src/App.css | 2 +- frontend/src/pages/Register.tsx | 226 +++++++++++++++++++++----------- 2 files changed, 147 insertions(+), 81 deletions(-) diff --git a/frontend/src/App.css b/frontend/src/App.css index 704507d..9e6fc0d 100644 --- a/frontend/src/App.css +++ b/frontend/src/App.css @@ -154,7 +154,7 @@ body { padding: 40px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2); width: 100%; - max-width: 440px; + max-width: 900px; } .auth-card h2 { diff --git a/frontend/src/pages/Register.tsx b/frontend/src/pages/Register.tsx index 6f25eee..0511c33 100644 --- a/frontend/src/pages/Register.tsx +++ b/frontend/src/pages/Register.tsx @@ -12,6 +12,8 @@ const Register: React.FC = () => { phone: '', address: '' }); + const [confirmPassword, setConfirmPassword] = useState(''); + const [passwordsMatch, setPasswordsMatch] = useState(true); const [error, setError] = useState(''); const [loading, setLoading] = useState(false); @@ -22,15 +24,41 @@ const Register: React.FC = () => { }); }; + const handlePasswordChange = (e: React.ChangeEvent) => { + const { name, value } = e.target; + if (name === 'password') { + setFormData(prev => ({ ...prev, password: value })); + setPasswordsMatch(value === confirmPassword); + } else if (name === 'confirmPassword') { + setConfirmPassword(value); + setPasswordsMatch(formData.password === value); + } + }; + const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(''); + + // Validate password confirmation + if (formData.password !== confirmPassword) { + setError('Passwords do not match. Please try again.'); + return; + } + setLoading(true); try { + // Register the user await authService.register(formData); - alert('Registration successful! Please check your email. You can now log in.'); - navigate('/login'); + + // Automatically log in the user + await authService.login({ + email: formData.email, + password: formData.password + }); + + // Redirect to dashboard + navigate('/dashboard'); } catch (err: any) { setError(err.response?.data?.detail || 'Registration failed. Please try again.'); } finally { @@ -48,89 +76,127 @@ const Register: React.FC = () => { {error &&
{error}
} -
-
- - + + {/* Left Column - Personal Information */} +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + + + Minimum 8 characters + +
+ +
+ + + {confirmPassword && ( + + {passwordsMatch ? '✓ Passwords match' : '✗ Passwords do not match'} + + )} + {!confirmPassword && ( + + Re-enter your password + + )} +
-
- - + {/* Right Column - Contact Information */} +
+
+ + +
+ +
+ +