"use client"; import Link from "next/link"; import { usePathname } from "next/navigation"; import type { CommonContent } from "@/content/types"; import { locales, type Locale } from "@/lib/i18n"; type BottomNavProps = { locale: Locale; common: CommonContent; }; export default function BottomNav({ locale, common }: BottomNavProps) { const pathname = usePathname(); const segments = pathname.split("/").filter(Boolean); const normalizedPath = pathname !== "/" && pathname.endsWith("/") ? pathname.slice(0, -1) : pathname; const homePath = `/${locale}`; const aboutPath = `/${locale}/about`; const contactPath = `/${locale}/contact`; const isHome = normalizedPath === homePath; const isAbout = normalizedPath === aboutPath || normalizedPath.startsWith(`${aboutPath}/`); const isContact = normalizedPath === contactPath || normalizedPath.startsWith(`${contactPath}/`); const targetLocale: Locale = locale === "ar" ? "en" : "ar"; const switchPath = () => { const nextSegments = [...segments]; if (nextSegments.length === 0) { return `/${targetLocale}`; } if (locales.includes(nextSegments[0] as Locale)) { nextSegments[0] = targetLocale; } else { nextSegments.unshift(targetLocale); } return `/${nextSegments.join("/")}`; }; return ( ); }