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/Product.jsx | 6 ++++++
 1 file changed, 6 insertions(+)

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

diff --git a/src/lib/product/components/Product/Product.jsx b/src/lib/product/components/Product/Product.jsx
index 9521cbe4..351c07c1 100644
--- a/src/lib/product/components/Product/Product.jsx
+++ b/src/lib/product/components/Product/Product.jsx
@@ -5,6 +5,8 @@ import ProductDesktop from './ProductDesktop'
 import useAuth from '@/core/hooks/useAuth'
 import ProductMobile from './ProductMobile'
 import { useRouter } from 'next/router'
+import { useEffect } from 'react'
+import { gtagViewItem } from '@/core/utils/googleTag'
 
 const Product = ({ product }) => {
   const auth = useAuth()
@@ -26,6 +28,10 @@ const Product = ({ product }) => {
     wishlist.refetch()
   }
 
+  useEffect(() => {
+    gtagViewItem(product.variants)
+  }, [product])
+
   return (
     <>
       <ProductMobile product={product} wishlist={wishlist} toggleWishlist={toggleWishlist} />
-- 
cgit v1.2.3


From bbc333053b2cb963f8a16cecb4d7f15a0111daf2 Mon Sep 17 00:00:00 2001
From: "HATEC\\SPVDEV001" <tri.susilo@altama.co.id>
Date: Thu, 22 Jun 2023 11:02:53 +0700
Subject: page variant

---
 src/lib/product/components/Product/Product.jsx | 39 ++++++++++++++++++++------
 1 file changed, 30 insertions(+), 9 deletions(-)

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

diff --git a/src/lib/product/components/Product/Product.jsx b/src/lib/product/components/Product/Product.jsx
index 351c07c1..0547c36e 100644
--- a/src/lib/product/components/Product/Product.jsx
+++ b/src/lib/product/components/Product/Product.jsx
@@ -7,8 +7,10 @@ import ProductMobile from './ProductMobile'
 import { useRouter } from 'next/router'
 import { useEffect } from 'react'
 import { gtagViewItem } from '@/core/utils/googleTag'
+import ProductDesktopVariant from './ProductDesktopVariant'
+import ProductMobileVariant from './ProductMobileVariant'
 
-const Product = ({ product }) => {
+const Product = ({ product, isVariant = false }) => {
   const auth = useAuth()
   const router = useRouter()
   const { wishlist } = useWishlist({ productId: product?.id })
@@ -29,15 +31,34 @@ const Product = ({ product }) => {
   }
 
   useEffect(() => {
-    gtagViewItem(product.variants)
-  }, [product])
+    if (isVariant == false) {
+      gtagViewItem(product.variants)
+    }
+  }, [product, isVariant])
 
-  return (
-    <>
-      <ProductMobile product={product} wishlist={wishlist} toggleWishlist={toggleWishlist} />
-      <ProductDesktop product={product} wishlist={wishlist} toggleWishlist={toggleWishlist} />
-    </>
-  )
+  if (isVariant == true) {
+    return (
+      <>
+        <ProductDesktopVariant
+          product={product}
+          wishlist={wishlist}
+          toggleWishlist={toggleWishlist}
+        />
+        <ProductMobileVariant
+          product={product}
+          wishlist={wishlist}
+          toggleWishlist={toggleWishlist}
+        />
+      </>
+    )
+  } else {
+    return (
+      <>
+        <ProductMobile product={product} wishlist={wishlist} toggleWishlist={toggleWishlist} />
+        <ProductDesktop product={product} wishlist={wishlist} toggleWishlist={toggleWishlist} />
+      </>
+    )
+  }
 }
 
 export default Product
-- 
cgit v1.2.3

