fix: replace window.location with Next.js router for client-side navigation

- Replace window.location.href with router.push() + router.refresh() in UserDropdown logout
- Replace window.location.href with router.push() in CreateSearchSpaceDialog
- Replace window.location.reload() with router.refresh() in login page retry action
- Prevents full page reloads and preserves React state during in-app navigation
This commit is contained in:
SohamBhattacharjee2003 2026-04-08 04:28:41 +05:30
parent 0cd997f673
commit baada1457a
3 changed files with 12 additions and 9 deletions

View file

@ -1,6 +1,7 @@
"use client";
import { AnimatePresence, motion } from "motion/react";
import { useRouter } from "next/navigation";
import { useSearchParams } from "next/navigation";
import { useTranslations } from "next-intl";
import { Suspense, useEffect, useState } from "react";
@ -16,6 +17,7 @@ import { LocalLoginForm } from "./LocalLoginForm";
function LoginContent() {
const t = useTranslations("auth");
const tCommon = useTranslations("common");
const router = useRouter();
const [authType, setAuthType] = useState<string | null>(null);
const [isLoading, setIsLoading] = useState(true);
const [urlError, setUrlError] = useState<{ title: string; message: string } | null>(null);
@ -79,7 +81,7 @@ function LoginContent() {
if (shouldRetry(error)) {
toastOptions.action = {
label: "Retry",
onClick: () => window.location.reload(),
onClick: () => router.refresh(),
};
}