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

---
 src/lib/quotation/components/Quotationheader.jsx | 189 +++++++++++++++++++++++
 1 file changed, 189 insertions(+)
 create mode 100644 src/lib/quotation/components/Quotationheader.jsx

(limited to 'src/lib/quotation/components/Quotationheader.jsx')

diff --git a/src/lib/quotation/components/Quotationheader.jsx b/src/lib/quotation/components/Quotationheader.jsx
new file mode 100644
index 00000000..141b731e
--- /dev/null
+++ b/src/lib/quotation/components/Quotationheader.jsx
@@ -0,0 +1,189 @@
+import { useCallback, useEffect, useMemo, useState } from 'react';
+import { getQuotationApi } from '../api/QuotationApi';
+import currencyFormat from '@/core/utils/currencyFormat';
+import { createSlug } from '@/core/utils/slug';
+import useAuth from '@/core/hooks/useAuth';
+import { useRouter } from 'next/router';
+import odooApi from '@/core/api/odooApi';
+import { useProductQuotationContext } from '@/contexts/ProductQuotationContext';
+import Image from '@/core/components/elements/Image/Image';
+import whatsappUrl from '@/core/utils/whatsappUrl';
+import { AnimatePresence, motion } from 'framer-motion';
+import style from '../../../../src-migrate/modules/cart/styles/item-promo.module.css';
+import useTransactions from '../../transaction/hooks/useTransactions';
+const { DocumentCheckIcon, PhotoIcon } = require('@heroicons/react/24/outline');
+const { default: Link } = require('next/link');
+
+const Quotationheader = (quotationCount) => {
+  const auth = useAuth();
+  const query = {
+    context: 'quotation',
+    site: auth?.webRole === null && auth?.site ? auth.site : null,
+  };
+
+  const router = useRouter();
+  const [subTotal, setSubTotal] = useState(null);
+  const [buttonLoading, SetButtonTerapkan] = useState(false);
+  const itemLoading = [1, 2, 3];
+  const [countQuotation, setCountQuotation] = useState(null);
+  const { productQuotation, setProductQuotation, refreshQuotation, setRefreshQuotation, isLoading, setIsloading } =
+    useProductQuotationContext();
+
+  const [isHovered, setIsHovered] = useState(false);
+  const [isTop, setIsTop] = useState(true);
+  const qotation = useMemo(() => {
+    return productQuotation || [];
+  }, [productQuotation]);
+
+  const handleMouseEnter = () => {
+    setIsHovered(true);
+    getCart();
+  };
+
+  const handleMouseLeave = () => {
+    setIsHovered(false);
+  };
+
+  const getCart = () => {
+    if (!productQuotation && auth) {
+      refreshCartf();
+    }
+  };
+  const refreshCartf = useCallback(async () => {
+    setIsloading(true);
+    let { transactions } = await useTransactions({ query });
+    let pendingTransactions = transactions?.data?.saleOrders.filter(transaction => transaction.status === 'draft');
+    setProductQuotation(pendingTransactions);
+    setCountQuotation(pendingTransactions.length);
+    setIsloading(false);
+  }, [setProductQuotation, setIsloading]);
+
+  useEffect(() => {
+    if (refreshQuotation) {
+      refreshCartf();
+    }
+    setRefreshQuotation(false);
+  }, [refreshQuotation, refreshCartf, setRefreshQuotation]);
+
+  useEffect(() => {
+    setCountQuotation(quotationCount.cartCount);
+  }, [quotationCount]);
+
+  useEffect(() => {
+    const handleScroll = () => {
+      setIsTop(window.scrollY === 0);
+    };
+    window.addEventListener('scroll', handleScroll);
+    return () => {
+      window.removeEventListener('scroll', handleScroll);
+    };
+  }, []);
+
+  const handleCheckout = async () => {
+    SetButtonTerapkan(true);
+    let checkoutAll = await odooApi('POST', `/api/v1/user/${auth.id}/cart/select-all`);
+    router.push('/shop/quotation');
+  };
+
+  return (
+    <div className='relative group'>
+      <div>
+        <Link
+          href='/my/quotations'
+          target='_blank'
+          rel='noreferrer'
+          className='flex items-center gap-x-2 !text-gray_r-12/80'
+          onMouseEnter={handleMouseEnter}
+          onMouseLeave={handleMouseLeave}
+        >
+          <div className={`relative ${countQuotation > 0 && 'mr-2'}`}>
+            <DocumentCheckIcon className='w-7' />
+            {countQuotation > 0 && (
+              <span className='absolute -top-2 -right-2 badge-solid-red rounded-full w-5 h-5 flex items-center justify-center'>
+                {countQuotation}
+              </span>
+            )}
+          </div>
+          <span>
+            Daftar
+            <br />
+            Quotation
+          </span>
+        </Link>
+      </div>
+      <AnimatePresence>
+        {isHovered && (
+          <>
+            <motion.div
+              initial={{ opacity: 0 }}
+              animate={{ opacity: 1, top: isTop ? 230 : 155 }}
+              exit={{ opacity: 0 }}
+              transition={{ duration: 0.15, top: { duration: 0.3 } }}
+              className={`fixed left-0 w-full h-full bg-black/50 z-10`}
+            />
+            <motion.div
+              initial={{ opacity: 0 }}
+              animate={{ opacity: 1, transition: { duration: 0.2 } }}
+              exit={{ opacity: 0, transition: { duration: 0.3 } }}
+              className='absolute z-10 left-0 w-96'
+              onMouseEnter={handleMouseEnter}
+              onMouseLeave={handleMouseLeave}
+            >
+              <motion.div
+                initial={{ height: 0 }}
+                animate={{ height: 'auto' }}
+                exit={{ height: 0 }}
+                className='w-full max-w-md p-2 bg-white border border-gray-200 rounded-lg shadow overflow-hidden'
+              >
+                <div className='p-2 flex justify-between items-center'>
+                  <h5 className='text-base font-semibold leading-none'>Daftar Quotation</h5>
+                  <Link href='/shop/cart' class='text-sm font-medium text-red-600 underline'>
+                    Lihat Semua
+                  </Link>
+                </div>
+                <hr className='mt-3 mb-3 border border-gray-100' />
+                <div className='flow-root max-h-[250px] overflow-y-auto'>
+                  {!auth && (
+                    <div className='justify-center p-4'>
+                      <p className='text-gray-500 text-center '>
+                        Silahkan{' '}
+                        <Link href='/login' className='text-red-600 underline leading-6'>
+                          Login
+                        </Link>{' '}
+                        Untuk Melihat Daftar Keranjang Belanja Anda
+                      </p>
+                    </div>
+                  )}
+                  {isLoading &&
+                    itemLoading.map((item) => (
+                      <div key={item} role='status' className='max-w-sm animate-pulse'>
+                        <div className='flex items-center space-x-4 mb- 2'>
+                          <div className='flex-shrink-0'>
+                            <PhotoIcon className='h-16 w-16 text-gray-500' />
+                          </div>
+                          <div className='flex-1 min-w-0'>
+                            <div className='h-2.5 bg-gray-200 rounded-full dark:bg-gray-700 w-48 mb-4'></div>
+                            <div className='h-2 bg-gray-200 rounded-full dark:bg-gray-700 max-w-[360px] mb-2.5'></div>
+                            <div className='h-2 bg-gray-200 rounded-full dark:bg-gray-700 mb-2.5'></div>
+                          </div>
+                        </div>
+                      </div>
+                    ))}
+                  {auth && qotation.length === 0 && !isLoading && (
+                    <div className='justify-center p-4'>
+                      <p className='text-gray-500 text-center '>
+                        Tidak Ada Quotation
+                      </p>
+                    </div>
+                  )}
+                </div>
+              </motion.div>
+            </motion.div>
+          </>
+        )}
+      </AnimatePresence>
+    </div>
+  );
+};
+
+export default Quotationheader;
-- 
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

