|
1 | 1 | import React, { useState, useEffect, useCallback } from 'react'; |
2 | | -import { Link, useLocation } from 'react-router-dom'; |
| 2 | +import { Link, useLocation, useNavigate } from 'react-router-dom'; |
3 | 3 | import { Menu, X } from 'lucide-react'; |
4 | 4 | import { motion, AnimatePresence } from 'framer-motion'; |
5 | 5 | import logo from '../../assets/logo.png'; |
6 | 6 | import { handleNavigation } from '../../utils/navigation'; |
7 | 7 |
|
8 | 8 | const navLinks = [ |
9 | | - { name: 'Technology', href: '/#technology' }, |
10 | | - { name: 'Benefits', href: '/#benefits' }, |
11 | | - { name: 'Integration', href: '/#integration' }, |
12 | | - { name: 'Timeline', href: '#/timeline' }, |
13 | | - { name: 'Team', href: '#/team' }, |
14 | | - { name: 'Careers', href: '#/careers' }, |
15 | | - { name: 'FAQ', href: '#/faq' }, |
| 9 | + { name: 'Technology', href: '/#technology', isSection: true }, |
| 10 | + { name: 'Benefits', href: '/#benefits', isSection: true }, |
| 11 | + { name: 'Integration', href: '/#integration', isSection: true }, |
| 12 | + { name: 'Timeline', href: '/timeline', isSection: false }, |
| 13 | + { name: 'Team', href: '/team', isSection: false }, |
| 14 | + { name: 'Careers', href: '/careers', isSection: false }, |
| 15 | + { name: 'FAQ', href: '/faq', isSection: false }, |
16 | 16 | ]; |
17 | 17 |
|
18 | 18 | const Header: React.FC = () => { |
19 | 19 | const [isOpen, setIsOpen] = useState(false); |
20 | 20 | const [scrolled, setScrolled] = useState(false); |
21 | 21 | const location = useLocation(); |
| 22 | + const navigate = useNavigate(); |
22 | 23 |
|
23 | 24 | const toggleMobileMenu = useCallback(() => { |
24 | 25 | setIsOpen(!isOpen); |
@@ -73,18 +74,28 @@ const Header: React.FC = () => { |
73 | 74 | {/* Desktop Navigation */} |
74 | 75 | <nav className="hidden md:flex items-center space-x-6"> |
75 | 76 | {navLinks.map((link) => ( |
76 | | - <Link |
77 | | - key={link.name} |
78 | | - to={link.href} |
79 | | - className="text-sm font-medium text-white/70 hover:text-white transition-colors" |
80 | | - onClick={(e) => handleNavigation(link.href, e)} |
81 | | - > |
82 | | - {link.name} |
83 | | - </Link> |
| 77 | + link.isSection ? ( |
| 78 | + <Link |
| 79 | + key={link.name} |
| 80 | + to={link.href} |
| 81 | + className="text-sm font-medium text-white/70 hover:text-white transition-colors" |
| 82 | + onClick={(e) => handleNavigation(link.href, e, location, navigate)} |
| 83 | + > |
| 84 | + {link.name} |
| 85 | + </Link> |
| 86 | + ) : ( |
| 87 | + <Link |
| 88 | + key={link.name} |
| 89 | + to={link.href} |
| 90 | + className="text-sm font-medium text-white/70 hover:text-white transition-colors" |
| 91 | + > |
| 92 | + {link.name} |
| 93 | + </Link> |
| 94 | + ) |
84 | 95 | ))} |
85 | 96 | <Link |
86 | 97 | to="/#contact" |
87 | | - onClick={(e) => handleNavigation('/#contact', e)} |
| 98 | + onClick={(e) => handleNavigation('/#contact', e, location, navigate)} |
88 | 99 | className="px-4 py-2 bg-primary-500 hover:bg-primary-600 text-white rounded-full text-sm font-medium transition-colors" |
89 | 100 | > |
90 | 101 | Contact Us |
@@ -116,22 +127,33 @@ const Header: React.FC = () => { |
116 | 127 | <nav className="container mx-auto px-4 py-4"> |
117 | 128 | <div className="flex flex-col space-y-4"> |
118 | 129 | {navLinks.map((link) => ( |
119 | | - <Link |
120 | | - key={link.name} |
121 | | - to={link.href} |
122 | | - className="text-base font-medium text-white/70 hover:text-white transition-colors" |
123 | | - onClick={(e) => { |
124 | | - handleNavigation(link.href, e); |
125 | | - closeMobileMenu(); |
126 | | - }} |
127 | | - > |
128 | | - {link.name} |
129 | | - </Link> |
| 130 | + link.isSection ? ( |
| 131 | + <Link |
| 132 | + key={link.name} |
| 133 | + to={link.href} |
| 134 | + className="text-base font-medium text-white/70 hover:text-white transition-colors" |
| 135 | + onClick={(e) => { |
| 136 | + handleNavigation(link.href, e, location, navigate); |
| 137 | + closeMobileMenu(); |
| 138 | + }} |
| 139 | + > |
| 140 | + {link.name} |
| 141 | + </Link> |
| 142 | + ) : ( |
| 143 | + <Link |
| 144 | + key={link.name} |
| 145 | + to={link.href} |
| 146 | + className="text-base font-medium text-white/70 hover:text-white transition-colors" |
| 147 | + onClick={closeMobileMenu} |
| 148 | + > |
| 149 | + {link.name} |
| 150 | + </Link> |
| 151 | + ) |
130 | 152 | ))} |
131 | 153 | <Link |
132 | 154 | to="/#contact" |
133 | 155 | onClick={(e) => { |
134 | | - handleNavigation('/#contact', e); |
| 156 | + handleNavigation('/#contact', e, location, navigate); |
135 | 157 | closeMobileMenu(); |
136 | 158 | }} |
137 | 159 | className="text-base font-medium text-primary-500 hover:text-primary-400 transition-colors" |
|
0 commit comments