From 4e634a9d3556e94c7ce0729ef9f15b73495b2e28 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Wed, 15 Mar 2023 14:52:16 +0700
Subject: product detail desktop

---
 src/lib/product/components/ProductMobile.jsx | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

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

diff --git a/src/lib/product/components/ProductMobile.jsx b/src/lib/product/components/ProductMobile.jsx
index 790fcd57..07da876e 100644
--- a/src/lib/product/components/ProductMobile.jsx
+++ b/src/lib/product/components/ProductMobile.jsx
@@ -17,7 +17,7 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => {
 
   const [quantity, setQuantity] = useState('1')
   const [selectedVariant, setSelectedVariant] = useState(null)
-  const [informationTab, setInformationTab] = useState(null)
+  const [informationTab, setInformationTab] = useState(informationTabOptions[0].value)
 
   const [activeVariant, setActiveVariant] = useState({
     id: product.id,
@@ -58,12 +58,6 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => {
     }
   }, [selectedVariant, product])
 
-  useEffect(() => {
-    if (!informationTab) {
-      setInformationTab(informationTabOptions[0].value)
-    }
-  }, [informationTab])
-
   const validAction = () => {
     let isValid = true
     if (!selectedVariant) {
@@ -91,6 +85,12 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => {
     router.push(`/shop/checkout?productId=${activeVariant.id}&quantity=${quantity}`)
   }
 
+  const productSimilarQuery = [
+    product?.name.replace(/[()/"&]/g, ''),
+    `fq=-product_id:${product.id}`,
+    `fq=-manufacture_id:${product.manufacture?.id || 0}`
+  ].join('&')
+
   return (
     <MobileView>
       <Image
@@ -242,7 +242,7 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => {
       <div className='p-4'>
         <h2 className='font-semibold mb-4'>Kamu Mungkin Juga Suka</h2>
         <LazyLoad>
-          <ProductSimilar query={product?.name.split(' ').slice(1, 3).join(' ')} />
+          <ProductSimilar query={productSimilarQuery} />
         </LazyLoad>
       </div>
     </MobileView>
@@ -252,7 +252,7 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => {
 const informationTabOptions = [
   { value: 'specification', label: 'Spesifikasi' },
   { value: 'description', label: 'Deskripsi' },
-  { value: 'important', label: 'Info Penting' }
+  { value: 'information', label: 'Info Penting' }
 ]
 
 const TabButton = ({ children, active, ...props }) => {
-- 
cgit v1.2.3

