diff options
Diffstat (limited to 'src-migrate/modules/product-detail/components/ProductDetail.tsx')
| -rw-r--r-- | src-migrate/modules/product-detail/components/ProductDetail.tsx | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src-migrate/modules/product-detail/components/ProductDetail.tsx b/src-migrate/modules/product-detail/components/ProductDetail.tsx index 03089afa..b6db3f69 100644 --- a/src-migrate/modules/product-detail/components/ProductDetail.tsx +++ b/src-migrate/modules/product-detail/components/ProductDetail.tsx @@ -156,9 +156,19 @@ const ProductDetail = ({ product }: Props) => { setAskAdminUrl(createdAskUrl); }, [router.asPath, product.manufacture.name, product.name, setAskAdminUrl]); - // ========================================================================= + // useEffect(() => { + // if (!product?.variants?.length) return; + + // setIsApproval(auth?.feature?.soApproval); + + // setSelectedVariant((prev: any) => { + // if (prev) return prev; + + // return product.variants[0]; + // }); + // }, [product?.id]); + // 1. LOGIC INISIALISASI VARIANT - // ========================================================================= useEffect(() => { if (typeof auth === 'object') { setIsApproval(auth?.feature?.soApproval); @@ -175,9 +185,8 @@ const ProductDetail = ({ product }: Props) => { }, [product, auth]); - // ========================================================================= + // 2. LOGIC FETCH DATA - // ========================================================================= useEffect(() => { const fetchMagentoData = async () => { const allVariantIds = product.variants.map(v => v.id); @@ -247,9 +256,7 @@ const ProductDetail = ({ product }: Props) => { }, [product.id]); - // ========================================================================= // HELPER 1: GROUPING DATA BY LABEL - // ========================================================================= const processMatrixData = (rawMatrix: any[]) => { const groups: any = {}; const result: any[] = []; @@ -283,9 +290,7 @@ const ProductDetail = ({ product }: Props) => { }; - // ========================================================================= // HELPER 2: RENDER SPEC VALUE - // ========================================================================= const renderSpecValue = (val: any) => { if (!val) return '-'; const strVal = String(val).trim(); |