---
 src/lib/quotation/components/Quotationheader.jsx | 67 +++++++++++++++++++-----
 1 file changed, 55 insertions(+), 12 deletions(-)

(limited to 'src/lib/quotation/components/Quotationheader.jsx')

diff --git a/src/lib/quotation/components/Quotationheader.jsx b/src/lib/quotation/components/Quotationheader.jsx
index 141b731e..9f0f17a6 100644
--- a/src/lib/quotation/components/Quotationheader.jsx
+++ b/src/lib/quotation/components/Quotationheader.jsx
@@ -1,16 +1,15 @@
 import { useCallback, useEffect, useMemo, useState } from 'react';
-import { getQuotationApi } from '../api/QuotationApi';
-import currencyFormat from '@/core/utils/currencyFormat';
 import { createSlug } from '@/core/utils/slug';
 import useAuth from '@/core/hooks/useAuth';
 import { useRouter } from 'next/router';
 import odooApi from '@/core/api/odooApi';
-import { useProductQuotationContext } from '@/contexts/ProductQuotationContext';
+import { useProductCartContext } from '@/contexts/ProductCartContext';
 import Image from '@/core/components/elements/Image/Image';
 import whatsappUrl from '@/core/utils/whatsappUrl';
 import { AnimatePresence, motion } from 'framer-motion';
 import style from '../../../../src-migrate/modules/cart/styles/item-promo.module.css';
 import useTransactions from '../../transaction/hooks/useTransactions';
+import currencyFormat from '@/core/utils/currencyFormat';
 const { DocumentCheckIcon, PhotoIcon } = require('@heroicons/react/24/outline');
 const { default: Link } = require('next/link');
 
@@ -20,14 +19,14 @@ const Quotationheader = (quotationCount) => {
     context: 'quotation',
     site: auth?.webRole === null && auth?.site ? auth.site : null,
   };
-
+  
   const router = useRouter();
   const [subTotal, setSubTotal] = useState(null);
   const [buttonLoading, SetButtonTerapkan] = useState(false);
   const itemLoading = [1, 2, 3];
   const [countQuotation, setCountQuotation] = useState(null);
-  const { productQuotation, setProductQuotation, refreshQuotation, setRefreshQuotation, isLoading, setIsloading } =
-    useProductQuotationContext();
+  const { productCart, setProductCart, refreshCart, setRefreshCart, isLoading, setIsloading, productQuotation, setProductQuotation, refreshQuotation, setRefreshQuotation } =
+  useProductCartContext();
 
   const [isHovered, setIsHovered] = useState(false);
   const [isTop, setIsTop] = useState(true);
