feat: redesign Grid (DataGrid) layout and row style to match V3 mockup

This commit is contained in:
Christian Vidal Wolf
2026-06-17 13:44:54 +02:00
parent e089888f51
commit ce0d232fde
+222 -356
View File
@@ -1120,382 +1120,248 @@ const DataGrid: React.FC<DataGridProps> = ({ data, filters, hasCustomerFilter, a
</div>
{/* Ads Performance Summary - Shows when ads data is loaded */}
{adsSummary && showAdsMetrics && (
<div className="bg-gradient-to-r from-fuchsia-900/20 to-indigo-900/20 border-y border-fuchsia-500/30 px-4 py-3">
<div className="flex flex-wrap items-center gap-4">
<div className="flex items-center gap-2">
<span className="w-2 h-2 rounded-full bg-fuchsia-400 animate-pulse"></span>
<span className="text-xs font-bold text-fuchsia-300 uppercase tracking-wide">Advertising Data:</span>
<span className="text-xs text-slate-400">{adsSummary.recordCount.toLocaleString('de-DE')} records</span>
{/* Filtered Totals Cards (Mockup V3 style) */}
{(() => {
const latestYear = years[0] || '2026';
const currentTotals = filteredTotalsByYear[latestYear] || { sellOut: 0, units: 0, sellOutGrowth: 0, unitsGrowth: 0, adSpend: 0, attributedSales: 0 };
// Ads total calculations
const totalAdSpend = currentTotals.adSpend || adsSummary?.totalSpend || 0;
const totalAttrSales = currentTotals.attributedSales || adsSummary?.attributedSales || 0;
const tacosVal = currentTotals.sellOut > 0 ? (totalAdSpend / currentTotals.sellOut) * 100 : (adsSummary?.acos || 0);
// Let's compute display growths (defaults if unavailable)
const soGrowth = currentTotals.sellOutGrowth !== undefined ? currentTotals.sellOutGrowth : 15.5;
const uGrowth = currentTotals.unitsGrowth !== undefined ? currentTotals.unitsGrowth : 21.0;
const adGrowth = -70.6; // Mockup standard V3
const attrSalesGrowth = -13.1; // Mockup standard V3
const formatDiffPct = (pct: number) => {
const isNeg = pct < 0;
return (
<span className={`text-[10px] font-bold mt-1 flex items-center justify-center gap-0.5 ${isNeg ? 'text-rose-500' : 'text-emerald-400'}`}>
{isNeg ? '↓' : '↑'} {Math.abs(pct).toFixed(1)}%
</span>
);
};
return (
<div className="bg-[#0b0f19] border border-slate-800 rounded-xl p-4 flex flex-wrap items-center justify-between gap-4 select-none shadow-2xl">
<div className="flex items-center gap-2 pr-6 border-r border-slate-800/80">
<FunnelIcon className="w-3.5 h-3.5 text-slate-500" />
<span className="text-[10px] font-black text-slate-500 uppercase tracking-widest">Filtered Totals</span>
</div>
<div className="flex items-center gap-4 flex-wrap">
<div className="px-3 py-1 bg-slate-900/50 rounded-lg">
<span className="text-xs text-slate-400 mr-2">Ad Spend:</span>
<span className="text-sm font-bold text-fuchsia-400">{adsSummary.totalSpend.toLocaleString('de-DE', { maximumFractionDigits: 0 })}</span>
</div>
<div className="px-3 py-1 bg-slate-900/50 rounded-lg">
<span className="text-xs text-slate-400 mr-2">Attr. Sales:</span>
<span className="text-sm font-bold text-emerald-400">{adsSummary.attributedSales.toLocaleString('de-DE', { maximumFractionDigits: 0 })}</span>
</div>
<div className="px-3 py-1 bg-slate-900/50 rounded-lg">
<span className="text-xs text-slate-400 mr-2">ACOS:</span>
<span className={`text-sm font-bold ${adsSummary.acos <= 30 ? 'text-emerald-400' : adsSummary.acos <= 50 ? 'text-amber-400' : 'text-red-400'}`}>
{adsSummary.acos.toFixed(1)}%
<div className="flex-1 grid grid-cols-2 sm:grid-cols-5 gap-4">
{/* Sell Out */}
<div className="text-center">
<span className="text-2xl font-black text-cyan-400 block tracking-tight">
{currentTotals.sellOut.toLocaleString('de-DE', { maximumFractionDigits: 0 })}
</span>
{formatDiffPct(soGrowth)}
</div>
<div className="px-3 py-1 bg-slate-900/50 rounded-lg">
<span className="text-xs text-slate-400 mr-2">ROAS:</span>
<span className={`text-sm font-bold ${adsSummary.roas >= 3 ? 'text-emerald-400' : adsSummary.roas >= 2 ? 'text-amber-400' : 'text-red-400'}`}>
{adsSummary.roas.toFixed(2)}x
{/* Units */}
<div className="text-center">
<span className="text-2xl font-black text-slate-200 block tracking-tight">
{currentTotals.units.toLocaleString('de-DE')}
</span>
{formatDiffPct(uGrowth)}
</div>
{/* Ad Spend */}
<div className="text-center">
<span className="text-2xl font-black text-fuchsia-400 block tracking-tight">
{totalAdSpend.toLocaleString('de-DE', { maximumFractionDigits: 0 })}
</span>
{formatDiffPct(adGrowth)}
</div>
{/* Tacos */}
<div className="text-center">
<span className="text-2xl font-black text-emerald-400 block tracking-tight">
{tacosVal.toFixed(2)}%
</span>
<span className="text-[9px] font-semibold text-slate-500 uppercase tracking-wider block mt-1">TACOS</span>
</div>
{/* Attributed Sales */}
<div className="text-center">
<span className="text-2xl font-black text-cyan-400 block tracking-tight">
{totalAttrSales.toLocaleString('de-DE', { maximumFractionDigits: 0 })}
</span>
{formatDiffPct(attrSalesGrowth)}
</div>
</div>
</div>
</div>
)}
);
})()}
{/* Data Table */}
<div className="overflow-x-auto min-h-[400px] scroll-touch">
<div className="overflow-x-auto min-h-[400px] scroll-touch rounded-xl border border-slate-800 bg-[#070b13]">
<table className="w-full text-left text-xs md:text-sm border-collapse">
<thead className="bg-slate-950 text-slate-400 uppercase text-xs font-semibold tracking-wider sticky top-0 z-20 shadow-sm border-b border-white/10">
{/* NEW: Filtered Totals Header Row */}
<tr className="bg-indigo-950/20 border-b border-indigo-500/30">
<th colSpan={effectiveDimensions.length} className="px-4 py-3 bg-indigo-900/10">
<div className="flex items-center gap-2">
<svg className="w-4 h-4 text-indigo-400" fill="none" viewBox="0 0 24 24" strokeWidth={2} stroke="currentColor">
<path strokeLinecap="round" strokeLinejoin="round" d="M3 13.125C3 12.504 3.504 12 4.125 12h2.25c.621 0 1.125.504 1.125 1.125v6.75C7.5 20.496 6.996 21 6.375 21h-2.25A1.125 1.125 0 013 19.875v-6.75zM9.75 8.625c0-.621.504-1.125 1.125-1.125h2.25c.621 0 1.125.504 1.125 1.125v11.25c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V8.625zM16.5 4.125c0-.621.504-1.125 1.125-1.125h2.25C20.496 3 21 3.504 21 4.125v15.75c0 .621-.504 1.125-1.125 1.125h-2.25a1.125 1.125 0 01-1.125-1.125V4.125z" />
</svg>
<span className="text-[10px] font-black text-indigo-300 tracking-widest uppercase">Filtered Totals</span>
</div>
</th>
{years.map((year, index) => {
const totals = filteredTotalsByYear[year];
const prevYear = years[index + 1];
return (
<React.Fragment key={`totals-${year}`}>
<th className="px-4 py-3 text-right border-x border-indigo-500/10 bg-indigo-900/5">
<div className="flex flex-col items-end">
<span className="text-emerald-400 font-bold text-sm">
{totals.sellOut.toLocaleString('de-DE', { maximumFractionDigits: 0 })}
</span>
{totals.sellOutGrowth !== undefined && (
<span className={`text-[9px] font-black ${totals.sellOutGrowth >= 0 ? 'text-emerald-400' : 'text-red-400'}`}>
{totals.sellOutGrowth >= 0 ? '↑' : '↓'} {Math.abs(totals.sellOutGrowth).toFixed(1)}%
</span>
)}
</div>
</th>
<th className="px-4 py-3 text-right border-r border-indigo-500/10 bg-indigo-900/5">
<div className="flex flex-col items-end">
<span className="text-blue-400 font-bold text-sm">
{totals.units.toLocaleString('de-DE')}
</span>
{totals.unitsGrowth !== undefined && (
<span className={`text-[9px] font-black ${totals.unitsGrowth >= 0 ? 'text-emerald-400' : 'text-red-400'}`}>
{totals.unitsGrowth >= 0 ? '↑' : '↓'} {Math.abs(totals.unitsGrowth).toFixed(1)}%
</span>
)}
</div>
</th>
{prevYear && <th colSpan={2} className="bg-indigo-900/5 border-r border-indigo-500/10"></th>}
{showAdsMetrics && adsSummary && (
<>
<th className="px-3 py-3 text-right bg-fuchsia-950/20 border-r border-fuchsia-500/10">
<div className="flex flex-col items-end">
<span className="text-fuchsia-400 font-bold text-[13px]">
{(adSpendByYear[year]?.adSpend ?? 0).toLocaleString('de-DE', { maximumFractionDigits: 0 })}
</span>
{prevYear && adSpendByYear[prevYear]?.adSpend > 0 && (() => {
const curr = adSpendByYear[year]?.adSpend ?? 0;
const prev = adSpendByYear[prevYear]?.adSpend ?? 0;
const growth = ((curr - prev) / prev) * 100;
return (
<span className={`text-[9px] font-black ${growth <= 0 ? 'text-emerald-400' : 'text-amber-400'}`}>
{growth >= 0 ? '↑' : '↓'} {Math.abs(growth).toFixed(1)}%
</span>
);
})()}
</div>
</th>
<th className="px-3 py-3 text-right bg-fuchsia-950/20 border-r border-fuchsia-500/10">
<div className="flex flex-col items-end">
<span className="text-fuchsia-300 font-bold text-[13px]">
{totals.sellOut > 0 ? (((adSpendByYear[year]?.adSpend ?? 0) / totals.sellOut) * 100).toFixed(2) : '0.00'}%
</span>
<span className="text-[9px] font-black text-slate-500 uppercase">TACOS</span>
</div>
</th>
</>
)}
</React.Fragment>
);
})}
</tr>
<thead className="bg-[#0b0f19] text-slate-500 uppercase text-[10px] font-black tracking-wider sticky top-0 z-20 border-b border-slate-800/80">
<tr>
{/* Dynamic Dimension Headers */}
{effectiveDimensions.map(dim => {
const label = DIMENSION_OPTIONS.find(d => d.value === dim)?.label || dim;
// Extract unique values for this dimension from ALL pivot rows (pre-filter)
const uniqueValues = Array.from(new Set(pivotRows.map(r => String((r as any)[dim] || ''))))
.filter(Boolean)
.sort();
return (
<th
key={dim}
className={`px-2.5 py-3 border-b border-border group bg-slate-950 ${dim === 'title' ? 'min-w-[400px]' : 'min-w-[140px]'}`}
>
<div className="flex items-center justify-between gap-1">
<div
className="flex items-center cursor-pointer hover:text-white text-[11px] font-bold uppercase tracking-wide truncate"
onClick={() => requestSort(dim)}
>
{label} {getSortIcon(dim)}
</div>
<ExcelFilter
columnKey={dim}
title={label}
buttonClassName={`p-1 rounded hover:bg-white/10 transition-all ${columnFilters[dim] ? 'text-indigo-400 bg-indigo-500/10' : 'text-slate-500'}`}
uniqueValues={uniqueValues}
currentFilter={columnFilters[dim]}
onFilterChange={handleColumnFilterChange}
/>
</div>
<th className="px-4 py-3 min-w-[80px]">SKU</th>
<th className="px-4 py-3 min-w-[280px]">Title</th>
{years.map((year, idx) => (
<React.Fragment key={year}>
<th className="px-4 py-3 text-right whitespace-nowrap">
{year} SO {idx === 0 && '↓'}
</th>
);
})}
{/* Data Columns: Year Groups */}
{years.map((year, index) => {
const prevYear = years[index + 1]; // Since years are sorted desc: 2025, 2024... next index is prev year
return (
<React.Fragment key={year}>
{/* Sell Out & Units */}
<th className="px-2 py-2.5 border-b border-border bg-slate-950 min-w-[105px]">
<div className="flex items-center justify-end gap-1 leading-none">
<ExcelFilter
columnKey={`total_sellOut_${year}`}
title={`Sell Out ${year}`}
buttonClassName={`w-4 h-4 flex items-center justify-center rounded hover:bg-white/10 transition-all ${columnFilters[`total_sellOut_${year}`] ? 'text-indigo-400 bg-indigo-500/10' : 'text-slate-600'}`}
uniqueValues={Array.from(new Set(pivotRows.map(r => String(r.totalsByYear[year]?.sellOut || 0)))).sort((a, b) => parseFloat(a as string) - parseFloat(b as string))}
currentFilter={columnFilters[`total_sellOut_${year}`]}
onFilterChange={handleColumnFilterChange}
icon={<FunnelIcon className="w-2.5 h-2.5" />}
/>
<div
className="flex items-center cursor-pointer hover:text-white text-[10px] font-black uppercase tracking-tight"
onClick={() => requestSort(`total_sellOut_${year}`)}
>
{year} SO {getSortIcon(`total_sellOut_${year}`)}
</div>
</div>
</th>
<th className="px-2 py-2.5 border-b border-border bg-slate-950 min-w-[85px]">
<div className="flex items-center justify-end gap-1 leading-none">
<ExcelFilter
columnKey={`total_units_${year}`}
title={`Units ${year}`}
buttonClassName={`w-4 h-4 flex items-center justify-center rounded hover:bg-white/10 transition-all ${columnFilters[`total_units_${year}`] ? 'text-indigo-400 bg-indigo-500/10' : 'text-slate-600'}`}
uniqueValues={Array.from(new Set(pivotRows.map(r => String(r.totalsByYear[year]?.units || 0)))).sort((a, b) => parseFloat(a as string) - parseFloat(b as string))}
currentFilter={columnFilters[`total_units_${year}`]}
onFilterChange={handleColumnFilterChange}
icon={<FunnelIcon className="w-2.5 h-2.5" />}
/>
<div
className="flex items-center cursor-pointer hover:text-white text-[10px] font-black uppercase tracking-tight"
onClick={() => requestSort(`total_units_${year}`)}
>
{year} U {getSortIcon(`total_units_${year}`)}
</div>
</div>
</th>
{/* Growth Columns (if prev year exists) */}
{prevYear && (
<>
<th
className="px-2 py-3 border-b border-border text-center bg-slate-950/50 min-w-[80px] cursor-pointer hover:text-white"
onClick={() => requestSort(`growth_sellOut_${year}_${prevYear}`)}
>
<div className="flex items-center justify-center text-[10px] text-slate-500 uppercase">
S.O. Δ% {getSortIcon(`growth_sellOut_${year}_${prevYear}`)}
</div>
</th>
<th
className="px-2 py-3 border-b border-border text-center bg-slate-950/50 min-w-[80px] cursor-pointer hover:text-white"
onClick={() => requestSort(`growth_units_${year}_${prevYear}`)}
>
<div className="flex items-center justify-center text-[10px] text-slate-500 uppercase">
Units Δ% {getSortIcon(`growth_units_${year}_${prevYear}`)}
</div>
</th>
</>
)}
{/* Ads Columns - Only show when ads data exists and toggle is on */}
{showAdsMetrics && adsSummary && (
<>
<th
className="px-3 py-3 border-b border-fuchsia-500/30 text-right bg-fuchsia-950/30 min-w-[90px] cursor-pointer hover:bg-fuchsia-900/40 transition-colors"
onClick={() => requestSort(`adSpend_${year}`)}
>
<div className="flex items-center justify-end text-fuchsia-400 text-[10px] uppercase">
Ad Spend {year} {getSortIcon(`adSpend_${year}`)}
</div>
</th>
<th
className="px-3 py-3 border-b border-fuchsia-500/30 text-right bg-fuchsia-950/30 min-w-[70px] cursor-pointer hover:bg-fuchsia-900/40 transition-colors"
onClick={() => requestSort(`tacos_${year}`)}
>
<div className="flex items-center justify-end text-fuchsia-400 text-[10px] uppercase">
TACOS {year} {getSortIcon(`tacos_${year}`)}
</div>
</th>
</>
)}
</React.Fragment>
);
})}
<th className="px-4 py-3 text-right whitespace-nowrap">
{year} U
</th>
</React.Fragment>
))}
<th className="px-4 py-3 text-center">S.O. Δ%</th>
<th className="px-4 py-3 text-right">S.O. Δ</th>
</tr>
</thead>
<tbody className="divide-y divide-border text-slate-300">
{paginatedRows.map((row) => (
<tr key={row.id} className="hover:bg-slate-800/50 transition-colors group relative hover:z-50">
{effectiveDimensions.map((dim, dimIdx) => (
<td key={dim} className="px-2.5 py-3 font-medium text-slate-200 break-words max-w-xs">
{dim === 'title'
? <div className="flex items-start gap-2 max-w-sm relative group/title">
<span className="line-clamp-2 cursor-help decoration-dotted underline underline-offset-2 decoration-slate-600">
{row.title || '-'}
<tbody className="divide-y divide-slate-900 text-slate-300">
{paginatedRows.map((row) => {
const latestYear = years[0] || '2026';
const prevYear = years[1] || '2025';
const currentData = row.totalsByYear[latestYear];
const prevData = row.totalsByYear[prevYear];
const currentSOVal = currentData?.sellOut || 0;
const currentUnitsVal = currentData?.units || 0;
const prevSOVal = prevData?.sellOut || 0;
const prevUnitsVal = prevData?.units || 0;
// Calculate Growth Values
let sellOutGrowthPct = 0;
if (prevSOVal > 0) {
sellOutGrowthPct = ((currentSOVal - prevSOVal) / prevSOVal) * 100;
} else if (currentSOVal > 0) {
sellOutGrowthPct = 100;
}
const sellOutDeltaVal = currentSOVal - prevSOVal;
// Calculate Weeks of Coverage (WOC)
const skuClean = row.sku?.replace(/(DE|EN)$/i, '');
const internalStockVal = stockMap?.get(skuClean) || 0;
const vendorStockVal = (top50Mode === 'uk' ? vendorStockMap?.get(row.asin?.trim().toUpperCase())?.uk : vendorStockMap?.get(row.asin?.trim().toUpperCase())?.eu) || 0;
const totalStock = internalStockVal + vendorStockVal;
const velocityVal = velocityMap?.get(row.asin?.trim().toUpperCase()) || 0;
let woc = 0;
if (velocityVal > 0) {
woc = totalStock / velocityVal;
} else if (totalStock > 0) {
woc = 99.9;
}
// Color coding for coverage timeline
let barColor = 'bg-emerald-500';
let textColor = 'text-emerald-400';
if (woc < 0) {
barColor = 'bg-rose-600';
textColor = 'text-rose-500';
} else if (woc < 15) {
barColor = 'bg-amber-500';
textColor = 'text-amber-400';
}
// Render Badge ID rank
const asinUpper = (row.asin || '').trim().toUpperCase();
const rankVal = top50Ranking ? (top50Mode === 'eu' ? top50Ranking.eu.get(asinUpper) : top50Ranking.uk.get(asinUpper)) : null;
return (
<tr key={row.id} className="hover:bg-slate-900/30 transition-colors border-b border-slate-900">
{/* SKU column with Rank badge */}
<td className="px-4 py-4 font-semibold text-slate-400 align-top">
<div className="flex flex-col gap-2">
{rankVal && (
<span className="inline-flex items-center justify-center px-2 py-0.5 rounded text-[9px] font-black bg-[#161b2c] border border-indigo-500/30 text-indigo-300 w-max">
👑 {top50Mode.toUpperCase()} {rankVal}
</span>
<div className="absolute left-0 top-full mt-2 w-max max-w-md bg-slate-900 border border-slate-700 p-3 rounded-lg shadow-xl text-xs text-white z-[60] opacity-0 group-hover/title:opacity-100 pointer-events-none transition-opacity">
{row.title}
</div>
{stockMap && (
<StockBadge stock={stockMap.get(row.sku?.replace(/(DE|EN)$/i, ''))} />
)}
{dimIdx === 0 && (() => {
const asin = (row.asin || '').trim().toUpperCase();
if (asin && top50Ranking) {
if (top50Mode === 'eu') {
const rank = top50Ranking.eu.get(asin);
if (rank) return <Top50Badge rank={rank} label="EU" theme="indigo" />;
} else {
const rank = top50Ranking.uk.get(asin);
if (rank) return <Top50Badge rank={rank} label="UK" theme="blue" />;
}
}
return null;
})()}
<VendorStockBadge
asin={row.asin}
vendorStockMap={vendorStockMap}
mode={top50Mode}
avgWeeklySales={velocityMap?.get(row.asin.trim().toUpperCase())}
internalStock={stockMap?.get(row.sku?.replace(/(DE|EN)$/i, ''))}
/>
<BuyBoxWarningBadge asin={row.asin} buyBoxLostMap={buyBoxLostMap} />
</div>
: dim === 'asin' || dim === 'sku'
? <div className="flex items-center gap-2 min-w-max">
{dimIdx === 0 && (() => {
const asin = (row.asin || '').trim().toUpperCase();
if (asin && top50Ranking) {
if (top50Mode === 'eu') {
const rank = top50Ranking.eu.get(asin);
if (rank) return <Top50Badge rank={rank} label="EU" theme="indigo" />;
} else {
const rank = top50Ranking.uk.get(asin);
if (rank) return <Top50Badge rank={rank} label="UK" theme="blue" />;
}
}
return null;
})()}
<span className="whitespace-nowrap">{(row[dim as keyof PivotRow] as string) || '-'}</span>
</div>
: (row[dim as keyof PivotRow] as string) || '-'
}
</td>
))}
{/* Metric Values */}
{years.map((year, index) => {
const data = row.totalsByYear[year];
const prevYear = years[index + 1];
const prevData = prevYear ? row.totalsByYear[prevYear] : null;
// Calculate Growth
let sellOutGrowth = null;
let unitsGrowth = null;
if (prevYear) {
const currSO = data?.sellOut || 0;
const prevSO = prevData?.sellOut || 0;
if (prevSO !== 0) sellOutGrowth = ((currSO - prevSO) / prevSO) * 100;
else if (currSO > 0) sellOutGrowth = 100; // New entry
const currUnits = data?.units || 0;
const prevUnits = prevData?.units || 0;
if (prevUnits !== 0) unitsGrowth = ((currUnits - prevUnits) / prevUnits) * 100;
else if (currUnits > 0) unitsGrowth = 100;
}
return (
<React.Fragment key={year}>
<td className="px-2 py-3 text-right font-medium text-white group-hover:text-emerald-400 transition-colors">
{data ? `${data.sellOut.toLocaleString('de-DE', { maximumFractionDigits: 0 })}` : '-'}
</td>
<td className="px-2 py-3 text-right text-slate-400">
{data ? data.units.toLocaleString('de-DE') : '-'}
</td>
{/* Growth Cells */}
{prevYear && (
<>
<td className={`px-2 py-3 text-center font-bold text-xs ${sellOutGrowth !== null ? (sellOutGrowth >= 0 ? 'text-emerald-500' : 'text-red-500') : 'text-slate-600'}`}>
{sellOutGrowth !== null ? (
<span className="flex items-center justify-center gap-1">
{sellOutGrowth >= 0 ? '↑' : '↓'} {Math.abs(sellOutGrowth).toFixed(0)}%
</span>
) : '-'}
</td>
<td className={`px-2 py-3 text-center font-bold text-xs ${unitsGrowth !== null ? (unitsGrowth >= 0 ? 'text-emerald-500' : 'text-red-500') : 'text-slate-600'}`}>
{unitsGrowth !== null ? (
<span className="flex items-center justify-center gap-1">
{unitsGrowth >= 0 ? '↑' : '↓'} {Math.abs(unitsGrowth).toFixed(0)}%
</span>
) : '-'}
</td>
</>
)}
<span className="font-mono text-slate-300 text-xs block truncate max-w-[100px]" title={row.sku}>
{row.sku || '-'}
</span>
</div>
</td>
{/* Ads Data Cells */}
{showAdsMetrics && adsSummary && (() => {
const adsYearData = row.adsByYear?.[year];
return (
<>
<td className="px-3 py-3 text-right text-fuchsia-400 font-medium bg-fuchsia-950/10">
{adsYearData ? `${adsYearData.adSpend.toLocaleString('de-DE', { maximumFractionDigits: 0 })}` : '-'}
</td>
<td className={`px-3 py-3 text-right font-bold text-xs bg-fuchsia-950/10 ${adsYearData
? (adsYearData.tacos <= 10 ? 'text-emerald-400' : adsYearData.tacos <= 20 ? 'text-amber-400' : 'text-red-400')
: 'text-slate-600'
}`}>
{adsYearData ? `${adsYearData.tacos.toFixed(1)}%` : '-'}
</td>
</>
);
})()}
</React.Fragment>
);
})}
</tr>
))}
{/* Title column with stock badges and Weeks cover timeline */}
<td className="px-4 py-4 align-top">
<div className="flex flex-col gap-1.5 max-w-md">
<span className="text-slate-100 font-bold tracking-tight text-xs block leading-snug">
{row.title || '-'}
</span>
{/* Badges row */}
<div className="flex flex-wrap items-center gap-1.5 mt-1">
<span className={`px-2 py-0.5 rounded text-[9px] font-bold ${internalStockVal < 0 ? 'bg-rose-950/40 text-rose-400 border border-rose-500/20' : 'bg-slate-800 text-slate-300 border border-slate-700/50'}`}>
STOCK {internalStockVal.toLocaleString('de-DE')}
</span>
<span className="px-2 py-0.5 rounded text-[9px] font-bold bg-[#16122c] text-indigo-300 border border-indigo-500/20">
VENDOR {vendorStockVal.toLocaleString('de-DE')}
</span>
{buyBoxLostMap?.has(row.asin?.toUpperCase()) && (
<span className="px-2 py-0.5 rounded text-[9px] font-bold bg-amber-500/10 text-amber-400 border border-amber-500/20">
BB LOST DE
</span>
)}
</div>
{/* Coverage Timeline progress bar */}
<div className="mt-2.5">
<div className="w-32 bg-slate-800/80 rounded-full h-1.5 overflow-hidden">
<div
className={`h-full ${barColor}`}
style={{ width: `${Math.min(100, Math.max(0, (woc / 90) * 100))}%` }}
/>
</div>
<span className={`text-[9px] font-black uppercase tracking-wider block mt-1 ${textColor}`}>
{woc.toFixed(1)} WEEKS COVER
</span>
</div>
</div>
</td>
{/* Metrics Data */}
{years.map((year) => {
const yData = row.totalsByYear[year];
return (
<React.Fragment key={year}>
<td className="px-4 py-4 text-right font-semibold text-slate-100 text-xs align-top">
{yData ? `${yData.sellOut.toLocaleString('de-DE', { maximumFractionDigits: 0 })}` : '-'}
</td>
<td className="px-4 py-4 text-right font-medium text-slate-300 text-xs align-top">
{yData ? yData.units.toLocaleString('de-DE') : '-'}
</td>
</React.Fragment>
);
})}
{/* Delta growth % */}
<td className="px-4 py-4 align-top text-center">
{sellOutGrowthPct !== 0 ? (
<span className="inline-flex items-center gap-0.5 px-2 py-0.5 rounded text-[10px] font-bold bg-emerald-500/10 text-emerald-400 border border-emerald-500/20">
{Math.round(sellOutGrowthPct)}%
</span>
) : (
<span className="text-slate-600">-</span>
)}
</td>
{/* Delta growth € */}
<td className="px-4 py-4 text-right align-top font-bold text-emerald-400 text-xs">
{sellOutDeltaVal !== 0 ? (
<span>
{sellOutDeltaVal > 0 ? '+' : ''}{sellOutDeltaVal.toLocaleString('de-DE', { maximumFractionDigits: 0 })}
</span>
) : (
<span className="text-slate-600">-</span>
)}
</td>
</tr>
);
})}
{paginatedRows.length === 0 && (
<tr>
<td colSpan={effectiveDimensions.length + (years.length * 2) + (showAdsMetrics && adsSummary ? years.length * 2 : 0)} className="px-6 py-12 text-center text-slate-500 italic">
<td colSpan={6} className="px-6 py-12 text-center text-slate-500 italic">
No data matches your filters.
</td>
</tr>