From e5c08cb213d0c6dbfa5a931e03eeccac518ddba1 Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Fri, 15 Sep 2023 09:32:12 +0700
Subject: change get product odoo to solr di page navbar & basiclayout & bugfix
 redirect login next page null

---
 .../components/elements/Navbar/NavbarDesktop.jsx   | 37 +++++++++++-----------
 1 file changed, 18 insertions(+), 19 deletions(-)

(limited to 'src/core/components/elements/Navbar/NavbarDesktop.jsx')

diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx
index 655c4732..2e4b25fc 100644
--- a/src/core/components/elements/Navbar/NavbarDesktop.jsx
+++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx
@@ -22,6 +22,7 @@ import productApi from '@/lib/product/api/productApi'
 import { useSession } from 'next-auth/react'
 import { AuthContext } from '@/pages/_app'
 import { TopBannerSkeleton } from '../Skeleton/TopBannerSkeleton'
+import { useProductContext } from '@/contexts/ProductContext'
 
 const Search = dynamic(() => import('./Search'))
 const TopBanner = dynamic(() => import('./TopBanner'), {
@@ -30,7 +31,7 @@ const TopBanner = dynamic(() => import('./TopBanner'), {
 
 const NavbarDesktop = () => {
   const [isOpenCategory, setIsOpenCategory] = useState(false)
-  const {authenticated} = useContext(AuthContext)
+  const { authenticated } = useContext(AuthContext)
   const auth = useAuth()
 
   const [cartCount, setCartCount] = useState(0)
@@ -40,7 +41,22 @@ const NavbarDesktop = () => {
   const [urlPath, setUrlPath] = useState(null)
 
   const router = useRouter()
-  
+
+  const { product } = useProductContext()
+
+  useEffect(() => {
+    if (router.pathname === '/shop/product/[slug]') {
+      setPayloadWa({
+        name: product?.name,
+        manufacture: product?.manufacture.name,
+        url: createSlug('/shop/product/', product?.name, product?.id, true)
+      })
+      setTemplateWA('product')
+
+      setUrlPath(router.asPath)
+    }
+  }, [product, router])
+
   useEffect(() => {
     const handleCartChange = () => {
       const cart = async () => {
@@ -52,23 +68,6 @@ const NavbarDesktop = () => {
     handleCartChange()
 
     window.addEventListener('localStorageChange', handleCartChange)
-    if (router.pathname === '/shop/product/[slug]') {
-      const authToken = getAuth().token
-
-      const { slug } = router.query
-      const getProduct = async () => {
-        let product = await productApi({ id: getIdFromSlug(slug), headers: { Token: authToken } })
-        setPayloadWa({
-          name: product[0]?.name,
-          manufacture: product[0]?.manufacture.name,
-          url: createSlug('/shop/product/', product[0]?.name, product[0]?.id, true)
-        })
-      }
-      getProduct()
-      setTemplateWA('product')
-
-      setUrlPath(router.asPath)
-    }
 
     return () => {
       window.removeEventListener('localStorageChange', handleCartChange)
-- 
cgit v1.2.3


From 54b3b9670995d62c2e11b761911430e4300fa36e Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Tue, 19 Sep 2023 17:08:55 +0700
Subject: popup cart

---
 src/core/components/elements/Navbar/NavbarDesktop.jsx | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

(limited to 'src/core/components/elements/Navbar/NavbarDesktop.jsx')

diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx
index 2e4b25fc..2bee64f7 100644
--- a/src/core/components/elements/Navbar/NavbarDesktop.jsx
+++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx
@@ -23,6 +23,7 @@ import { useSession } from 'next-auth/react'
 import { AuthContext } from '@/pages/_app'
 import { TopBannerSkeleton } from '../Skeleton/TopBannerSkeleton'
 import { useProductContext } from '@/contexts/ProductContext'
+import Cardheader from '@/lib/cart/components/Cartheader'
 
 const Search = dynamic(() => import('./Search'))
 const TopBanner = dynamic(() => import('./TopBanner'), {
@@ -101,7 +102,7 @@ const NavbarDesktop = () => {
           <div className='flex-1 flex items-center'>
             <Search />
           </div>
-          <div className='flex gap-x-4'>
+          <div className='flex gap-x-4 items-center'>
             <Link
               href='/my/transactions'
               target='_blank'
@@ -113,7 +114,8 @@ const NavbarDesktop = () => {
               <br />
               Quotation
             </Link>
-            <Link
+            <Cardheader cartCount={cartCount}/>
+            {/* <Link
               href='/shop/cart'
               target='_blank'
               rel='noreferrer'
@@ -132,7 +134,7 @@ const NavbarDesktop = () => {
                 <br />
                 Belanja
               </span>
-            </Link>
+            </Link> */}
             <Link
               target='_blank'
               rel='noreferrer'
-- 
cgit v1.2.3


From 4f285349adec93a040e41d1d8c0c1c7b57749397 Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Thu, 21 Sep 2023 14:56:35 +0700
Subject: add context for list product popup cart

---
 src/core/components/elements/Navbar/NavbarDesktop.jsx | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

(limited to 'src/core/components/elements/Navbar/NavbarDesktop.jsx')

diff --git a/src/core/components/elements/Navbar/NavbarDesktop.jsx b/src/core/components/elements/Navbar/NavbarDesktop.jsx
index 2bee64f7..3aba55c9 100644
--- a/src/core/components/elements/Navbar/NavbarDesktop.jsx
+++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx
@@ -10,17 +10,14 @@ import DesktopView from '../../views/DesktopView'
 import dynamic from 'next/dynamic'
 import IndoteknikLogo from '@/images/logo.png'
 import Category from '@/lib/category/components/Category'
-import { useContext, useEffect, useState } from 'react'
+import { useCallback, useContext, useEffect, useState } from 'react'
 import useAuth from '@/core/hooks/useAuth'
 import NavbarUserDropdown from './NavbarUserDropdown'
-import { getCountCart } from '@/core/utils/cart'
+import { getCartApi, getCountCart } from '@/core/utils/cart'
 import whatsappUrl from '@/core/utils/whatsappUrl'
 import { useRouter } from 'next/router'
 import { getAuth, setAuth } from '@/core/utils/auth'
 import { createSlug, getIdFromSlug } from '@/core/utils/slug'
-import productApi from '@/lib/product/api/productApi'
-import { useSession } from 'next-auth/react'
-import { AuthContext } from '@/pages/_app'
 import { TopBannerSkeleton } from '../Skeleton/TopBannerSkeleton'
 import { useProductContext } from '@/contexts/ProductContext'
 import Cardheader from '@/lib/cart/components/Cartheader'
@@ -32,7 +29,6 @@ const TopBanner = dynamic(() => import('./TopBanner'), {
 
 const NavbarDesktop = () => {
   const [isOpenCategory, setIsOpenCategory] = useState(false)
-  const { authenticated } = useContext(AuthContext)
   const auth = useAuth()
 
   const [cartCount, setCartCount] = useState(0)
@@ -44,7 +40,7 @@ const NavbarDesktop = () => {
   const router = useRouter()
 
   const { product } = useProductContext()
-
+  
   useEffect(() => {
     if (router.pathname === '/shop/product/[slug]') {
       setPayloadWa({
-- 
cgit v1.2.3

