import { useNavigate } from "@tanstack/react-router";
import { useEffect } from "react";

/** Goes to another page once. (A <Navigate> that is rendered again would start over and over.) */
export function Redirect({ to }: { to: "/login" | "/projects" | "/change-password" }) {
  const navigate = useNavigate();
  useEffect(() => {
    void navigate({ to, replace: true });
  }, [to, navigate]);
  return null;
}
