summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorit-fixcomart <it@fixcomart.co.id>2025-01-23 09:28:23 +0700
committerit-fixcomart <it@fixcomart.co.id>2025-01-23 09:28:23 +0700
commit2ce7d2605e3c20963589a19abd5ae3e9f6aae6fe (patch)
tree0059dfc638f07baed1a1f05ec39ab3bd92b059eb
parent6d9c1067b6e857eb95f12864cc88117350ae6cfb (diff)
<iman> set selected varian ke yang is_in_bu = true
-rw-r--r--src-migrate/modules/product-detail/components/ProductDetail.tsx6
-rw-r--r--src/lib/product/components/Product/ProductMobile.jsx6
2 files changed, 10 insertions, 2 deletions
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 (
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]);