From 1e4aa525ec325a23d7617133c5532ad874fe309f Mon Sep 17 00:00:00 2001 From: FIN-IT_AndriFP Date: Thu, 8 Jan 2026 10:08:55 +0700 Subject: (andri) fix table spec desktop --- .../product-detail/components/ProductDetail.tsx | 204 ++++++++++++--------- 1 file changed, 116 insertions(+), 88 deletions(-) diff --git a/src-migrate/modules/product-detail/components/ProductDetail.tsx b/src-migrate/modules/product-detail/components/ProductDetail.tsx index 4cc082d8..3a4d9c7e 100644 --- a/src-migrate/modules/product-detail/components/ProductDetail.tsx +++ b/src-migrate/modules/product-detail/components/ProductDetail.tsx @@ -468,119 +468,147 @@ const ProductDetail = ({ product }: Props) => { - {/* SPESIFIKASI (LOGIKA GROUPING + RATA TENGAH + STICKY FIRST COLUMN) */} + {/* SPESIFIKASI */} - + {loadingSpecs ? (
) : specsMatrix.length > 0 ? ( (() => { - const isSingleVariant = product.variants.length === 1; - const globalAlign = isSingleVariant ? "left" : "center"; + const topHeaders: any[] = []; + const subHeaders: any[] = []; + const flatSpecs: any[] = []; + + specsMatrix.forEach(row => { + if (row.type === 'group') { + topHeaders.push({ + label: row.label, + type: 'group', + colSpan: row.children.length, + rowSpan: 1 + }); + row.children.forEach((child: any) => { + subHeaders.push(child); + flatSpecs.push(child); + }); + } else { + topHeaders.push({ + label: row.label, + type: 'single', + colSpan: 1, + rowSpan: 2 + }); + flatSpecs.push(row); + } + }); return ( - + - {/* 1. STICKY HEADER KOLOM PERTAMA */} + + {topHeaders.map((th, idx) => ( + - {product.variants.map(v => ( - + ))} + + + {subHeaders.map((sub, idx) => ( + ))} + - {specsMatrix.map((row, i) => { - - // CASE 1: GROUPING - if (row.type === 'group') { - return ( - - {/* 2. STICKY BODY KOLOM PERTAMA (GROUP) */} + {product.variants.map((v, vIdx) => ( + + + + {flatSpecs.map((spec, sIdx) => { + const rawValue = spec.values[v.id] || '-'; + return ( - - {product.variants.map(v => ( - - ))} - - ); - } - - // CASE 2: SINGLE ITEM - return ( - - {/* 3. STICKY BODY KOLOM PERTAMA (SINGLE) */} - - - {product.variants.map(v => { - const rawValue = row.values[v.id] || '-'; - return ( - - ); - })} - - ); - })} + ); + })} + + ))}
+ Tipe / Variant + - Spesifikasi - - {isSingleVariant ? 'Detail' : (v.attributes && v.attributes.length > 0 ? v.attributes.join(' - ') : v.code)} + > + {th.label} +
+ {sub.label}
+ {v.attributes && v.attributes.length > 0 ? v.attributes.join(' - ') : v.code} + - {row.label} + {renderSpecValue(rawValue)} -
-
- {row.children.map((child: any, idx: number) => { - const rawVal = child.values[v.id]; - if (!rawVal || rawVal === '-') return null; - - return ( -
- - {child.label}: - - {renderSpecValue(rawVal)} -
- ); - })} -
-
-
- {row.label} - - {renderSpecValue(rawValue)} -
); -- cgit v1.2.3