From 1850e105ce6578465a015e395fa4c38544afdafe Mon Sep 17 00:00:00 2001 From: "HATEC\\SPVDEV001" Date: Mon, 29 Apr 2024 10:17:54 +0700 Subject: CR - Price Product detail = variant yg ada harganya --- src-migrate/modules/product-detail/components/PriceAction.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src-migrate/modules') diff --git a/src-migrate/modules/product-detail/components/PriceAction.tsx b/src-migrate/modules/product-detail/components/PriceAction.tsx index f25847a5..ad04de43 100644 --- a/src-migrate/modules/product-detail/components/PriceAction.tsx +++ b/src-migrate/modules/product-detail/components/PriceAction.tsx @@ -23,6 +23,16 @@ const PriceAction = ({ product }: Props) => { useEffect(() => { setActive(product.variants[0]) + if(product.variants.length > 2 && product.variants[0].price.price === 0){ + const variants = product.variants + for (let i = 0; i < variants.length; i++) { + if(variants[i].price.price > 0){ + setActive(variants[i]) + break; + } + } + } + }, [product, setActive]); return ( -- cgit v1.2.3