Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

219 righe
12 KiB

  1. import React, { useState } from "react";
  2. import Link from '@/utils/ActiveLink';
  3. import * as Icon from 'react-feather';
  4. export default function NavbarYamaha({ username, ...props }) {
  5. const [menu, setMenu] = React.useState(true)
  6. const toggleNavbar = () => {
  7. setMenu(!menu)
  8. }
  9. React.useEffect(() => {
  10. let elementId = document.getElementById("header");
  11. document.addEventListener("scroll", () => {
  12. if (window.scrollY > 170) {
  13. elementId.classList.add("is-sticky");
  14. } else {
  15. elementId.classList.remove("is-sticky");
  16. }
  17. });
  18. window.scrollTo(0, 0);
  19. })
  20. const classOne = menu ? 'collapse navbar-collapse' : 'collapse navbar-collapse show';
  21. const classTwo = menu ? 'navbar-toggler navbar-toggler-right collapsed' : 'navbar-toggler navbar-toggler-right';
  22. return (
  23. <header id="header" className="headroom navbar-style-two">
  24. <div className="startp-nav">
  25. <div className="container">
  26. <nav className="navbar navbar-expand-md navbar-light">
  27. <Link href="/yamaha">
  28. <a onClick={toggleNavbar} className="navbar-brand">
  29. <img src="/images/Home/businees/ThamrinBrothers.png" width="200px" alt="logo" />
  30. </a>
  31. </Link>
  32. <button
  33. onClick={toggleNavbar}
  34. className={classTwo}
  35. type="button"
  36. data-toggle="collapse"
  37. data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent"
  38. aria-expanded="false"
  39. aria-label="Toggle navigation"
  40. >
  41. <span className="icon-bar top-bar"></span>
  42. <span className="icon-bar middle-bar"></span>
  43. <span className="icon-bar bottom-bar"></span>
  44. </button>
  45. <div className={classOne} id="navbarSupportedContent">
  46. <ul className="navbar-nav ms-auto">
  47. <li className="nav-item">
  48. <Link href="/yamaha" activeClassName="active">
  49. <a onClick={e => e.preventDefault()} className="nav-link">
  50. Home
  51. </a>
  52. </Link>
  53. </li>
  54. <li className="nav-item">
  55. <Link href="#">
  56. <a onClick={e => e.preventDefault()} className="nav-link">
  57. Product <Icon.ChevronDown />
  58. </a>
  59. </Link>
  60. <ul className="dropdown-menu">
  61. <li className="nav-item">
  62. <Link href="/yamaha/Product/Motor" activeClassName="active">
  63. <a onClick={toggleNavbar} className="nav-link">Motor Product</a>
  64. </Link>
  65. </li>
  66. <li className="nav-item">
  67. <Link href="/yamaha/Product/Sparepart" activeClassName="active">
  68. <a onClick={toggleNavbar} className="nav-link">Sparepart Product</a>
  69. </Link>
  70. </li>
  71. <li className="nav-item">
  72. <Link href="https://booking.thamrin.co.id/" activeClassName="active">
  73. <a target="_blank" onClick={toggleNavbar} className="nav-link">Service Product</a>
  74. </Link>
  75. </li>
  76. </ul>
  77. </li>
  78. <li className="nav-item">
  79. <Link href="/yamaha/LatestNews">
  80. <a onClick={toggleNavbar} className="nav-link">
  81. Latest News
  82. </a>
  83. </Link>
  84. </li>
  85. <li className="nav-item">
  86. <Link href="/#" activeClassName="active">
  87. <a onClick={e => e.preventDefault()} className="nav-link">
  88. Carrer
  89. </a>
  90. </Link>
  91. </li>
  92. <li className="nav-item">
  93. <Link href="/yamaha/AboutUs">
  94. <a onClick={toggleNavbar} className="nav-link">
  95. About Us
  96. </a>
  97. </Link>
  98. </li>
  99. <li className="nav-item">
  100. <Link href="/yamaha/ContactUs" activeClassName="active">
  101. <a onClick={toggleNavbar} className="nav-link">Contact</a>
  102. </Link>
  103. </li>
  104. </ul>
  105. </div>
  106. <div className="others-option">
  107. <Link href="/yamaha/Shop/Cart">
  108. <a className="cart-wrapper-btn">
  109. <Icon.ShoppingCart />
  110. </a>
  111. </Link>
  112. <Link href="/yamaha/login">
  113. {!username || username == "" ? (
  114. <Link href="/yamaha/login">
  115. <a className="btn btn-primary">Login</a>
  116. </Link>
  117. ) : (
  118. <li className="nav-item">
  119. <Link href="#">
  120. <a onClick={e => e.preventDefault()} className="nav-link">
  121. Product <Icon.ChevronDown />
  122. </a>
  123. </Link>
  124. <ul className="dropdown-menu">
  125. <li className="nav-item">
  126. <Link href="/yamaha/Product/Motor" activeClassName="active">
  127. <a onClick={toggleNavbar} className="nav-link">Motor Product</a>
  128. </Link>
  129. </li>
  130. <li className="nav-item">
  131. <Link href="/yamaha/Product/Sparepart" activeClassName="active">
  132. <a onClick={toggleNavbar} className="nav-link">Sparepart Product</a>
  133. </Link>
  134. </li>
  135. <li className="nav-item">
  136. <Link href="https://booking.thamrin.co.id/" activeClassName="active">
  137. <a target="_blank" onClick={toggleNavbar} className="nav-link">Service Product</a>
  138. </Link>
  139. </li>
  140. </ul>
  141. </li>
  142. // <CustomDropdown
  143. // noLiPadding
  144. // navDropdown
  145. // buttonText={
  146. // username.length > 12 ? username.substring(0, 9) + ".." : username
  147. // }
  148. // buttonProps={{
  149. // className: classes.navLink,
  150. // color: "transparent",
  151. // }}
  152. // buttonIcon={Person}
  153. // dropdownList={[
  154. // <div
  155. // onClick={async (e) => {
  156. // e.preventDefault();
  157. // fetch("/api/auth/logout", {
  158. // method: "POST",
  159. // headers: {
  160. // "Content-Type": "application/json",
  161. // },
  162. // body: JSON.stringify({ p: "YAMAHA" }),
  163. // }).then((res) => {
  164. // //if (res.ok) {
  165. // window.location.href = "../yamaha/home";
  166. // /*}
  167. // else{
  168. // }*/
  169. // });
  170. // }}
  171. // >
  172. // <Link href="/yamaha/login">
  173. // <a className="btn btn-primary">Logout</a>
  174. // </Link>
  175. // </div>,
  176. // <div>
  177. // <Link href="/yamaha/login">
  178. // <a className="btn btn-primary">Profile</a>
  179. // </Link>
  180. // </div>,
  181. // <div>
  182. // <Link href="/yamaha/login">
  183. // <a className="btn btn-primary">Pesanan Saya</a>
  184. // </Link>
  185. // </div>
  186. // // <a href="/yamaha/profile/profile" className={classes.dropdownLink}>Profile</a>,
  187. // ]}
  188. // />
  189. )}
  190. </Link>
  191. </div>
  192. </nav>
  193. </div>
  194. </div>
  195. </header>
  196. );
  197. }