change to pathname and params

This commit is contained in:
IO420
2025-09-29 19:57:02 -06:00
parent 88eb4d6e54
commit 68d9dc97c1
18 changed files with 89 additions and 49 deletions
+3 -2
View File
@@ -1,6 +1,6 @@
"use client";
import { useSearchParams } from "next/navigation";
import { usePathname, useSearchParams } from "next/navigation";
import { useRouter } from "next/navigation";
import { useState, ReactNode } from "react";
@@ -18,6 +18,7 @@ interface ToggleProps {
export default function Toggle({ options, defaultView }: ToggleProps) {
const router = useRouter();
const searchParams = useSearchParams();
const pathname = usePathname();
const [view, setView] = useState(defaultView || options[0].key);
const handleClick = (key: string) => {
@@ -26,7 +27,7 @@ export default function Toggle({ options, defaultView }: ToggleProps) {
const params = new URLSearchParams(searchParams.toString());
params.set("key", key);
router.replace(`${window.location.pathname}?${params.toString()}`);
router.replace(`${pathname}?${params.toString()}`);
};
return (