diff --git a/data.json b/data.json index 89db65c..ed2bf3d 100644 --- a/data.json +++ b/data.json @@ -167,12 +167,12 @@ "value": "121 King St , ملبورن VIC 3000, أستراليا" }, "2": { - "title": "المكتب الرئيسي", + "title": "رقم الهاتف", "image": "/contact/2.png", "value": "+61 2 8376 6284" }, "3": { - "title": "المكتب الرئيسي", + "title": "عنوان البريد الإلكتروني", "image": "/contact/3.png", "value": " hello@your domain.com" } diff --git a/src/components/layout/NavBar.tsx b/src/components/layout/NavBar.tsx index 73dd11f..7f7f85a 100644 --- a/src/components/layout/NavBar.tsx +++ b/src/components/layout/NavBar.tsx @@ -1,20 +1,19 @@ -// NavBar.tsx -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { RoutesEnums } from '../../enums/RoutesEnums'; import { MdLanguage } from 'react-icons/md'; import { FaEllipsis } from 'react-icons/fa6'; import { Popover } from 'antd'; import { navBar as navBarData, Setting } from '../../../data.json'; -// Define an enum for the routes +import { useLocation } from 'react-router-dom'; -// Define a type for the link objects interface NavLink { - path: RoutesEnums; + path: string; label: string; } const NavBar: React.FC = () => { - // Define an array of link objects using the RoutesEnums + const location = useLocation(); + const links: NavLink[] = [ { path: RoutesEnums.HOME, label: navBarData.link1 }, { path: RoutesEnums.FEATURES, label: navBarData.link2 }, @@ -25,47 +24,43 @@ const NavBar: React.FC = () => { { path: RoutesEnums.PRIVACY, label: navBarData.link7 }, { path: RoutesEnums.DOWNLOAD, label: navBarData.link8 }, ]; + + const [active, setActive] = useState(location.pathname + location.hash); + + useEffect(() => { + setActive(location.pathname + location.hash); + if (location.pathname + location.hash === '/') { + setActive(location.pathname+'#'); + } + }, [location.pathname, location.hash]); + + const handleToggle = () => setOpen(!Open); const [Open, setOpen] = useState(false); - const handleToggle = () => { - setOpen(!Open); - }; const NavBarContent = (
); - const [Active, setActive] = useState(location.hash); - return (