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-migrate/modules/product-detail/components/ProductDetail.tsx | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

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

diff --git a/src-migrate/modules/product-detail/components/ProductDetail.tsx b/src-migrate/modules/product-detail/components/ProductDetail.tsx
index b036cc2d..f23aa9dc 100644
--- a/src-migrate/modules/product-detail/components/ProductDetail.tsx
+++ b/src-migrate/modules/product-detail/components/ProductDetail.tsx
@@ -66,7 +66,11 @@ const ProductDetail = ({ product }: Props) => {
     if (typeof auth === 'object') {
       setIsApproval(auth?.feature?.soApproval);
     }
-    setSelectedVariant(product?.variants[0])
+    const selectedVariant =
+      product?.variants?.find((variant) => variant.is_in_bu) ||
+      product?.variants?.[0];
+    setSelectedVariant(selectedVariant);
+    // setSelectedVariant(product?.variants[0])
   }, []);
 
   return (
-- 
cgit v1.2.3

