From 0f4938c0f9ce12d60bac2eb012a98b818fcd5110 Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Tue, 6 Aug 2024 08:59:31 +0700
Subject: <iman> update refresh cart

---
 src-migrate/modules/product-detail/components/AddToCart.tsx | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

(limited to 'src-migrate/modules/product-detail/components/AddToCart.tsx')

diff --git a/src-migrate/modules/product-detail/components/AddToCart.tsx b/src-migrate/modules/product-detail/components/AddToCart.tsx
index 6c9aedf8..c73d7b36 100644
--- a/src-migrate/modules/product-detail/components/AddToCart.tsx
+++ b/src-migrate/modules/product-detail/components/AddToCart.tsx
@@ -34,8 +34,7 @@ const AddToCart = ({
 
   const [product, setProducts] = useState(products);
   
-  const { productCart, setRefreshCart, setProductCart, refreshCart, isLoading, setIsloading } =
-  useProductCartContext()
+  const {setRefreshCart} = useProductCartContext()
 
   const productSimilarQuery = [
     product?.name,
@@ -50,16 +49,17 @@ const AddToCart = ({
       router.push(`/login?next=${currentUrl}`)
       return;
     }
-
+    
     if (
       !variantId ||
       isNaN(quantity) ||
       typeof auth !== 'object'
     ) return;
-
+    
     setRefreshCart(true);
+    // console.log('Refresh cart triggered');
     setAddCartAlert(true);
-
+    
     toast.promise(
       upsertUserCart({
         userId: auth.id,
@@ -78,7 +78,7 @@ const AddToCart = ({
     )
     
     
-
+    
     if (source === 'buy') {
       router.push('/shop/checkout?source=buy')
     }
-- 
cgit v1.2.3


From 1ce47f63e967d32d8e6026c0f2e8da931d23fd4c Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Tue, 6 Aug 2024 10:21:43 +0700
Subject: <iman> update add to cart pop up

---
 .../product-detail/components/AddToCart.tsx        | 59 +++++++++++++++++++++-
 1 file changed, 57 insertions(+), 2 deletions(-)

(limited to 'src-migrate/modules/product-detail/components/AddToCart.tsx')

diff --git a/src-migrate/modules/product-detail/components/AddToCart.tsx b/src-migrate/modules/product-detail/components/AddToCart.tsx
index c73d7b36..bebc793f 100644
--- a/src-migrate/modules/product-detail/components/AddToCart.tsx
+++ b/src-migrate/modules/product-detail/components/AddToCart.tsx
@@ -1,4 +1,5 @@
 import BottomPopup from '@/core/components/elements/Popup/BottomPopup'
+import style from '../styles/price-action.module.css';
 import { Button, Link, useToast } from '@chakra-ui/react'
 import product from 'next-seo/lib/jsonld/product'
 import { useRouter } from 'next/router'
@@ -11,6 +12,9 @@ import ProductSimilar from '../../../../src/lib/product/components/ProductSimila
 import { IProductDetail } from '~/types/product';
 import ImageNext from 'next/image';
 import { useProductCartContext } from '@/contexts/ProductCartContext'
+import { createSlug } from '~/libs/slug'
+import formatCurrency from '~/libs/formatCurrency'
+import { useProductDetail } from '../stores/useProductDetail';
 
 type Props = {
   variantId: number | null,
@@ -32,6 +36,10 @@ const AddToCart = ({
     isClosable: true
   })
 
+  const {
+    askAdminUrl,
+  } = useProductDetail();
+
   const [product, setProducts] = useState(products);
   
   const {setRefreshCart} = useProductCartContext()
@@ -118,8 +126,55 @@ const AddToCart = ({
                   height={80}
                 />
             </div>
-            <div className='ml-3 flex flex-1 items-center font-normal'>
-              {product.name}
+            <div className='ml-3 flex flex-1 items-start font-medium justify-center flex-col gap-y-1'>
+              {!!product.manufacture.name ? (
+                  <Link
+                  href={createSlug('/shop/brands/', product.manufacture.name, product.manufacture.id.toString())}
+                  className=' hover:underline'
+                  color={"red"}
+                  >
+                    {product.manufacture.name}
+                  </Link>
+                ) : '-'}
+              <p className='text-ellipsis overflow-hidden'>
+                {product.name}
+                </p>
+                <p>
+                  {product.code}
+                </p>
+                {!!product.lowest_price && product.lowest_price.price > 0 && (
+                    <>
+                      <div className='flex items-end gap-x-2'>
+                        {product.lowest_price.discount_percentage > 0 && (
+                          <>
+                            <div className='badge-solid-red'>
+                              {Math.floor(product.lowest_price.discount_percentage)}%
+                            </div>
+                            <div className='text-gray_r-11 line-through text-[11px] sm:text-caption-2'>
+                              Rp {formatCurrency(product.lowest_price.price || 0)}
+                            </div>
+                          </>
+                        )}
+                        <div className='text-danger-500 font-semibold'>
+                          Rp {formatCurrency(product.lowest_price.price_discount || 0)}
+                        </div>
+                      </div>
+                    </>
+                  )}
+
+                  {!!product.lowest_price && product.lowest_price.price === 0 && (
+                    <span>
+                      Hubungi kami untuk dapatkan harga terbaik,{' '}
+                      <Link
+                        href={askAdminUrl}
+                        target='_blank'
+                        className='font-medium underline'
+                        color={'red'}
+                      >
+                        klik disini
+                      </Link>
+                    </span>
+                  )}
             </div>
             <div className='ml-3 flex items-center font-normal'>
               <Link
-- 
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-migrate/modules/product-detail/components/AddToCart.tsx | 1 -
 1 file changed, 1 deletion(-)

(limited to 'src-migrate/modules/product-detail/components/AddToCart.tsx')

diff --git a/src-migrate/modules/product-detail/components/AddToCart.tsx b/src-migrate/modules/product-detail/components/AddToCart.tsx
index bebc793f..2f87311f 100644
--- a/src-migrate/modules/product-detail/components/AddToCart.tsx
+++ b/src-migrate/modules/product-detail/components/AddToCart.tsx
@@ -65,7 +65,6 @@ const AddToCart = ({
     ) return;
     
     setRefreshCart(true);
-    // console.log('Refresh cart triggered');
     setAddCartAlert(true);
     
     toast.promise(
-- 
cgit v1.2.3

