From 807931ee9bcb063157ceb8368e5ee0941450c6ca Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Tue, 6 Aug 2024 14:32:41 +0700
Subject: <iman> add quotation pop up

---
 .../components/elements/Navbar/NavbarDesktop.jsx   | 58 ++++++++++++++++------
 1 file changed, 43 insertions(+), 15 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 7d9e4264..49c4cd6e 100644
--- a/src/core/components/elements/Navbar/NavbarDesktop.jsx
+++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx
@@ -5,7 +5,9 @@ import { createSlug } from '@/core/utils/slug';
 import whatsappUrl from '@/core/utils/whatsappUrl';
 import IndoteknikLogo from '@/images/logo.png';
 import Cardheader from '@/lib/cart/components/Cartheader';
+import Quotationheader from '@/lib/quotation/components/QuotationHeader'
 import Category from '@/lib/category/components/Category';
+import { useProductQuotationContext } from '@/contexts/ProductQuotationContext'
 import {
   ChevronDownIcon,
   DocumentCheckIcon,
@@ -28,6 +30,7 @@ import {
   useDisclosure,
 } from '@chakra-ui/react';
 import style from "./style/NavbarDesktop.module.css";
+import useTransactions from '@/lib/transaction/hooks/useTransactions';
 
 const Search = dynamic(() => import('./Search'), { ssr: false });
 const TopBanner = dynamic(() => import('./TopBanner'), { ssr: false });
@@ -37,6 +40,8 @@ const NavbarDesktop = () => {
   const auth = useAuth();
 
   const [cartCount, setCartCount] = useState(0);
+  const [quotationCount, setQuotationCount] = useState(0);
+  // const { setProductQuotation, refreshQuotation, setRefreshQuotation, isLoading, setIsloading } = useProductQuotationContext()
 
   const [templateWA, setTemplateWA] = useState(null);
   const [payloadWA, setPayloadWa] = useState(null);
@@ -47,6 +52,16 @@ const NavbarDesktop = () => {
   const { product } = useProductContext();
   const { isOpen, onOpen, onClose } = useDisclosure();
 
+  const query = {
+    context: 'quotation',
+    site:
+      (auth?.webRole === null && auth?.site ? auth.site : null),
+  };
+  
+  const { transactions } = useTransactions({query});
+  const pendingTransactions = transactions?.data?.saleOrders.filter(transaction => transaction.status === 'draft');
+  
+  
   useEffect(() => {
     if (router.pathname === '/shop/product/[slug]') {
       setPayloadWa({
@@ -55,11 +70,11 @@ const NavbarDesktop = () => {
         url: createSlug('/shop/product/', product?.name, product?.id, true),
       });
       setTemplateWA('product');
-
+      
       setUrlPath(router.asPath);
     }
   }, [product, router]);
-
+  
   useEffect(() => {
     const handleCartChange = () => {
       const cart = async () => {
@@ -69,14 +84,36 @@ const NavbarDesktop = () => {
       cart();
     };
     handleCartChange();
-
+    
     window.addEventListener('localStorageChange', handleCartChange);
-
+    
     return () => {
       window.removeEventListener('localStorageChange', handleCartChange);
     };
   }, []);
+  
+  // useEffect(() => {
+  //   setProductQuotation(pendingTransactions)
+  // }, [transactions, ])
+  // console.log("Pending Transactions", pendingTransactions); 
+  // console.log("pendingTransactions.length", pendingTransactions.length); 
+
+  useEffect(() => {
+    const handleQuotationChange = () => {
+      const quotation = async () => {
+        setQuotationCount(pendingTransactions?.length);
+      };
+      quotation();
+    };
+    handleQuotationChange();
 
+    window.addEventListener('localStorageChange', handleQuotationChange);
+
+    return () => {
+      window.removeEventListener('localStorageChange', handleQuotationChange);
+    };
+  }, []);
+  console.log("quotationCount",quotationCount)
   return (
     <DesktopView>
       <TopBanner />
@@ -139,17 +176,8 @@ const NavbarDesktop = () => {
             <Search />
           </div>
           <div className='flex gap-x-4 items-center'>
-            <Link
-              href='/my/transactions'
-              target='_blank'
-              rel='noreferrer'
-              className='flex items-center gap-x-2 !text-gray_r-12/80'
-            >
-              <DocumentCheckIcon className='w-7' />
-              Daftar
-              <br />
-              Quotation
-            </Link>
+
+            <Quotationheader quotationCount={quotationCount} />
 
             <Cardheader cartCount={cartCount} />
 
-- 
cgit v1.2.3


From a63b03fffdf46ecddecf356d1d00d6582add75cf Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Tue, 6 Aug 2024 17:05:01 +0700
Subject: <iman> update cart pop up

---
 .../components/elements/Navbar/NavbarDesktop.jsx   | 35 +++++++++++-----------
 1 file changed, 18 insertions(+), 17 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 49c4cd6e..c0e9b383 100644
--- a/src/core/components/elements/Navbar/NavbarDesktop.jsx
+++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx
@@ -7,7 +7,7 @@ import IndoteknikLogo from '@/images/logo.png';
 import Cardheader from '@/lib/cart/components/Cartheader';
 import Quotationheader from '@/lib/quotation/components/QuotationHeader'
 import Category from '@/lib/category/components/Category';
-import { useProductQuotationContext } from '@/contexts/ProductQuotationContext'
+import { useProductCartContext } from '@/contexts/ProductCartContext';
 import {
   ChevronDownIcon,
   DocumentCheckIcon,
@@ -41,8 +41,9 @@ const NavbarDesktop = () => {
 
   const [cartCount, setCartCount] = useState(0);
   const [quotationCount, setQuotationCount] = useState(0);
-  // const { setProductQuotation, refreshQuotation, setRefreshQuotation, isLoading, setIsloading } = useProductQuotationContext()
-
+  const { productCart, setProductCart, refreshCart, setRefreshCart, isLoading, setIsloading, productQuotation, setProductQuotation, refreshQuotation, setRefreshQuotation } =
+  useProductCartContext();
+  const [pendingTransactions, setPendingTransactions] = useState([])
   const [templateWA, setTemplateWA] = useState(null);
   const [payloadWA, setPayloadWa] = useState(null);
   const [urlPath, setUrlPath] = useState(null);
@@ -51,15 +52,22 @@ const NavbarDesktop = () => {
 
   const { product } = useProductContext();
   const { isOpen, onOpen, onClose } = useDisclosure();
-
+  
   const query = {
     context: 'quotation',
     site:
-      (auth?.webRole === null && auth?.site ? auth.site : null),
+    (auth?.webRole === null && auth?.site ? auth.site : null),
   };
   
-  const { transactions } = useTransactions({query});
-  const pendingTransactions = transactions?.data?.saleOrders.filter(transaction => transaction.status === 'draft');
+  const { transactions } = useTransactions({ query });
+  const data = transactions?.data?.saleOrders.filter(
+    (transaction) => transaction.status === 'draft'
+  );
+
+  useEffect(() => {
+    setProductQuotation(data);
+    setPendingTransactions(data);
+  }, [transactions.data]);
   
   
   useEffect(() => {
@@ -83,7 +91,7 @@ const NavbarDesktop = () => {
       };
       cart();
     };
-    handleCartChange();
+    handleCartChange(); 
     
     window.addEventListener('localStorageChange', handleCartChange);
     
@@ -91,12 +99,6 @@ const NavbarDesktop = () => {
       window.removeEventListener('localStorageChange', handleCartChange);
     };
   }, []);
-  
-  // useEffect(() => {
-  //   setProductQuotation(pendingTransactions)
-  // }, [transactions, ])
-  // console.log("Pending Transactions", pendingTransactions); 
-  // console.log("pendingTransactions.length", pendingTransactions.length); 
 
   useEffect(() => {
     const handleQuotationChange = () => {
@@ -112,8 +114,8 @@ const NavbarDesktop = () => {
     return () => {
       window.removeEventListener('localStorageChange', handleQuotationChange);
     };
-  }, []);
-  console.log("quotationCount",quotationCount)
+  }, [pendingTransactions]);
+  
   return (
     <DesktopView>
       <TopBanner />
@@ -176,7 +178,6 @@ const NavbarDesktop = () => {
             <Search />
           </div>
           <div className='flex gap-x-4 items-center'>
-
             <Quotationheader quotationCount={quotationCount} />
 
             <Cardheader cartCount={cartCount} />
-- 
cgit v1.2.3


From 29662765048f561af5ab0dc586a37bd80068b633 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 8 Aug 2024 11:45:59 +0700
Subject: <iman> update location quotationHeader

---
 src/core/components/elements/Navbar/NavbarDesktop.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(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 c0e9b383..85e77b2d 100644
--- a/src/core/components/elements/Navbar/NavbarDesktop.jsx
+++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx
@@ -5,7 +5,7 @@ import { createSlug } from '@/core/utils/slug';
 import whatsappUrl from '@/core/utils/whatsappUrl';
 import IndoteknikLogo from '@/images/logo.png';
 import Cardheader from '@/lib/cart/components/Cartheader';
-import Quotationheader from '@/lib/quotation/components/QuotationHeader'
+import Quotationheader from '../../../../../src/lib/quotation/components/QuotationHeader'
 import Category from '@/lib/category/components/Category';
 import { useProductCartContext } from '@/contexts/ProductCartContext';
 import {
-- 
cgit v1.2.3


From 6e36b0e78c7ac56c8b7d2f27a19838e9aaa9da98 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 8 Aug 2024 12:03:04 +0700
Subject: <iman> add import quotationHeader

---
 src/core/components/elements/Navbar/NavbarDesktop.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(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 85e77b2d..03335df6 100644
--- a/src/core/components/elements/Navbar/NavbarDesktop.jsx
+++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx
@@ -5,7 +5,7 @@ import { createSlug } from '@/core/utils/slug';
 import whatsappUrl from '@/core/utils/whatsappUrl';
 import IndoteknikLogo from '@/images/logo.png';
 import Cardheader from '@/lib/cart/components/Cartheader';
-import Quotationheader from '../../../../../src/lib/quotation/components/QuotationHeader'
+import Quotationheader from "../../../../../src/lib/quotation/components/Quotationheader.jsx"
 import Category from '@/lib/category/components/Category';
 import { useProductCartContext } from '@/contexts/ProductCartContext';
 import {
-- 
cgit v1.2.3


From 079f8029445fdd243e267a4af7c7a4d5780afa24 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 8 Aug 2024 14:11:32 +0700
Subject: <iman> update pop up quotation & cart

---
 src/core/components/elements/Navbar/NavbarDesktop.jsx | 3 ---
 1 file changed, 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 03335df6..2e8c982e 100644
--- a/src/core/components/elements/Navbar/NavbarDesktop.jsx
+++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx
@@ -41,8 +41,6 @@ const NavbarDesktop = () => {
 
   const [cartCount, setCartCount] = useState(0);
   const [quotationCount, setQuotationCount] = useState(0);
-  const { productCart, setProductCart, refreshCart, setRefreshCart, isLoading, setIsloading, productQuotation, setProductQuotation, refreshQuotation, setRefreshQuotation } =
-  useProductCartContext();
   const [pendingTransactions, setPendingTransactions] = useState([])
   const [templateWA, setTemplateWA] = useState(null);
   const [payloadWA, setPayloadWa] = useState(null);
@@ -65,7 +63,6 @@ const NavbarDesktop = () => {
   );
 
   useEffect(() => {
-    setProductQuotation(data);
     setPendingTransactions(data);
   }, [transactions.data]);
   
-- 
cgit v1.2.3


From 64489b794a80b381d86ea226f0fe36457d5836be Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 8 Aug 2024 15:06:37 +0700
Subject: <iman> update quotation pop up bug

---
 src/core/components/elements/Navbar/NavbarDesktop.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(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 2e8c982e..1163aff3 100644
--- a/src/core/components/elements/Navbar/NavbarDesktop.jsx
+++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx
@@ -175,7 +175,7 @@ const NavbarDesktop = () => {
             <Search />
           </div>
           <div className='flex gap-x-4 items-center'>
-            <Quotationheader quotationCount={quotationCount} />
+            <Quotationheader quotationCount={quotationCount} data={pendingTransactions} />
 
             <Cardheader cartCount={cartCount} />
 
-- 
cgit v1.2.3


From cf3bcd1f3d1e0649204a786e9532a099772dad85 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Sat, 31 Aug 2024 09:42:34 +0700
Subject: <iman> update cart pop up

---
 src/core/components/elements/Navbar/NavbarDesktop.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(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 0d0e8550..ff08a4a1 100644
--- a/src/core/components/elements/Navbar/NavbarDesktop.jsx
+++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx
@@ -136,7 +136,7 @@ const NavbarDesktop = () => {
     return () => {
       window.removeEventListener('localStorageChange', handleCartChange);
     };
-  }, []);
+  }, [transactions.data]);
 
   useEffect(() => {
     const handleQuotationChange = () => {
-- 
cgit v1.2.3


From a76376b74c02ee6875b68b6cfb59090a159df40a Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Sat, 31 Aug 2024 11:44:49 +0700
Subject: <iman> update new cart pop up

---
 src/core/components/elements/Navbar/NavbarDesktop.jsx | 5 +++--
 1 file changed, 3 insertions(+), 2 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 ff08a4a1..454202df 100644
--- a/src/core/components/elements/Navbar/NavbarDesktop.jsx
+++ b/src/core/components/elements/Navbar/NavbarDesktop.jsx
@@ -32,6 +32,7 @@ import {
 } from '@chakra-ui/react';
 import style from "./style/NavbarDesktop.module.css";
 import useTransactions from '@/lib/transaction/hooks/useTransactions';
+import { useCartStore } from '~/modules/cart/stores/useCartStore';
 
 const Search = dynamic(() => import('./Search'), { ssr: false });
 const TopBanner = dynamic(() => import('./TopBanner'), { ssr: false });
@@ -46,7 +47,7 @@ const NavbarDesktop = () => {
   const [templateWA, setTemplateWA] = useState(null);
   const [payloadWA, setPayloadWa] = useState(null);
   const [urlPath, setUrlPath] = useState(null);
-
+  const { loadCart, cart, summary, updateCartItem } = useCartStore();
   const router = useRouter();
 
   const { product } = useProductContext();
@@ -136,7 +137,7 @@ const NavbarDesktop = () => {
     return () => {
       window.removeEventListener('localStorageChange', handleCartChange);
     };
-  }, [transactions.data]);
+  }, [transactions.data, cart]);
 
   useEffect(() => {
     const handleQuotationChange = () => {
-- 
cgit v1.2.3

