feat: proper redirect handling

This commit is contained in:
2025-05-29 14:17:09 +02:00
parent 8364a8e9ec
commit 807d7538a0
10 changed files with 106 additions and 53 deletions

View File

@ -1,6 +1,6 @@
import { Card, CardContent } from "@/components/ui/card";
import { Mail, Lock, User, Phone } from "lucide-react";
import { Link } from "react-router-dom";
import { Link, useLocation } from "react-router-dom";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
@ -23,6 +23,8 @@ export default function RegisterPage() {
formState: { errors },
} = useForm<RegisterForm>();
const location = useLocation();
const [isLoading, setLoading] = useState(false);
const [error, setError] = useState("");
const [success, setSuccess] = useState("");
@ -238,7 +240,11 @@ export default function RegisterPage() {
</Button>
<div className="text-sm text-center text-gray-600">
Already have an account?{" "}
<Link to="/login" className="text-blue-600 hover:underline">
<Link
to="/login"
state={location.state}
className="text-blue-600 hover:underline"
>
Login
</Link>
</div>