@@ -49,12 +48,12 @@ const Quotationheader = (quotationCount) => {
       refreshCartf();
     }
   };
+  let { transactions } = useTransactions({ query });
   const refreshCartf = useCallback(async () => {
     setIsloading(true);
-    let { transactions } = await useTransactions({ query });
     let pendingTransactions = transactions?.data?.saleOrders.filter(transaction => transaction.status === 'draft');
     setProductQuotation(pendingTransactions);
-    setCountQuotation(pendingTransactions.length);
+    setCountQuotation(pendingTransactions?.length ? pendingTransactions?.length : pendingTransactions?.length);
     setIsloading(false);
   }, [setProductQuotation, setIsloading]);
 
@@ -66,7 +65,7 @@ const Quotationheader = (quotationCount) => {
   }, [refreshQuotation, refreshCartf, setRefreshQuotation]);
 
   useEffect(() => {
-    setCountQuotation(quotationCount.cartCount);
+    setCountQuotation(quotationCount.quotationCount);
   }, [quotationCount]);
 
   useEffect(() => {
@@ -85,6 +84,8 @@ const Quotationheader = (quotationCount) => {
     router.push('/shop/quotation');
   };
 
+  console.log("quotation",qotation)
+
   return (
     <div className='relative group'>
       <div>
@@ -105,7 +106,7 @@ const Quotationheader = (quotationCount) => {
             )}
           </div>
           <span>
-            Daftar
+            List
             <br />
             Quotation
           </span>
@@ -137,7 +138,7 @@ const Quotationheader = (quotationCount) => {
               >
                 <div className='p-2 flex justify-between items-center'>
                   <h5 className='text-base font-semibold leading-none'>Daftar Quotation</h5>
-                  <Link href='/shop/cart' class='text-sm font-medium text-red-600 underline'>
+                  <Link href='/my/quotations' class='text-sm font-medium text-red-600 underline'>
                     Lihat Semua
                   </Link>
                 </div>
@@ -150,7 +151,7 @@ const Quotationheader = (quotationCount) => {
                         <Link href='/login' className='text-red-600 underline leading-6'>
                           Login
                         </Link>{' '}
-                        Untuk Melihat Daftar Keranjang Belanja Anda
+                        Untuk Melihat Daftar Quotation Anda
                       </p>
                     </div>
                   )}
@@ -176,6 +177,48 @@ const Quotationheader = (quotationCount) => {
                       </p>
                     </div>
                   )}
+                  {auth && qotation.length > 0 && !isLoading && (
+                    <>
+                      <ul role='list' className='divide-y divide-gray-200 dark:divide-gray-700'>
+                        {qotation &&
+                          qotation?.map((product, index) => (
+                            <>
+                              <li className='py-1 sm:py-2'>
+                                <div className='flex justify-between border p-1 flex-col gap-y-2'>
+                                  <div className='flex justify-between'>
+                                    <p className='tanggal text-base'>{product.dateOrder}</p>
+                                    <p className='badge-red h-fit md:text-caption-2 whitespace-nowrap'>Pending Quotation</p>
+                                  </div>
+                                  <div className='bagian tengah flex justify-between'>
+                                    <div className='no transaksi '>  
+                                      <p className='text-base'>
+                                        No. Transaksi
+                                      </p>
+                                      <p className='font-semibold text-red-500'>
+                                        {product.name}
+                                      </p>
+                                    </div>
+                                    <div className='purchase'>
+                                    <p className='text-base'>
+                                    No. Purchase Order
+                                      </p>
+                                      <p className='font-semibold text-red-500'>
+                                      {product.purchaseOrderFile}
+                                      </p>
+                                    </div>
+                                  </div>
+                                  <div className='bagian bawah flex justify-between'>
+                                    <p className='font-semibold'>Total</p>
+                                    <p className='font-semibold'>{currencyFormat(product.amountTotal)}</p>
+                                  </div>
+                                </div>
+                              </li>
+                            </>
+                          ))}
+                      </ul>
+                      <hr />
+                    </>
+                  )}
                 </div>
               </motion.div>
             </motion.div>
-- 
cgit v1.2.3


From a1ed8969b451acc7867622fc302b0fd2b3c970a2 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Wed, 7 Aug 2024 12:10:50 +0700
Subject: <iman> update quotation pop up

---
 src/lib/quotation/components/Quotationheader.jsx | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

(limited to 'src/lib/quotation/components/Quotationheader.jsx')

diff --git a/src/lib/quotation/components/Quotationheader.jsx b/src/lib/quotation/components/Quotationheader.jsx
index 9f0f17a6..c9686b5a 100644
--- a/src/lib/quotation/components/Quotationheader.jsx
+++ b/src/lib/quotation/components/Quotationheader.jsx
@@ -184,26 +184,26 @@ const Quotationheader = (quotationCount) => {
                           qotation?.map((product, index) => (
                             <>
                               <li className='py-1 sm:py-2'>
-                                <div className='flex justify-between border p-1 flex-col gap-y-2'>
+                                <div className='flex justify-between border p-2 flex-col gap-y-2'>
                                   <div className='flex justify-between'>
-                                    <p className='tanggal text-base'>{product.dateOrder}</p>
-                                    <p className='badge-red h-fit md:text-caption-2 whitespace-nowrap'>Pending Quotation</p>
+                                    <p className='tanggal text-xs'>{product.dateOrder}</p>
+                                    <p className='badge-red h-fit md:text-caption-1 whitespace-nowrap'>Pending Quotation</p>
                                   </div>
                                   <div className='bagian tengah flex justify-between'>
                                     <div className='no transaksi '>  
-                                      <p className='text-base'>
+                                      <p className='text-xs'>
                                         No. Transaksi
                                       </p>
-                                      <p className='font-semibold text-red-500'>
+                                      <Link href='/my/quotations' className='font-semibold text-sm text-red-500'>
                                         {product.name}
-                                      </p>
+                                      </Link>
                                     </div>
                                     <div className='purchase'>
-                                    <p className='text-base'>
+                                    <p className='text-xs'>
                                     No. Purchase Order
                                       </p>
                                       <p className='font-semibold text-red-500'>
-                                      {product.purchaseOrderFile}
+                                      {product.purchaseOrderFile ? product.purchaseOrderFile : '-'}
                                       </p>
                                     </div>
                                   </div>
-- 
cgit v1.2.3


From 86c880442fc0abbc4c356da4fa8a20bc5759aff3 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Wed, 7 Aug 2024 14:00:07 +0700
Subject: <iman> quotation update popup

---
 src/lib/quotation/components/Quotationheader.jsx | 54 +++++++++++++-----------
 1 file changed, 29 insertions(+), 25 deletions(-)

(limited to 'src/lib/quotation/components/Quotationheader.jsx')

diff --git a/src/lib/quotation/components/Quotationheader.jsx b/src/lib/quotation/components/Quotationheader.jsx
index c9686b5a..79011682 100644
--- a/src/lib/quotation/components/Quotationheader.jsx
+++ b/src/lib/quotation/components/Quotationheader.jsx
@@ -184,33 +184,37 @@ const Quotationheader = (quotationCount) => {
                           qotation?.map((product, index) => (
                             <>
                               <li className='py-1 sm:py-2'>
-                                <div className='flex justify-between border p-2 flex-col gap-y-2'>
-                                  <div className='flex justify-between'>
-                                    <p className='tanggal text-xs'>{product.dateOrder}</p>
-                                    <p className='badge-red h-fit md:text-caption-1 whitespace-nowrap'>Pending Quotation</p>
-                                  </div>
-                                  <div className='bagian tengah flex justify-between'>
-                                    <div className='no transaksi '>  
-                                      <p className='text-xs'>
-                                        No. Transaksi
-                                      </p>
-                                      <Link href='/my/quotations' className='font-semibold text-sm text-red-500'>
-                                        {product.name}
-                                      </Link>
+                                <div className='flex justify-between border p-2 flex-col gap-y-2 hover:border-red-500'>
+                                <Link 
+                                    href={`/my/quotations/${product?.id}`}
+                                    className='hover:border-red-500' 
+                                     >
+                                    <div className='flex justify-between mb-2'>
+                                      <div className='flex flex-row items-center'>
+                                      <p className='tanggal text-xs opacity-80 mr-[2px]'>Sales : </p>
+                                      <p className='tanggal text-xs text-red-500 font-semibold'>{product.sales}</p>
+                                      </div>
+                                      <div className='flex flex-row items-center'>
+                                      <p className='text-xs opacity-80 mr-[2px]'>Status :</p>
+                                      <p className='badge-red h-fit text-xs whitespace-nowrap'>Pending Quotation</p>
+                                      </div>
                                     </div>
-                                    <div className='purchase'>
-                                    <p className='text-xs'>
-                                    No. Purchase Order
-                                      </p>
-                                      <p className='font-semibold text-red-500'>
-                                      {product.purchaseOrderFile ? product.purchaseOrderFile : '-'}
-                                      </p>
+                                    <div className='flex justify-between mb-2'>
+                                      <div className='flex flex-col items-start'>
+                                        <p className=' text-xs opacity-80 mr-[2px]'>No. Transaksi</p>
+                                        <p className=' text-sm text-red-500 font-semibold'> {product.name}</p>
+                                      </div>
+                                      <div className='flex flex-col items-end'>
+                                        <p className='text-xs opacity-80 mr-[2px]'>No. Purchase Order</p>
+                                        <p className='font-semibold text-sm text-red-500'> {product.purchaseOrderName ? product.purchaseOrderName : '-'}</p>
+                                      </div>
                                     </div>
-                                  </div>
-                                  <div className='bagian bawah flex justify-between'>
-                                    <p className='font-semibold'>Total</p>
-                                    <p className='font-semibold'>{currencyFormat(product.amountTotal)}</p>
-                                  </div>
+                                    <div className='my-0.5 h-0.5 bg-gray-200'></div>
+                                    <div className='bagian bawah flex justify-between mt-2'>
+                                      <p className='font-semibold text-base'>Total</p>
+                                      <p className='font-semibold text-base'>{currencyFormat(product.amountTotal)}</p>
+                                    </div>
+                                </Link>
                                 </div>
                               </li>
                             </>
-- 
cgit v1.2.3


From bad8abd263bd43c59dad8e61e2f5f35bfe5b7746 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 8 Aug 2024 11:37:58 +0700
Subject: <iman> update quotation pop up

---
 src/lib/quotation/components/Quotationheader.jsx | 38 +++++++++++++++++++++---
 1 file changed, 34 insertions(+), 4 deletions(-)

(limited to 'src/lib/quotation/components/Quotationheader.jsx')

diff --git a/src/lib/quotation/components/Quotationheader.jsx b/src/lib/quotation/components/Quotationheader.jsx
index 79011682..14743fd6 100644
--- a/src/lib/quotation/components/Quotationheader.jsx
+++ b/src/lib/quotation/components/Quotationheader.jsx
@@ -30,6 +30,7 @@ const Quotationheader = (quotationCount) => {
 
   const [isHovered, setIsHovered] = useState(false);
   const [isTop, setIsTop] = useState(true);
+
   const qotation = useMemo(() => {
     return productQuotation || [];
   }, [productQuotation]);
@@ -49,6 +50,7 @@ const Quotationheader = (quotationCount) => {
     }
   };
   let { transactions } = useTransactions({ query });
+
   const refreshCartf = useCallback(async () => {
     setIsloading(true);
     let pendingTransactions = transactions?.data?.saleOrders.filter(transaction => transaction.status === 'draft');
@@ -57,6 +59,18 @@ const Quotationheader = (quotationCount) => {
     setIsloading(false);
   }, [setProductQuotation, setIsloading]);
 
+  useEffect(() => {
+    if (!qotation) return
+
+    let calculateTotalDiscountAmount = 0
+    for (const product of qotation) {
+      // if (qotation.quantity == '') continue  
+      calculateTotalDiscountAmount += product.amountUntaxed
+    }
+    let subTotal = calculateTotalDiscountAmount
+    setSubTotal(subTotal)
+  }, [qotation])
+
   useEffect(() => {
     if (refreshQuotation) {
       refreshCartf();
@@ -84,8 +98,6 @@ const Quotationheader = (quotationCount) => {
     router.push('/shop/quotation');
   };
 
-  console.log("quotation",qotation)
-
   return (
     <div className='relative group'>
       <div>
@@ -211,8 +223,8 @@ const Quotationheader = (quotationCount) => {
                                     </div>
                                     <div className='my-0.5 h-0.5 bg-gray-200'></div>
                                     <div className='bagian bawah flex justify-between mt-2'>
-                                      <p className='font-semibold text-base'>Total</p>
-                                      <p className='font-semibold text-base'>{currencyFormat(product.amountTotal)}</p>
+                                      <p className='font-semibold text-sm'>Total</p>
+                                      <p className='font-semibold text-sm'>{currencyFormat(product.amountUntaxed)}</p>
                                     </div>
                                 </Link>
                                 </div>
@@ -224,6 +236,24 @@ const Quotationheader = (quotationCount) => {
                     </>
                   )}
                 </div>
+                {auth && qotation.length > 0 && !isLoading && (
+                  <>
+                    <div className='mt-3'>
+                      <span className='text-gray-400 text-caption-2'>Subtotal Sebelum PPN : </span>
+                      <span className='font-semibold text-red-600'>{currencyFormat(subTotal)}</span>
+                    </div>
+                    <div className='mt-5 mb-2'>
+                      <button
+                        type='button'
+                        className='btn-yellow rounded-lg w-full'
+                        onClick={handleCheckout}
+                        disabled={buttonLoading}
+                      >
+                        {buttonLoading ? 'Loading...' : 'Buat Quotation'}
+                      </button>
+                    </div>
+                  </>
+                )}
               </motion.div>
             </motion.div>
           </>
-- 
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/lib/quotation/components/Quotationheader.jsx | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

(limited to 'src/lib/quotation/components/Quotationheader.jsx')

diff --git a/src/lib/quotation/components/Quotationheader.jsx b/src/lib/quotation/components/Quotationheader.jsx
index 14743fd6..10e3e147 100644
--- a/src/lib/quotation/components/Quotationheader.jsx
+++ b/src/lib/quotation/components/Quotationheader.jsx
@@ -25,7 +25,7 @@ const Quotationheader = (quotationCount) => {
   const [buttonLoading, SetButtonTerapkan] = useState(false);
   const itemLoading = [1, 2, 3];
   const [countQuotation, setCountQuotation] = useState(null);
-  const { productCart, setProductCart, refreshCart, setRefreshCart, isLoading, setIsloading, productQuotation, setProductQuotation, refreshQuotation, setRefreshQuotation } =
+  const { productCart, setProductCart, refreshCart, setRefreshCart, isLoading, setIsloading, productQuotation, setProductQuotation } =
   useProductCartContext();
 
   const [isHovered, setIsHovered] = useState(false);
@@ -72,11 +72,11 @@ const Quotationheader = (quotationCount) => {
   }, [qotation])
 
   useEffect(() => {
-    if (refreshQuotation) {
+    if (refreshCart) {
       refreshCartf();
     }
-    setRefreshQuotation(false);
-  }, [refreshQuotation, refreshCartf, setRefreshQuotation]);
+    setRefreshCart(false);
+  }, [ refreshCartf, setRefreshCart]);
 
   useEffect(() => {
     setCountQuotation(quotationCount.quotationCount);
@@ -150,9 +150,6 @@ const Quotationheader = (quotationCount) => {
               >
                 <div className='p-2 flex justify-between items-center'>
                   <h5 className='text-base font-semibold leading-none'>Daftar Quotation</h5>
-                  <Link href='/my/quotations' class='text-sm font-medium text-red-600 underline'>
-                    Lihat Semua
-                  </Link>
                 </div>
                 <hr className='mt-3 mb-3 border border-gray-100' />
                 <div className='flow-root max-h-[250px] overflow-y-auto'>
@@ -221,7 +218,8 @@ const Quotationheader = (quotationCount) => {
                                         <p className='font-semibold text-sm text-red-500'> {product.purchaseOrderName ? product.purchaseOrderName : '-'}</p>
                                       </div>
                                     </div>
-                                    <div className='my-0.5 h-0.5 bg-gray-200'></div>
+                                    {/* <div className='my-0.5 h-0.5 bg-gray-200'></div> */}
+                                    <hr className='mt-3 mb-3 border border-gray-100' />
                                     <div className='bagian bawah flex justify-between mt-2'>
                                       <p className='font-semibold text-sm'>Total</p>
                                       <p className='font-semibold text-sm'>{currencyFormat(product.amountUntaxed)}</p>
@@ -238,18 +236,18 @@ const Quotationheader = (quotationCount) => {
                 </div>
                 {auth && qotation.length > 0 && !isLoading && (
                   <>
-                    <div className='mt-3'>
+                    <div className='mt-3 ml-1'>
                       <span className='text-gray-400 text-caption-2'>Subtotal Sebelum PPN : </span>
                       <span className='font-semibold text-red-600'>{currencyFormat(subTotal)}</span>
                     </div>
                     <div className='mt-5 mb-2'>
                       <button
                         type='button'
-                        className='btn-yellow rounded-lg w-full'
+                        className='btn-solid-red rounded-lg w-full'
                         onClick={handleCheckout}
                         disabled={buttonLoading}
                       >
-                        {buttonLoading ? 'Loading...' : 'Buat Quotation'}
+                        {buttonLoading ? 'Loading...' : 'Lihat Semua'}
                       </button>
                     </div>
                   </>
-- 
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/lib/quotation/components/Quotationheader.jsx | 1 +
 1 file changed, 1 insertion(+)

(limited to 'src/lib/quotation/components/Quotationheader.jsx')

diff --git a/src/lib/quotation/components/Quotationheader.jsx b/src/lib/quotation/components/Quotationheader.jsx
index 10e3e147..0bb4dfe0 100644
--- a/src/lib/quotation/components/Quotationheader.jsx
+++ b/src/lib/quotation/components/Quotationheader.jsx
@@ -80,6 +80,7 @@ const Quotationheader = (quotationCount) => {
 
   useEffect(() => {
     setCountQuotation(quotationCount.quotationCount);
+    setProductQuotation(quotationCount.data);
   }, [quotationCount]);
 
   useEffect(() => {
-- 
cgit v1.2.3


From 3de1a412bba31b19b8b443dd91df8aff8d6eda07 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 8 Aug 2024 16:22:00 +0700
Subject: <iman> update link button

---
 src/lib/quotation/components/Quotationheader.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src/lib/quotation/components/Quotationheader.jsx')

diff --git a/src/lib/quotation/components/Quotationheader.jsx b/src/lib/quotation/components/Quotationheader.jsx
index 0bb4dfe0..4529c977 100644
--- a/src/lib/quotation/components/Quotationheader.jsx
+++ b/src/lib/quotation/components/Quotationheader.jsx
@@ -96,7 +96,7 @@ const Quotationheader = (quotationCount) => {
   const handleCheckout = async () => {
     SetButtonTerapkan(true);
     let checkoutAll = await odooApi('POST', `/api/v1/user/${auth.id}/cart/select-all`);
-    router.push('/shop/quotation');
+    router.push('/my/quotations');
   };
 
   return (
-- 
cgit v1.2.3


From 36601aba6017aeef16f89351eb487238402ab52e Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Tue, 24 Sep 2024 16:12:50 +0700
Subject: <iman> update Perapihan Tag

---
 src/lib/quotation/components/Quotationheader.jsx | 131 +++++++++++++++++------
 1 file changed, 96 insertions(+), 35 deletions(-)

(limited to 'src/lib/quotation/components/Quotationheader.jsx')

diff --git a/src/lib/quotation/components/Quotationheader.jsx b/src/lib/quotation/components/Quotationheader.jsx
index 4529c977..cb7684ed 100644
--- a/src/lib/quotation/components/Quotationheader.jsx
+++ b/src/lib/quotation/components/Quotationheader.jsx
@@ -19,14 +19,22 @@ const Quotationheader = (quotationCount) => {
     context: 'quotation',
     site: auth?.webRole === null && auth?.site ? auth.site : null,
   };
-  
+
   const router = useRouter();
   const [subTotal, setSubTotal] = useState(null);
   const [buttonLoading, SetButtonTerapkan] = useState(false);
   const itemLoading = [1, 2, 3];
   const [countQuotation, setCountQuotation] = useState(null);
-  const { productCart, setProductCart, refreshCart, setRefreshCart, isLoading, setIsloading, productQuotation, setProductQuotation } =
-  useProductCartContext();
+  const {
+    productCart,
+    setProductCart,
+    refreshCart,
+    setRefreshCart,
+    isLoading,
+    setIsloading,
+    productQuotation,
+    setProductQuotation,
+  } = useProductCartContext();
 
   const [isHovered, setIsHovered] = useState(false);
   const [isTop, setIsTop] = useState(true);
@@ -49,34 +57,44 @@ const Quotationheader = (quotationCount) => {
       refreshCartf();
     }
   };
-  let { transactions } = useTransactions({ query });
+  let transactions = null;
+
+  if (auth) {
+    transactions = useTransactions({ query });
+  }
 
   const refreshCartf = useCallback(async () => {
     setIsloading(true);
-    let pendingTransactions = transactions?.data?.saleOrders.filter(transaction => transaction.status === 'draft');
+    let pendingTransactions = transactions?.data?.saleOrders.filter(
+      (transaction) => transaction.status === 'draft'
+    );
     setProductQuotation(pendingTransactions);
-    setCountQuotation(pendingTransactions?.length ? pendingTransactions?.length : pendingTransactions?.length);
+    setCountQuotation(
+      pendingTransactions?.length
+        ? pendingTransactions?.length
+        : pendingTransactions?.length
+    );
     setIsloading(false);
   }, [setProductQuotation, setIsloading]);
 
   useEffect(() => {
-    if (!qotation) return
+    if (!qotation) return;
 
-    let calculateTotalDiscountAmount = 0
+    let calculateTotalDiscountAmount = 0;
     for (const product of qotation) {
-      // if (qotation.quantity == '') continue  
-      calculateTotalDiscountAmount += product.amountUntaxed
+      // if (qotation.quantity == '') continue
+      calculateTotalDiscountAmount += product.amountUntaxed;
     }
-    let subTotal = calculateTotalDiscountAmount
-    setSubTotal(subTotal)
-  }, [qotation])
+    let subTotal = calculateTotalDiscountAmount;
+    setSubTotal(subTotal);
+  }, [qotation]);
 
   useEffect(() => {
     if (refreshCart) {
       refreshCartf();
     }
     setRefreshCart(false);
-  }, [ refreshCartf, setRefreshCart]);
+  }, [refreshCartf, setRefreshCart]);
 
   useEffect(() => {
     setCountQuotation(quotationCount.quotationCount);
@@ -95,7 +113,10 @@ const Quotationheader = (quotationCount) => {
 
   const handleCheckout = async () => {
     SetButtonTerapkan(true);
-    let checkoutAll = await odooApi('POST', `/api/v1/user/${auth.id}/cart/select-all`);
+    let checkoutAll = await odooApi(
+      'POST',
+      `/api/v1/user/${auth.id}/cart/select-all`
+    );
     router.push('/my/quotations');
   };
 
@@ -150,7 +171,9 @@ const Quotationheader = (quotationCount) => {
                 className='w-full max-w-md p-2 bg-white border border-gray-200 rounded-lg shadow overflow-hidden'
               >
                 <div className='p-2 flex justify-between items-center'>
-                  <h5 className='text-base font-semibold leading-none'>Daftar Quotation</h5>
+                  <h5 className='text-base font-semibold leading-none'>
+                    Daftar Quotation
+                  </h5>
                 </div>
                 <hr className='mt-3 mb-3 border border-gray-100' />
                 <div className='flow-root max-h-[250px] overflow-y-auto'>
@@ -158,7 +181,10 @@ const Quotationheader = (quotationCount) => {
                     <div className='justify-center p-4'>
                       <p className='text-gray-500 text-center '>
                         Silahkan{' '}
-                        <Link href='/login' className='text-red-600 underline leading-6'>
+                        <Link
+                          href='/login'
+                          className='text-red-600 underline leading-6'
+                        >
                           Login
                         </Link>{' '}
                         Untuk Melihat Daftar Quotation Anda
@@ -167,7 +193,11 @@ const Quotationheader = (quotationCount) => {
                   )}
                   {isLoading &&
                     itemLoading.map((item) => (
-                      <div key={item} role='status' className='max-w-sm animate-pulse'>
+                      <div
+                        key={item}
+                        role='status'
+                        className='max-w-sm animate-pulse'
+                      >
                         <div className='flex items-center space-x-4 mb- 2'>
                           <div className='flex-shrink-0'>
                             <PhotoIcon className='h-16 w-16 text-gray-500' />
@@ -189,43 +219,70 @@ const Quotationheader = (quotationCount) => {
                   )}
                   {auth && qotation.length > 0 && !isLoading && (
                     <>
-                      <ul role='list' className='divide-y divide-gray-200 dark:divide-gray-700'>
+                      <ul
+                        role='list'
+                        className='divide-y divide-gray-200 dark:divide-gray-700'
+                      >
                         {qotation &&
                           qotation?.map((product, index) => (
                             <>
                               <li className='py-1 sm:py-2'>
                                 <div className='flex justify-between border p-2 flex-col gap-y-2 hover:border-red-500'>
-                                <Link 
+                                  <Link
                                     href={`/my/quotations/${product?.id}`}
-                                    className='hover:border-red-500' 
-                                     >
+                                    className='hover:border-red-500'
+                                  >
                                     <div className='flex justify-between mb-2'>
                                       <div className='flex flex-row items-center'>
-                                      <p className='tanggal text-xs opacity-80 mr-[2px]'>Sales : </p>
-                                      <p className='tanggal text-xs text-red-500 font-semibold'>{product.sales}</p>
+                                        <p className='tanggal text-xs opacity-80 mr-[2px]'>
+                                          Sales :{' '}
+                                        </p>
+                                        <p className='tanggal text-xs text-red-500 font-semibold'>
+                                          {product.sales}
+                                        </p>
                                       </div>
                                       <div className='flex flex-row items-center'>
-                                      <p className='text-xs opacity-80 mr-[2px]'>Status :</p>
-                                      <p className='badge-red h-fit text-xs whitespace-nowrap'>Pending Quotation</p>
+                                        <p className='text-xs opacity-80 mr-[2px]'>
+                                          Status :
+                                        </p>
+                                        <p className='badge-red h-fit text-xs whitespace-nowrap'>
+                                          Pending Quotation
+                                        </p>
                                       </div>
                                     </div>
                                     <div className='flex justify-between mb-2'>
                                       <div className='flex flex-col items-start'>
-                                        <p className=' text-xs opacity-80 mr-[2px]'>No. Transaksi</p>
-                                        <p className=' text-sm text-red-500 font-semibold'> {product.name}</p>
+                                        <p className=' text-xs opacity-80 mr-[2px]'>
+                                          No. Transaksi
+                                        </p>
+                                        <p className=' text-sm text-red-500 font-semibold'>
+                                          {' '}
+                                          {product.name}
+                                        </p>
                                       </div>
                                       <div className='flex flex-col items-end'>
-                                        <p className='text-xs opacity-80 mr-[2px]'>No. Purchase Order</p>
-                                        <p className='font-semibold text-sm text-red-500'> {product.purchaseOrderName ? product.purchaseOrderName : '-'}</p>
+                                        <p className='text-xs opacity-80 mr-[2px]'>
+                                          No. Purchase Order
+                                        </p>
+                                        <p className='font-semibold text-sm text-red-500'>
+                                          {' '}
+                                          {product.purchaseOrderName
+                                            ? product.purchaseOrderName
+                                            : '-'}
+                                        </p>
                                       </div>
                                     </div>
                                     {/* <div className='my-0.5 h-0.5 bg-gray-200'></div> */}
                                     <hr className='mt-3 mb-3 border border-gray-100' />
                                     <div className='bagian bawah flex justify-between mt-2'>
-                                      <p className='font-semibold text-sm'>Total</p>
-                                      <p className='font-semibold text-sm'>{currencyFormat(product.amountUntaxed)}</p>
+                                      <p className='font-semibold text-sm'>
+                                        Total
+                                      </p>
+                                      <p className='font-semibold text-sm'>
+                                        {currencyFormat(product.amountUntaxed)}
+                                      </p>
                                     </div>
-                                </Link>
+                                  </Link>
                                 </div>
                               </li>
                             </>
@@ -238,8 +295,12 @@ const Quotationheader = (quotationCount) => {
                 {auth && qotation.length > 0 && !isLoading && (
                   <>
                     <div className='mt-3 ml-1'>
-                      <span className='text-gray-400 text-caption-2'>Subtotal Sebelum PPN : </span>
-                      <span className='font-semibold text-red-600'>{currencyFormat(subTotal)}</span>
+                      <span className='text-gray-400 text-caption-2'>
+                        Subtotal Sebelum PPN :{' '}
+                      </span>
+                      <span className='font-semibold text-red-600'>
+                        {currencyFormat(subTotal)}
+                      </span>
                     </div>
                     <div className='mt-5 mb-2'>
                       <button
-- 
cgit v1.2.3


From 2e7b5789f013c121b48edcb3589d094a2b636c59 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Wed, 25 Sep 2024 09:14:54 +0700
Subject: <iman> back to code

---
 src/lib/quotation/components/Quotationheader.jsx | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

(limited to 'src/lib/quotation/components/Quotationheader.jsx')

diff --git a/src/lib/quotation/components/Quotationheader.jsx b/src/lib/quotation/components/Quotationheader.jsx
index cb7684ed..d94a55de 100644
--- a/src/lib/quotation/components/Quotationheader.jsx
+++ b/src/lib/quotation/components/Quotationheader.jsx
@@ -57,11 +57,7 @@ const Quotationheader = (quotationCount) => {
       refreshCartf();
     }
   };
-  let transactions = null;
-
-  if (auth) {
-    transactions = useTransactions({ query });
-  }
+  let { transactions } = useTransactions({ query });
 
   const refreshCartf = useCallback(async () => {
     setIsloading(true);
-- 
cgit v1.2.3

