141 lines
4.5 KiB
TypeScript
141 lines
4.5 KiB
TypeScript
|
|
import { useState } from "react";
|
||
|
|
import { Link, useNavigate } from "react-router-dom";
|
||
|
|
import { Mail, Lock, User, ArrowRight } from "lucide-react";
|
||
|
|
import { Button } from "@/components/ui/button";
|
||
|
|
import { Input } from "@/components/ui/input";
|
||
|
|
import { Label } from "@/components/ui/label";
|
||
|
|
|
||
|
|
export default function RegisterPage() {
|
||
|
|
const navigate = useNavigate();
|
||
|
|
const [name, setName] = useState("");
|
||
|
|
const [email, setEmail] = useState("");
|
||
|
|
const [password, setPassword] = useState("");
|
||
|
|
const [confirmPassword, setConfirmPassword] = useState("");
|
||
|
|
const [isLoading, setIsLoading] = useState(false);
|
||
|
|
|
||
|
|
const handleSubmit = async (e: React.FormEvent) => {
|
||
|
|
e.preventDefault();
|
||
|
|
if (password !== confirmPassword) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
setIsLoading(true);
|
||
|
|
// Mock registration - will be replaced with actual auth
|
||
|
|
setTimeout(() => {
|
||
|
|
setIsLoading(false);
|
||
|
|
navigate("/verify-email");
|
||
|
|
}, 1000);
|
||
|
|
};
|
||
|
|
|
||
|
|
return (
|
||
|
|
<div className="auth-card">
|
||
|
|
<div className="text-center mb-8">
|
||
|
|
<h1 className="text-2xl font-semibold text-foreground tracking-tight">
|
||
|
|
Create your account
|
||
|
|
</h1>
|
||
|
|
<p className="text-muted-foreground mt-2">
|
||
|
|
Get started with Authy2 in seconds
|
||
|
|
</p>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<form onSubmit={handleSubmit} className="space-y-4">
|
||
|
|
<div className="space-y-2">
|
||
|
|
<Label htmlFor="name">Full name</Label>
|
||
|
|
<div className="relative">
|
||
|
|
<User className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground" />
|
||
|
|
<Input
|
||
|
|
id="name"
|
||
|
|
type="text"
|
||
|
|
placeholder="John Doe"
|
||
|
|
value={name}
|
||
|
|
onChange={(e) => setName(e.target.value)}
|
||
|
|
className="pl-10"
|
||
|
|
required
|
||
|
|
/>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div className="space-y-2">
|
||
|
|
<Label htmlFor="email">Email</Label>
|
||
|
|
<div className="relative">
|
||
|
|
<Mail className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground" />
|
||
|
|
<Input
|
||
|
|
id="email"
|
||
|
|
type="email"
|
||
|
|
placeholder="you@example.com"
|
||
|
|
value={email}
|
||
|
|
onChange={(e) => setEmail(e.target.value)}
|
||
|
|
className="pl-10"
|
||
|
|
required
|
||
|
|
/>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div className="space-y-2">
|
||
|
|
<Label htmlFor="password">Password</Label>
|
||
|
|
<div className="relative">
|
||
|
|
<Lock className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground" />
|
||
|
|
<Input
|
||
|
|
id="password"
|
||
|
|
type="password"
|
||
|
|
placeholder="••••••••"
|
||
|
|
value={password}
|
||
|
|
onChange={(e) => setPassword(e.target.value)}
|
||
|
|
className="pl-10"
|
||
|
|
required
|
||
|
|
minLength={8}
|
||
|
|
/>
|
||
|
|
</div>
|
||
|
|
<p className="text-xs text-muted-foreground">
|
||
|
|
Must be at least 8 characters
|
||
|
|
</p>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div className="space-y-2">
|
||
|
|
<Label htmlFor="confirmPassword">Confirm password</Label>
|
||
|
|
<div className="relative">
|
||
|
|
<Lock className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground" />
|
||
|
|
<Input
|
||
|
|
id="confirmPassword"
|
||
|
|
type="password"
|
||
|
|
placeholder="••••••••"
|
||
|
|
value={confirmPassword}
|
||
|
|
onChange={(e) => setConfirmPassword(e.target.value)}
|
||
|
|
className="pl-10"
|
||
|
|
required
|
||
|
|
/>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<Button type="submit" className="w-full" disabled={isLoading}>
|
||
|
|
{isLoading ? (
|
||
|
|
"Creating account..."
|
||
|
|
) : (
|
||
|
|
<>
|
||
|
|
Create account
|
||
|
|
<ArrowRight className="w-4 h-4 ml-2" />
|
||
|
|
</>
|
||
|
|
)}
|
||
|
|
</Button>
|
||
|
|
</form>
|
||
|
|
|
||
|
|
<p className="text-center text-sm text-muted-foreground mt-6">
|
||
|
|
Already have an account?{" "}
|
||
|
|
<Link to="/login" className="text-accent hover:underline font-medium">
|
||
|
|
Sign in
|
||
|
|
</Link>
|
||
|
|
</p>
|
||
|
|
|
||
|
|
<p className="text-center text-xs text-muted-foreground mt-4">
|
||
|
|
By creating an account, you agree to our{" "}
|
||
|
|
<Link to="/terms" className="underline">
|
||
|
|
Terms of Service
|
||
|
|
</Link>{" "}
|
||
|
|
and{" "}
|
||
|
|
<Link to="/privacy" className="underline">
|
||
|
|
Privacy Policy
|
||
|
|
</Link>
|
||
|
|
</p>
|
||
|
|
</div>
|
||
|
|
);
|
||
|
|
}
|