diff --git a/src/pages/Register.tsx b/src/pages/Register.tsx index 51169ed..10308a5 100644 --- a/src/pages/Register.tsx +++ b/src/pages/Register.tsx @@ -1,7 +1,8 @@ import React, { useState } from 'react'; -import { useNavigate } from 'react-router-dom'; +import { useNavigate, Link } from 'react-router-dom'; +import { User, Mail, Lock } from 'lucide-react'; // Import icons -const Register = () => { +const Register: React.FC = () => { const navigate = useNavigate(); const [formData, setFormData] = useState({ username: '', @@ -9,73 +10,181 @@ const Register = () => { password: '', confirmPassword: '' }); + const [error, setError] = useState(''); - const handleChange = (e) => { + const handleChange = (e: React.ChangeEvent) => { setFormData({ ...formData, [e.target.name]: e.target.value }); }; - const handleSubmit = (e) => { + const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); + setError(''); // Clear previous errors // Simple validation if (formData.password !== formData.confirmPassword) { - alert("Passwords do not match!"); + setError("Passwords do not match!"); return; } - // You can replace this with API call - console.log("Registering user:", formData); + if (formData.password.length < 6) { + setError("Password must be at least 6 characters long."); + return; + } - // Simulate success - alert("Registration successful!"); + // You can replace this with your API call for registration + console.log("Registering user:", { + username: formData.username, + email: formData.email + // Do not log the password + }); + + // On successful registration: + // For now, we'll simulate success and navigate to the login page. + console.log("Registration successful!"); navigate('/login'); // redirect to login page }; return ( -
-

Create Account

-
- -
- -
- -
- -
- -
+
+
+

+ Create a new account +

+

+ Or{' '} + + sign in to your existing account + +

+
+ +
+
+
+
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ +
+ +
+
+ + {error && ( +
+
+
+

{error}

+
+
+
+ )} + +
+ +
+
+
+
); };