diff options
| author | FIN-IT_AndriFP <andrifebriyadiputra@gmail.com> | 2026-01-05 10:41:39 +0700 |
|---|---|---|
| committer | FIN-IT_AndriFP <andrifebriyadiputra@gmail.com> | 2026-01-05 10:41:39 +0700 |
| commit | fd50180ac301916c6feb5e93598f3fc59ecb78a8 (patch) | |
| tree | 3deec1aaa8952d43882e262d9ed3d35377ec7967 /src-migrate/modules | |
| parent | ddc308aa4e5da482763f97e16ab92fe777e8dfeb (diff) | |
(andri) get desc variant product from magento
Diffstat (limited to 'src-migrate/modules')
| -rw-r--r-- | src-migrate/modules/product-detail/components/ProductDetail.tsx | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src-migrate/modules/product-detail/components/ProductDetail.tsx b/src-migrate/modules/product-detail/components/ProductDetail.tsx index 82b99697..4cc082d8 100644 --- a/src-migrate/modules/product-detail/components/ProductDetail.tsx +++ b/src-migrate/modules/product-detail/components/ProductDetail.tsx @@ -71,6 +71,7 @@ const ProductDetail = ({ product }: Props) => { const [specsMatrix, setSpecsMatrix] = useState<any[]>([]); const [upsellIds, setUpsellIds] = useState<number[]>([]); const [relatedIds, setRelatedIds] = useState<number[]>([]); + const [descriptionMap, setDescriptionMap] = useState<Record<string, string>>({}); const [loadingSpecs, setLoadingSpecs] = useState(false); @@ -174,6 +175,10 @@ const ProductDetail = ({ product }: Props) => { setSpecsMatrix([]); } + if (data.descriptions){ + setDescriptionMap(data.descriptions); + } + // 2. Upsell & Related if (data.upsell_ids && Array.isArray(data.upsell_ids)) setUpsellIds(data.upsell_ids); else setUpsellIds([]); @@ -319,6 +324,10 @@ const ProductDetail = ({ product }: Props) => { setMainImage(allImages[i] || ''); }; + const activeMagentoDesc = selectedVariant?.id ? descriptionMap[String(selectedVariant.id)] : ''; + const finalDescription = activeMagentoDesc || product.description || 'Deskripsi produk tidak tersedia.'; + const cleanDescription = finalDescription === '<p><br></p>' ? 'Deskripsi produk tidak tersedia.' : finalDescription; + return ( <> <div className='relative'> @@ -455,7 +464,7 @@ const ProductDetail = ({ product }: Props) => { {/* DESKRIPSI */} <TabPanel px={0} py={6}> <div className='overflow-x-auto text-sm text-gray-700'> - <div className={style['description']} dangerouslySetInnerHTML={{ __html: !product.description || product.description === '<p><br></p>' ? '<p>Lorem ipsum dolor sit amet.</p>' : product.description, }} /> + <div className={style['description']} dangerouslySetInnerHTML={{ __html: cleanDescription }} /> </div> </TabPanel> |
