rapharehap/components/layout/MobileMenu.js

221 lines
8.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use client'
import Link from "next/link";
import { useState } from "react";
import { servicesList } from "@/utils/Services.utils";
import { areaOfInjuryData } from "@/utils/AreaOfInjery.utils";
import Rehabilitation from "@/utils/Rehabilitation.utils";
import Accident from "@/utils/Accident.utils";
export default function MobileMenu({ isSidebar, handleMobileMenu, handleSidebar }) {
const [isActive, setIsActive] = useState({
status: false,
key: "",
subMenuKey: "",
});
const handleToggle = (key, subMenuKey = "") => {
if (isActive.key === key && isActive.subMenuKey === subMenuKey) {
setIsActive({
status: false,
key: "",
subMenuKey: "",
});
} else {
setIsActive({
status: true,
key,
subMenuKey,
});
}
};
// ✅ Always close menu after clicking a link
const closeMenu = () => {
if (typeof handleMobileMenu === "function") {
handleMobileMenu();
}
};
return (
<>
<div className="mobile-menu">
{/* Backdrop */}
<div className="menu-backdrop" onClick={closeMenu} />
{/* Close button */}
<div className="close-btn" onClick={closeMenu}>
<span className="far fa-times" />
</div>
{/* Mobile Navigation */}
<nav className="menu-box">
{/* Header row (Logo left, Social icons right) */}
<div className="nav-header">
<div className="nav-logo">
<Link href="/" onClick={closeMenu}>
<img src="/assets/images/logo-2.png" alt="Logo" />
</Link>
</div>
<div className="nav-social">
<ul className="clearfix">
<li>
<Link href="https://www.instagram.com/elrapharehab/" target="_blank" rel="noopener noreferrer" onClick={closeMenu}>
<span className="fab fa-instagram"></span>
</Link>
</li>
<li>
<Link href="https://www.facebook.com/ELRaphaRehabCenter/" target="_blank" rel="noopener noreferrer" onClick={closeMenu}>
<span className="fab fa-facebook-square"></span>
</Link>
</li>
</ul>
</div>
</div>
{/* Menu Items */}
<div className="menu-outer">
<div className="collapse navbar-collapse show clearfix" id="navbarSupportedContent">
<ul className="navigation clearfix">
<li>
<Link href="/" onClick={closeMenu}>Home</Link>
</li>
{/* About Us */}
<li className={isActive.key == 1 ? "dropdown current" : "dropdown"}>
<Link href="/about-us" onClick={closeMenu}>About Us</Link>
<ul style={{ display: `${isActive.key == 1 ? "block" : "none"}` }}>
<li><Link href="/our-team-physiotherapy-etobicoke" onClick={closeMenu}>Our Team</Link></li>
<li><Link href="/ourapproach-physiotherapy-etobicoke" onClick={closeMenu}>Our Approach</Link></li>
<li><Link href="/gallery-physiotherapy-etobicoke" onClick={closeMenu}>Gallery</Link></li>
<li><Link href="/covid-19-updates" onClick={closeMenu}>Covid-19 Updates</Link></li>
</ul>
<div
className={isActive.key == 1 ? "dropdown-btn open" : "dropdown-btn"}
onClick={() => handleToggle(1)}
>
<span className="fa fa-angle-right" />
</div>
</li>
{/* Services */}
<li className={isActive.key == 2 ? "dropdown current" : "dropdown"}>
<Link href="/etobicoke-treatment-service" onClick={closeMenu}>Services</Link>
<ul style={{ display: `${isActive.key == 2 ? "block" : "none"}` }}>
{servicesList.map((item) => (
<li key={item.id}>
<Link href={`/etobicoke-treatment-service/${item.slug}`} onClick={closeMenu}>
{item.shortTitle}
</Link>
</li>
))}
</ul>
<div
className={isActive.key == 2 ? "dropdown-btn open" : "dropdown-btn"}
onClick={() => handleToggle(2)}
>
<span className="fa fa-angle-right" />
</div>
</li>
{/* Area of Injury */}
<li className={isActive.key == 3 ? "dropdown current" : "dropdown"}>
<Link href="/area-of-injury" onClick={closeMenu}>Area of Injury</Link>
<ul style={{ display: `${isActive.key == 3 ? "block" : "none"}` }}>
{areaOfInjuryData.map((item) => (
<li key={item.id}>
<Link href={`/area-of-injury/${item.slug}`} onClick={closeMenu}>
{item.title}
</Link>
</li>
))}
</ul>
<div
className={isActive.key == 3 ? "dropdown-btn open" : "dropdown-btn"}
onClick={() => handleToggle(3)}
>
<span className="fa fa-angle-right" />
</div>
</li>
{/* Rehabilitation */}
<li className={isActive.key == 4 ? "dropdown current" : "dropdown"}>
<Link href="/rehabilitation" onClick={closeMenu}>Rehabilitation</Link>
<ul style={{ display: `${isActive.key == 4 ? "block" : "none"}` }}>
{Rehabilitation.map((item) => (
<li key={item.id}>
<Link href={`/rehabilitation/${item.slug}`} onClick={closeMenu}>
{item.title}
</Link>
</li>
))}
</ul>
<div
className={isActive.key == 4 ? "dropdown-btn open" : "dropdown-btn"}
onClick={() => handleToggle(4)}
>
<span className="fa fa-angle-right" />
</div>
</li>
{/* Accident */}
<li className={isActive.key == 5 ? "dropdown current" : "dropdown"}>
<Link href="/accident" onClick={closeMenu}>Accident</Link>
<ul style={{ display: `${isActive.key == 5 ? "block" : "none"}` }}>
{Accident.map((item) => (
<li key={item.id}>
<Link href={`/accident/${item.slug}`} onClick={closeMenu}>
{item.title}
</Link>
</li>
))}
</ul>
<div
className={isActive.key == 5 ? "dropdown-btn open" : "dropdown-btn"}
onClick={() => handleToggle(5)}
>
<span className="fa fa-angle-right" />
</div>
</li>
{/* Other Links */}
<li><Link href="/contact" onClick={closeMenu}>Contact</Link></li>
<li><Link href="/blog" onClick={closeMenu}>Blog</Link></li>
<li><Link href="/why-rapha-physiotherapy-etobicoke" onClick={closeMenu}>Why Us</Link></li>
<li><Link href="/faq-physiotherapy-etobicoke" onClick={closeMenu}>Faq</Link></li>
<li><Link href="/what-to-expect" onClick={closeMenu}>What To Expect</Link></li>
<li><Link href="/payment-insurance" onClick={closeMenu}>Payment And Insurance</Link></li>
{/* <li><Link href="/refugee-physiotherapy" onClick={closeMenu}>Refugee Physiotherapy</Link></li> */}
</ul>
</div>
</div>
{/* Contact Info */}
<div className="contact-info">
<h4>Contact Info</h4>
<ul>
<li>6 4335 Bloor Street West Etobicoke, M9C5S2</li>
<li>
<Link href="tel:+647-722-3434, +416-622-2873" onClick={closeMenu}>
+647-722-3434, +416-622-2873
</Link>
</li>
<li>
<Link href="mailto:bloor@rapharehab.ca" onClick={closeMenu}>
bloor@rapharehab.ca
</Link>
</li>
</ul>
</div>
</nav>
</div>
{/* Sidebar Overlay */}
<div
className="nav-overlay"
style={{ display: `${isSidebar ? "block" : "none"}` }}
onClick={handleSidebar}
/>
</>
);
}