From 0ee7434188364dc230bbd034dc165a0f4850e3db Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Sat, 3 Jun 2023 11:16:32 +0700
Subject: Add gtag event on product detail

---
 src/lib/product/components/Product/ProductDesktop.jsx | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

(limited to 'src/lib/product/components/Product/ProductDesktop.jsx')

diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx
index 75b37b9d..4a584761 100644
--- a/src/lib/product/components/Product/ProductDesktop.jsx
+++ b/src/lib/product/components/Product/ProductDesktop.jsx
@@ -14,6 +14,7 @@ import BottomPopup from '@/core/components/elements/Popup/BottomPopup'
 import ProductCard from '../ProductCard'
 import productSimilarApi from '../../api/productSimilarApi'
 import whatsappUrl from '@/core/utils/whatsappUrl'
+import { gtagAddToCart } from '@/core/utils/googleTag'
 
 const ProductDesktop = ({ product, wishlist, toggleWishlist }) => {
   const router = useRouter()
@@ -52,11 +53,12 @@ const ProductDesktop = ({ product, wishlist, toggleWishlist }) => {
     return isValid
   }
 
-  const handleAddToCart = (variantId) => {
-    const quantity = variantQuantityRefs.current[variantId].value
+  const handleAddToCart = (variant) => {
+    const quantity = variantQuantityRefs.current[variant.id].value
     if (!validQuantity(quantity)) return
+    gtagAddToCart(variant, quantity)
     updateItemCart({
-      productId: variantId,
+      productId: variant.id,
       quantity,
       selected: true
     })
@@ -247,14 +249,14 @@ const ProductDesktop = ({ product, wishlist, toggleWishlist }) => {
                 />
                 <button
                   type='button'
-                  onClick={() => handleAddToCart(product.variants[0].id)}
+                  onClick={() => handleAddToCart(product.variants[0])}
                   className='flex-1 py-2 btn-yellow'
                 >
                   Keranjang
                 </button>
                 <button
                   type='button'
-                  onClick={() => handleBuy(product.variants[0].id)}
+                  onClick={() => handleBuy(product.variants[0])}
                   className='flex-1 py-2 btn-solid-red'
                 >
                   Beli
@@ -345,7 +347,7 @@ const ProductDesktop = ({ product, wishlist, toggleWishlist }) => {
                       <td className='flex gap-x-3'>
                         <button
                           type='button'
-                          onClick={() => handleAddToCart(variant.id)}
+                          onClick={() => handleAddToCart(variant)}
                           className='flex-1 py-2 btn-yellow'
                         >
                           Keranjang
-- 
cgit v1.2.3


From a235f77530f0f51b3637b4b1096552fe3058ed69 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Fri, 16 Jun 2023 10:10:25 +0700
Subject: Add gtag begin_checkout and purchase event

---
 src/lib/product/components/Product/ProductDesktop.jsx | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

(limited to 'src/lib/product/components/Product/ProductDesktop.jsx')

diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx
index 4a584761..6a87d022 100644
--- a/src/lib/product/components/Product/ProductDesktop.jsx
+++ b/src/lib/product/components/Product/ProductDesktop.jsx
@@ -65,10 +65,10 @@ const ProductDesktop = ({ product, wishlist, toggleWishlist }) => {
     setAddCartAlert(true)
   }
 
-  const handleBuy = (variantId) => {
-    const quantity = variantQuantityRefs.current[variantId].value
+  const handleBuy = (variant) => {
+    const quantity = variantQuantityRefs.current[variant.id].value
     if (!validQuantity(quantity)) return
-    router.push(`/shop/checkout?productId=${variantId}&quantity=${quantity}`)
+    router.push(`/shop/checkout?productId=${variant.id}&quantity=${quantity}`)
   }
 
   const variantSectionRef = useRef(null)
-- 
cgit v1.2.3


From 3f890e6d482cefba37014e021cb4c2b8d5de2a9d Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Wed, 12 Jul 2023 14:31:07 +0700
Subject: cr

---
 src/lib/product/components/Product/ProductDesktop.jsx | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

(limited to 'src/lib/product/components/Product/ProductDesktop.jsx')

diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx
index 6a87d022..cafab721 100644
--- a/src/lib/product/components/Product/ProductDesktop.jsx
+++ b/src/lib/product/components/Product/ProductDesktop.jsx
@@ -66,9 +66,9 @@ const ProductDesktop = ({ product, wishlist, toggleWishlist }) => {
   }
 
   const handleBuy = (variant) => {
-    const quantity = variantQuantityRefs.current[variant.id].value
+    const quantity = variantQuantityRefs.current[variant].value
     if (!validQuantity(quantity)) return
-    router.push(`/shop/checkout?productId=${variant.id}&quantity=${quantity}`)
+    router.push(`/shop/checkout?productId=${variant}&quantity=${quantity}`)
   }
 
   const variantSectionRef = useRef(null)
-- 
cgit v1.2.3


From b886fcf2dbc9114bc2e2347e3d4bf5299ed43d3b Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Fri, 14 Jul 2023 09:26:08 +0700
Subject: toggle on off

---
 src/lib/product/components/Product/ProductDesktop.jsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src/lib/product/components/Product/ProductDesktop.jsx')

diff --git a/src/lib/product/components/Product/ProductDesktop.jsx b/src/lib/product/components/Product/ProductDesktop.jsx
index cafab721..037b8c66 100644
--- a/src/lib/product/components/Product/ProductDesktop.jsx
+++ b/src/lib/product/components/Product/ProductDesktop.jsx
@@ -256,7 +256,7 @@ const ProductDesktop = ({ product, wishlist, toggleWishlist }) => {
                 </button>
                 <button
                   type='button'
-                  onClick={() => handleBuy(product.variants[0])}
+                  onClick={() => handleBuy(product.variants[0].id)}
                   className='flex-1 py-2 btn-solid-red'
                 >
                   Beli
-- 
cgit v1.2.3

