diff options
| author | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2024-04-29 10:17:54 +0700 |
|---|---|---|
| committer | HATEC\SPVDEV001 <tri.susilo@altama.co.id> | 2024-04-29 10:17:54 +0700 |
| commit | 1850e105ce6578465a015e395fa4c38544afdafe (patch) | |
| tree | 31f8fc2af29eab564c1d0dc8dfa33e9f2c52c55b | |
| parent | 2f5d387f2235d8293e70d1807731861607357d4d (diff) | |
CR - Price Product detail = variant yg ada harganya
| -rw-r--r-- | src-migrate/modules/product-detail/components/PriceAction.tsx | 10 |
1 files changed, 10 insertions, 0 deletions
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 ( |
