mirror of
http://88.130.71.182:3000/BlitTech/Projet1-RealEstate.git
synced 2026-06-12 23:33:21 +00:00
Create Register
This commit is contained in:
83
src/pages/Register
Normal file
83
src/pages/Register
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
import React, { useState } from 'react';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
|
const Register = () => {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const [formData, setFormData] = useState({
|
||||||
|
username: '',
|
||||||
|
email: '',
|
||||||
|
password: '',
|
||||||
|
confirmPassword: ''
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleChange = (e) => {
|
||||||
|
setFormData({
|
||||||
|
...formData,
|
||||||
|
[e.target.name]: e.target.value
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSubmit = (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
// Simple validation
|
||||||
|
if (formData.password !== formData.confirmPassword) {
|
||||||
|
alert("Passwords do not match!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// You can replace this with API call
|
||||||
|
console.log("Registering user:", formData);
|
||||||
|
|
||||||
|
// Simulate success
|
||||||
|
alert("Registration successful!");
|
||||||
|
navigate('/login'); // redirect to login page
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="register-container" style={{ padding: '2rem', maxWidth: '500px', margin: 'auto' }}>
|
||||||
|
<h2>Create Account</h2>
|
||||||
|
<form onSubmit={handleSubmit}>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
name="username"
|
||||||
|
placeholder="Username"
|
||||||
|
onChange={handleChange}
|
||||||
|
value={formData.username}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<br />
|
||||||
|
<input
|
||||||
|
type="email"
|
||||||
|
name="email"
|
||||||
|
placeholder="Email"
|
||||||
|
onChange={handleChange}
|
||||||
|
value={formData.email}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<br />
|
||||||
|
<input
|
||||||
|
type="password"
|
||||||
|
name="password"
|
||||||
|
placeholder="Password"
|
||||||
|
onChange={handleChange}
|
||||||
|
value={formData.password}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<br />
|
||||||
|
<input
|
||||||
|
type="password"
|
||||||
|
name="confirmPassword"
|
||||||
|
placeholder="Confirm Password"
|
||||||
|
onChange={handleChange}
|
||||||
|
value={formData.confirmPassword}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<br />
|
||||||
|
<button type="submit">Register</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Register;
|
||||||
Reference in New Issue
Block a user