diff options
Diffstat (limited to 'src/core/components/elements/Navbar/NavbarDesktop.jsx')
| -rw-r--r-- | src/core/components/elements/Navbar/NavbarDesktop.jsx | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx index fa3df5bf..f4b0d5e1 100644 --- a/src/core/components/elements/Navbar/NavbarDesktop.jsx +++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx @@ -12,12 +12,9 @@ import { MenuButton, MenuItem, MenuList, - useDisclosure + useDisclosure, } from '@chakra-ui/react'; -import { - ChevronDownIcon, - HeartIcon -} from '@heroicons/react/24/outline'; +import { ChevronDownIcon, HeartIcon } from '@heroicons/react/24/outline'; import dynamic from 'next/dynamic'; import { default as Image, default as NextImage } from 'next/image'; import { useRouter } from 'next/router'; @@ -81,21 +78,17 @@ const NavbarDesktop = () => { }; window.addEventListener('scroll', handleScroll); + return () => { window.removeEventListener('scroll', handleScroll); }; }, []); useEffect(() => { - const handleScroll = () => { - setIsTop(window.scrollY < 100); - }; - - window.addEventListener('scroll', handleScroll); - return () => { - window.removeEventListener('scroll', handleScroll); - }; - }, []); + if (auth) { + loadCart(auth.id); + } + }, [auth]); useEffect(() => { setPendingTransactions(data); @@ -115,20 +108,22 @@ const NavbarDesktop = () => { }, [product, router]); useEffect(() => { - const handleCartChange = () => { - const cart = async () => { - const listCart = await getCountCart(); - setCartCount(listCart); - }; - cart(); - }; - handleCartChange(); - - window.addEventListener('localStorageChange', handleCartChange); - - return () => { - window.removeEventListener('localStorageChange', handleCartChange); - }; + // const handleCartChange = () => { + // const cart = async () => { + // const listCart = await getCountCart(); + // setCartCount(listCart); + // }; + // cart(); + // }; + // handleCartChange(); + + setCartCount(cart?.products?.length) + + // window.addEventListener('localStorageChange', handleCartChange); + + // return () => { + // window.removeEventListener('localStorageChange', handleCartChange); + // }; }, [transactions.data, cart]); useEffect(() => { @@ -202,7 +197,9 @@ const NavbarDesktop = () => { src={IndoteknikLogo} alt='Indoteknik Logo' width={210} - height={210 / 3} + height={70} + loading='eager' + priority={true} /> </Link> <div className='flex-1 flex items-center'> @@ -236,6 +233,7 @@ const NavbarDesktop = () => { alt='Whatsapp' width={48} height={48} + loading='eager' /> <div> <div className='font-semibold'>Whatsapp</div> @@ -284,6 +282,7 @@ const NavbarDesktop = () => { quality={100} // className={`fixed ${isTop ? 'md:top-[145px] lg:top-[160px] ' : 'lg:top-[85px] top-[80px]'} rounded-3xl md:left-1/4 lg:left-1/4 xl:left-1/4 left-2/3 w-40 h-12 p-2 z-50 transition-all duration-300 animate-pulse`} className={`inline-block relative -top-8 transition-all duration-300 z-20 animate-pulse`} + loading='eager' /> </div> )} @@ -394,6 +393,7 @@ const SocialMedias = () => ( // alt='Youtube - Indoteknik.com' width={24} height={24} + loading='eager' /> </a> <a @@ -406,6 +406,7 @@ const SocialMedias = () => ( // alt='TikTok - Indoteknik.com' width={24} height={24} + loading='eager' /> </a> {/* <a target='_blank' rel='noreferrer' href={whatsappUrl(null)}> @@ -426,6 +427,7 @@ const SocialMedias = () => ( // alt='Facebook - Indoteknik.com' width={24} height={24} + loading='eager' /> </a> <a @@ -438,6 +440,7 @@ const SocialMedias = () => ( // alt='Instagram - Indoteknik.com' width={24} height={24} + loading='eager' /> </a> <a @@ -450,6 +453,7 @@ const SocialMedias = () => ( // alt='Linkedin - Indoteknik.com' width={24} height={24} + loading='eager' /> </a> <a @@ -462,6 +466,7 @@ const SocialMedias = () => ( // alt='Maps - Indoteknik.com' width={24} height={24} + loading='eager' /> </a> </div> |
