"use client"; import React, { useEffect, useState } from "react"; import { menu, close } from "src/assets"; import { styles } from "src/style"; import logo2 from "../../src/assets/logo2.png"; import Image from "next/image"; import { useLocale, useTranslations } from "next-intl"; import PersianNumberMemo from "plugins/PersianNumber"; import { Link, routing } from "../../src/i18n/routing"; import { useRouter } from "next/navigation"; // Fix the `useTranslations` key (removed space at the end) const navLinks = () => { const t = useTranslations("navLinks"); return [ { id: "our-solution", title: t("ourSolution"), go: false, }, { id: "product", title: t("product"), go: false, }, { id: "pricing", title: t("pricing"), go: true, }, { id: "about-us", title: t("aboutUs"), go: true, }, ]; }; const Navbar = () => { const [active, setActive] = useState(""); const [toggle, setToggle] = useState(false); const [scrolled, setScrolled] = useState(false); const [isOpenLang, setIsOpenLang] = useState(false); // To toggle the dropdown const t = useTranslations("navLinks"); const locale = useLocale(); const router = useRouter(); const isRTL = locale === "fa"; // Call `navLinks` once at the beginning const navItems = navLinks(); useEffect(() => { const handleScroll = () => { const scrollTop = window.scrollY; if (scrollTop > 100) { setScrolled(true); } else { setScrolled(false); } }; window.addEventListener("scroll", handleScroll); return () => window.removeEventListener("scroll", handleScroll); }, []); const availableLocales = [ { code: "en", name: "en" }, { code: "fa", name: "فا" }, // Persian (RTL) { code: "zh", name: "中文" }, ]; // Function to change the locale const changeLocale = (newLocale) => { // Navigate to the same route but with a different locale router.push(newLocale); setIsOpenLang(false); // Close the dropdown }; return ( ); }; export default Navbar;