Files
gatehouse-ui/src/pages/auth/ResetPasswordPage.tsx
T
gpt-engineer-app[bot] 0104839c11 Changes
2026-01-06 14:46:23 +00:00

111 lines
3.5 KiB
TypeScript

import { useState } from "react";
import { useNavigate } from "react-router-dom";
import { Lock, ArrowRight, CheckCircle } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import { Label } from "@/components/ui/label";
export default function ResetPasswordPage() {
const navigate = useNavigate();
const [password, setPassword] = useState("");
const [confirmPassword, setConfirmPassword] = useState("");
const [isLoading, setIsLoading] = useState(false);
const [isSuccess, setIsSuccess] = useState(false);
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
if (password !== confirmPassword) {
return;
}
setIsLoading(true);
setTimeout(() => {
setIsLoading(false);
setIsSuccess(true);
}, 1000);
};
if (isSuccess) {
return (
<div className="auth-card text-center">
<div className="w-16 h-16 rounded-full bg-success/10 flex items-center justify-center mx-auto mb-6">
<CheckCircle className="w-8 h-8 text-success" />
</div>
<h1 className="text-2xl font-semibold text-foreground tracking-tight">
Password reset successful
</h1>
<p className="text-muted-foreground mt-2 mb-6">
Your password has been updated. You can now sign in with your new password.
</p>
<Button onClick={() => navigate("/login")} className="w-full">
Sign in
<ArrowRight className="w-4 h-4 ml-2" />
</Button>
</div>
);
}
return (
<div className="auth-card">
<div className="text-center mb-8">
<h1 className="text-2xl font-semibold text-foreground tracking-tight">
Reset your password
</h1>
<p className="text-muted-foreground mt-2">
Enter a new password for your account
</p>
</div>
<form onSubmit={handleSubmit} className="space-y-4">
<div className="space-y-2">
<Label htmlFor="password">New 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 new 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 ? (
"Resetting..."
) : (
<>
Reset password
<ArrowRight className="w-4 h-4 ml-2" />
</>
)}
</Button>
</form>
</div>
);
}