From ae9ec009465cd33fe2147b64a99bff424c55865b Mon Sep 17 00:00:00 2001 From: RizqiSyahrendra Date: Fri, 28 Feb 2025 13:47:35 +0700 Subject: [PATCH] fix: HeaderNav types and defect --- src/components/HeaderNav.tsx | 147 +++++++++++++++-------------------- src/data/menu.ts | 7 +- 2 files changed, 67 insertions(+), 87 deletions(-) diff --git a/src/components/HeaderNav.tsx b/src/components/HeaderNav.tsx index 58f8f8d..132d4a8 100644 --- a/src/components/HeaderNav.tsx +++ b/src/components/HeaderNav.tsx @@ -1,12 +1,12 @@ "use client"; +import { navMenuData } from "@/data/menu"; import addScrollspy from "@/utils/addScroll"; import { init_classic_menu_resize } from "@/utils/menuToggle"; import { scrollToElement } from "@/utils/scrollToElement"; -import { closeMobileMenu, toggleMobileMenu } from "@/utils/toggleMobileMenu"; -import { Fragment, useEffect, useRef, useState } from "react"; +import { toggleMobileMenu } from "@/utils/toggleMobileMenu"; import Link from "next/link"; -import { navMenuData } from "@/data/menu"; +import { Fragment, useEffect, useRef, useState } from "react"; export default function HeaderNav({ links, animateY = false }: { links: typeof navMenuData; animateY?: boolean }) { const [isDropdownOpen, setIsDropdownOpen] = useState([""]); @@ -36,89 +36,70 @@ export default function HeaderNav({ links, animateY = false }: { links: typeof n return ( <> - {links[0].href?.includes("/") && - links.map((link, index) => ( - -
  • - {!Array.isArray(link?.child) && ( - - {animateY ? ( - - {link.text} - + {links.map((link, index) => ( + +
  • + {!Array.isArray(link?.child) && ( + + {animateY ? ( + + {link.text} + - ) : ( - link.text - )} - - )} - - {Array.isArray(link?.child) && ( - <> - - {link.text} toggleDropdown([link.text])} /> - - -
      - {link.child.map((subLink: any, subLinkIdx: number) => ( -
    • - {!Array.isArray(subLink?.child) && ( - toggleMobileMenu()}> - {subLink?.text} - - )} - {Array.isArray(subLink?.child) && ( - <> - - {subLink.text}{" "} - toggleDropdown([link.text, subLink.text])} - /> - - -
        - {subLink.child.map((subLink2: any, subLinkIdx2: number) => ( -
      • - toggleMobileMenu()}> - {subLink2?.text} - -
      • - ))} -
      - - )} -
    • - ))} -
    - - )} -
  • - {index != links.length - 1 && ( -
    - )} - - ))} - - {!links[0].href?.includes("/") && - links.map((link: any, index: any) => ( -
  • - closeMobileMenu()} className="" href={link.href}> - {animateY ? ( - - {link.text} - - - ) : ( - link.text - )} - + ) : ( + link.text + )} + + )} + + {Array.isArray(link?.child) && ( + <> + + {link.text} toggleDropdown([link.text])} /> + + +
      + {link.child.map((subLink: any, subLinkIdx: number) => ( +
    • + {!Array.isArray(subLink?.child) && ( + toggleMobileMenu()}> + {subLink?.text} + + )} + {Array.isArray(subLink?.child) && ( + <> + + {subLink.text} + toggleDropdown([link.text, subLink.text])} /> + + +
        + {subLink.child.map((subLink2: any, subLinkIdx2: number) => ( +
      • + toggleMobileMenu()}> + {subLink2?.text} + +
      • + ))} +
      + + )} +
    • + ))} +
    + + )}
  • - ))} + {index != links.length - 1 && ( +
    + )} + + ))} ); } diff --git a/src/data/menu.ts b/src/data/menu.ts index 3a5a32e..0baea42 100644 --- a/src/data/menu.ts +++ b/src/data/menu.ts @@ -1,8 +1,4 @@ export const navMenuData = [ - { href: "/", text: "Home" }, - { href: "/blog", text: "Blog" }, - { href: "/testimonials", text: "Testimonials" }, - { href: "https://cochise.mdnavigatorclinical.com/prognocistc1/cochiseClinicIndex.html", text: "Patient Portal" }, { href: "#", text: "About", @@ -68,10 +64,13 @@ export const navMenuData = [ }, ], }, + { href: "https://cochise.mdnavigatorclinical.com/prognocistc1/cochiseClinicIndex.html", text: "Patient Portal" }, + { href: "/blog", text: "Blog" }, { href: "#", text: "Resources", child: [ + { href: "/testimonials", text: "Testimonials" }, { href: "/insurances", text: "Insurances" }, { href: "/support", text: "Support Groups" }, { href: "/hospitality-house", text: "Hospitality House" },