From 2ce7d2605e3c20963589a19abd5ae3e9f6aae6fe Mon Sep 17 00:00:00 2001
From: it-fixcomart <it@fixcomart.co.id>
Date: Thu, 23 Jan 2025 09:28:23 +0700
Subject: <iman> set selected varian ke yang is_in_bu = true

---
 src/lib/product/components/Product/ProductMobile.jsx | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

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

diff --git a/src/lib/product/components/Product/ProductMobile.jsx b/src/lib/product/components/Product/ProductMobile.jsx
index 4cfd3755..16182271 100644
--- a/src/lib/product/components/Product/ProductMobile.jsx
+++ b/src/lib/product/components/Product/ProductMobile.jsx
@@ -95,7 +95,11 @@ const ProductMobile = ({ product, wishlist, toggleWishlist }) => {
 
   useEffect(() => {
     if (!selectedVariant && variantOptions.length == 1) {
-      setSelectedVariant(variantOptions[0]);
+      const selectedVariant =
+        variantOptions?.find((variant) => variant.is_in_bu) ||
+        variantOptions?.[0];
+      setSelectedVariant(selectedVariant);
+      // setSelectedVariant(variantOptions[0]);
     }
   }, [selectedVariant, variantOptions]);
 
-- 
cgit v1.2.3

