diff --git a/src/components/admin/AdminShell.tsx b/src/components/admin/AdminShell.tsx index dc29dfb..2268aa2 100644 --- a/src/components/admin/AdminShell.tsx +++ b/src/components/admin/AdminShell.tsx @@ -1,9 +1,9 @@ "use client"; -import Link from "next/link"; -import { usePathname } from "next/navigation"; import { useState } from "react"; +import { Link, usePathname } from "@/i18n/navigation"; + export interface NavItem { href: string; label: string } export interface NavGroup { title: string; items: NavItem[] } @@ -18,12 +18,10 @@ export function AdminShell({ back: string; children: React.ReactNode; }) { - const pathname = usePathname() ?? ""; + const pathname = usePathname() ?? ""; // next-intl: already without the locale prefix const [open, setOpen] = useState(false); - // Strip a leading locale segment (e.g. /en) so fa (no prefix) and en both match. - const clean = pathname.replace(/^\/[a-z]{2}(?=\/)/, ""); - const isActive = (href: string) => clean === href || clean.startsWith(href + "/"); + const isActive = (href: string) => pathname === href || pathname.startsWith(href + "/"); const current = groups.flatMap((g) => g.items).find((i) => isActive(i.href)); return ( @@ -68,9 +66,9 @@ export function AdminShell({ ))}