fix:content filter query
This commit is contained in:
parent
5807e389b4
commit
9563ad5987
|
|
@ -1,7 +1,7 @@
|
||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useLocale } from "next-intl";
|
import { useLocale } from "next-intl";
|
||||||
import { useParams } from "next/navigation";
|
import { useParams, useSearchParams } from "next/navigation";
|
||||||
import { locales } from "@/config";
|
import { locales } from "@/config";
|
||||||
import { usePathname, useRouter } from "@/i18n/routing";
|
import { usePathname, useRouter } from "@/i18n/routing";
|
||||||
|
|
||||||
|
|
@ -33,13 +33,22 @@ export default function LocalSwitcher() {
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
const localActive = useLocale() || "in";
|
const localActive = useLocale() || "in";
|
||||||
const [selectedLang, setSelectedLang] = useState<string>("");
|
const [selectedLang, setSelectedLang] = useState<string>("");
|
||||||
|
const searchParams = useSearchParams();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const storedLang = getLanguage();
|
const storedLang = getLanguage();
|
||||||
|
let joinParam = "";
|
||||||
|
if (searchParams) {
|
||||||
|
joinParam = Array.from(searchParams.entries())
|
||||||
|
.map(([key, value]) => `${key}=${value}`)
|
||||||
|
.join("&");
|
||||||
|
}
|
||||||
|
|
||||||
if (pathname.includes("polda")){
|
if (pathname.includes("polda")) {
|
||||||
startTransition(() => {
|
startTransition(() => {
|
||||||
router.replace(pathname, { locale: "in" });
|
router.replace(pathname + joinParam === "" ? "" : `?${joinParam}`, {
|
||||||
|
locale: "in",
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (!storedLang) {
|
if (!storedLang) {
|
||||||
|
|
@ -47,16 +56,20 @@ export default function LocalSwitcher() {
|
||||||
setSelectedLang("in");
|
setSelectedLang("in");
|
||||||
|
|
||||||
startTransition(() => {
|
startTransition(() => {
|
||||||
router.replace(pathname, { locale: "in" });
|
router.replace(pathname + joinParam === "" ? "" : `?${joinParam}`, {
|
||||||
|
locale: "in",
|
||||||
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
setSelectedLang(storedLang);
|
setSelectedLang(storedLang);
|
||||||
startTransition(() => {
|
startTransition(() => {
|
||||||
router.replace(pathname, { locale: storedLang });
|
router.replace(pathname + joinParam === "" ? "" : `?${joinParam}`, {
|
||||||
|
locale: storedLang,
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, []);
|
}, [searchParams]);
|
||||||
|
|
||||||
const onSelectChange = (nextLocale: string) => {
|
const onSelectChange = (nextLocale: string) => {
|
||||||
setLanguage(nextLocale);
|
setLanguage(nextLocale);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue