Header.js 15 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406
"use client";

import { useState, useEffect } from "react";
import Link from "next/link";
import { useRouter } from "next/router";
import Image from "next/image";
import MobileHamburger from "./MobileHamburger";

const Header = () => {
  const [menu, setMenu] = useState(true);
  const [clientServicingOpen, setClientServicingOpen] = useState(false);
  const router = useRouter();

  const toggleNavbar = () => {
    setMenu(!menu);
  };

  useEffect(() => {
    const handleRouteChange = () => {
      setMenu(true);
      setClientServicingOpen(false);
    };

    router.events.on("routeChangeStart", handleRouteChange);
    return () => {
      router.events.off("routeChangeStart", handleRouteChange);
    };
  }, [router]);

  useEffect(() => {
    const elementId = document.getElementById("navbar");
    const handleScroll = () => {
      if (window.scrollY > 170) {
        elementId.classList.add("is-sticky");
      } else {
        elementId.classList.remove("is-sticky");
      }
    };

    window.addEventListener("scroll", handleScroll);
    return () => {
      window.removeEventListener("scroll", handleScroll);
    };
  }, []);

  // Check if a route is active
  const isActive = (path) => {
    if (path === "/") {
      return router.pathname === path;
    }
    return router.pathname.startsWith(path);
  };

  const classOne = menu
    ? "collapse navbar-collapse"
    : "collapse navbar-collapse show";
  const classTwo = menu
    ? "navbar-toggler navbar-toggler-right collapsed"
    : "navbar-toggler navbar-toggler-right";

  const clientServices = [
    {
      title: "Virtual Finance Office",
      href: "/client-servicing/virtual-finance-office",
      items: [
        {
          name: "Virtual CFO Services",
          href: "/client-servicing/virtual-finance-office/virtual-cfo",
        },
        {
          name: "Virtual FC Services",
          href: "/client-servicing/virtual-finance-office/virtual-fc",
        },
        {
          name: "Book Closure and Audit Support",
          href: "/client-servicing/virtual-finance-office/book-closures-audit",
        },
        {
          name: "Accounting Payroll & Compliance",
          href: "/client-servicing/virtual-finance-office/apc",
        },
      ],
    },
    {
      title: "Advisory Services",
      href: "/client-servicing/advisory-services",
      items: [
        { name: "Transaction Advisory", href: "/client-servicing/ta" },
        { name: "Risk Advisory", href: "/client-servicing/ra" },
        { name: "Business Advisory", href: "/client-servicing/ba" },
      ],
    },
    {
      title: "GCC as a Service",
      href: "/client-servicing/global-capability-centres",
      items: [],
    },
    {
      title: "Digital Transformation",
      href: "/client-servicing/digital-transformation",
      items: [
        // { name: "ITeC App", href: "/client-servicing/ba" },
        // { name: "Digital Process Automation", href: "/client-servicing/ba" },
      ],
    },
    {
      title: "Empowering Finance Consultants",
      href: "/client-servicing/empowering-finance-consultants",
      items: [
        // { name: "CA/CPA firm services", href: "/client-servicing/ba" }
      ],
    },
    {
      title: "Bespoke Services",
      href: "/client-servicing/bespoke",
      items: [
        // { name: "Data analysis and reporting", href: "/client-servicing/ba" },
        // { name: "Admin and Backend Support Services", href: "/client-servicing/ba" },
        // { name: "PFM", href: "/client-servicing/ba" },
      ],
    },
  ];

  // Group the last four services into one column
  const megaMenuColumns = [
    [clientServices[0]], // Virtual Finance Office
    [clientServices[1]], // Advisory Services
    [
      clientServices[2],
      clientServices[3],
      clientServices[4],
      clientServices[5],
    ], // GCC as a Service, Digital Transformation, Empowering Finance Consultants, Bespoke Services
  ];

  return (
    <>
      <div className="mega-menu-container">
        {/* Mobile Hamburger only visible on mobile */}
        <div className="mobile-hamburger-wrapper">
          <MobileHamburger />
        </div>
        <div id="navbar" className="navbar-area">
          <div className="zixon-nav">
            <div
              className="container-fluid"
              style={{ maxWidth: 1200, margin: "0 auto", padding: "0 32px" }}
            >
              <nav className="navbar navbar-expand-md navbar-light">
                <Link href="/" className="navbar-brand">
                  <Image
                    width={180}
                    height={33}
                    src="/images/Advithlogo.svg"
                    alt="logo"
                  />
                </Link>
                <button
                  onClick={toggleNavbar}
                  className={classTwo}
                  type="button"
                  aria-controls="navbarSupportedContent"
                  aria-expanded="false"
                  aria-label="Toggle navigation"
                >
                  <span className="icon-bar top-bar"></span>
                  <span className="icon-bar middle-bar"></span>
                  <span className="icon-bar bottom-bar"></span>
                </button>
                <div className={classOne} id="navbarSupportedContent">
                  <ul className="navbar-nav">
                    <li className="nav-item">
                      <Link
                        href="/"
                        className={`nav-link ${isActive("/") ? "active" : ""}`}
                      >
                        Home
                      </Link>
                    </li>

                    {/* Knowledge Dropdown */}
                    <li className="nav-item knowledge-dropdown">
                      <Link
                        href="/knowledge"
                        className="dropdown-toggle nav-link"
                      >
                        Knowledge
                      </Link>
                      <ul className="dropdown-menu">
                        <li className="nav-item">
                          <Link
                            href="/corpedia"
                            className={`nav-link ${
                              isActive("/corpedia") ? "active" : ""
                            }`}
                          >
                            Corpedia
                          </Link>
                          <ul>
                            <li className="nav-item">
                              <Link
                                href="/taxwire"
                                className={`nav-link ${
                                  isActive("/taxwire") ? "active" : ""
                                }`}
                              >
                                Taxwire
                              </Link>
                            </li>
                            <li className="nav-item">
                              <Link
                                href="/budgetpanorama"
                                className={`nav-link ${
                                  isActive("/budgetpanorama") ? "active" : ""
                                }`}
                              >
                                Budget Panorama
                              </Link>
                            </li>
                          </ul>
                        </li>
                        <li className="nav-item">
                          <Link
                            href="/blog"
                            className={`nav-link ${
                              isActive("/blog") ? "active" : ""
                            }`}
                          >
                            Blogs
                          </Link>
                        </li>
                      </ul>
                    </li>

                    <li className="nav-item">
                      <Link
                        href="/people"
                        className={`nav-link ${
                          isActive("/people") ? "active" : ""
                        }`}
                      >
                        People
                      </Link>
                    </li>

                    {/* Wrap both the Client Servicing nav item and the mega menu in a parent div for hover logic */}
                    <li
                      className="nav-item"
                      onMouseEnter={() => setClientServicingOpen(true)}
                      onMouseLeave={() => setClientServicingOpen(false)}
                    >
                      <Link
                        href="/client-servicing"
                        className="nav-link dropdown-nav"
                        style={{
                          background: "none",
                          border: "none",
                          cursor: "pointer",
                        }}
                      >
                        Client Servicing
                        <span className="dropdown-arrow"></span>
                      </Link>
                    </li>
                    {clientServicingOpen && (
                      <div
                        className="mega-menu show"
                        style={{
                          position: "fixed",
                          left: 0,
                          top: "calc(64px + 1px)", // adjust 64px to your header height if needed
                          width: "100vw",
                          zIndex: 1000,
                          background: "#fff",
                          boxShadow: "0 2px 8px rgba(0,0,0,0.08)",
                        }}
                        onMouseEnter={() => setClientServicingOpen(true)}
                        onMouseLeave={() => setClientServicingOpen(false)}
                      >
                        <div className="mega-menu-content">
                          <div
                            className="mega-grid client-servicing-grid"
                            style={{
                              display: "flex",
                              gap: "32px",
                              justifyContent: "center",
                            }}
                          >
                            {megaMenuColumns.map((column, colIdx) => (
                              <div
                                key={colIdx}
                                className="mega-column"
                                style={
                                  colIdx === 2
                                    ? {
                                        minWidth: 260,
                                        gap: 8,
                                        display: "flex",
                                        flexDirection: "column",
                                      }
                                    : {
                                        minWidth: 260,
                                        display: "flex",
                                        flexDirection: "column",
                                      }
                                }
                              >
                                {column.map((service, idx) => (
                                  <div
                                    key={service.title}
                                    className="service-header"
                                    style={
                                      colIdx < 2
                                        ? { display: "block", marginBottom: 8 }
                                        : { marginBottom: 8 }
                                    }
                                  >
                                    <Link
                                      href={service.href}
                                      className="mega-column-title"
                                      style={{
                                        fontWeight: "bold",
                                        fontFamily: "inherit",
                                        borderBottom: "2px solid #f5c542",
                                        paddingBottom: 4,
                                        display: "inline-block",
                                        marginBottom: 8,
                                        fontSize: "1rem",
                                      }}
                                    >
                                      <strong>{service.title}</strong>
                                    </Link>
                                    {/* Only show subpoints for the first two columns */}
                                    {colIdx < 2 && service.items.length > 0 && (
                                      <ul className="mega-column-list">
                                        {service.items.map(
                                          (item, itemIndex) => (
                                            <li key={itemIndex}>
                                              <Link
                                                href={item.href}
                                                className={`${
                                                  isActive(item.href)
                                                    ? "active"
                                                    : ""
                                                }`}
                                              >
                                                {item.name}
                                              </Link>
                                            </li>
                                          )
                                        )}
                                      </ul>
                                    )}
                                  </div>
                                ))}
                              </div>
                            ))}
                          </div>
                        </div>
                      </div>
                    )}

                    <li className="nav-item">
                      <Link
                        href="/industry"
                        className={`nav-link ${
                          isActive("/industry") ? "active" : ""
                        }`}
                      >
                        Industry
                      </Link>
                    </li>

                    <li className="nav-item">
                      <Link
                        href="/career"
                        className={`nav-link ${
                          isActive("/career") ? "active" : ""
                        }`}
                      >
                        Careers
                      </Link>
                    </li>

                    <li className="nav-item">
                      <Link
                        href="/contact"
                        className={`nav-link ${
                          isActive("/contact") ? "active" : ""
                        } contact-btn`}
                      >
                        Contact Us
                      </Link>
                    </li>
                  </ul>
                </div>
              </nav>
            </div>
          </div>
        </div>
      </div>
    </>
  );
};

export default Header;