From 1fc494fc3f8837ca19d7a08efebf8f86610c94a6 Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Mon, 27 Apr 2026 11:40:36 +0200 Subject: [PATCH] Fix: consolidate stock badges and update WOC calculation to include internal warehouse stock --- components/AdsPerformance.tsx | 8 +++++++- components/DataGrid.tsx | 8 +++++++- components/TopMovers.tsx | 2 ++ components/VendorDataView.tsx | 1 + components/VendorStockBadge.tsx | 16 +++++++++------- components/WeeklyGrid.tsx | 9 --------- components/WeeklyRow.tsx | 18 +++++++----------- components/mkt/MasterTable.tsx | 1 + 8 files changed, 34 insertions(+), 29 deletions(-) diff --git a/components/AdsPerformance.tsx b/components/AdsPerformance.tsx index 23609af..489389e 100644 --- a/components/AdsPerformance.tsx +++ b/components/AdsPerformance.tsx @@ -82,7 +82,13 @@ const AdsRow: React.FC<{ {stockMap && ( )} - + diff --git a/components/DataGrid.tsx b/components/DataGrid.tsx index 684505d..34f7f0e 100644 --- a/components/DataGrid.tsx +++ b/components/DataGrid.tsx @@ -1400,7 +1400,13 @@ const DataGrid: React.FC = ({ data, filters, hasCustomerFilter, a } return null; })()} - + : dim === 'asin' || dim === 'sku' diff --git a/components/TopMovers.tsx b/components/TopMovers.tsx index c468060..90782fc 100644 --- a/components/TopMovers.tsx +++ b/components/TopMovers.tsx @@ -157,6 +157,8 @@ const MoversTable: React.FC<{ asin={item.asin} vendorStockMap={vendorStockMap} mode={top50Mode} + avgWeeklySales={velocityMap?.get(item.asin.trim().toUpperCase())} + internalStock={stockMap?.get(item.sku?.replace(/(DE|EN)$/i, ''))} /> diff --git a/components/VendorDataView.tsx b/components/VendorDataView.tsx index c35bfb3..ad7f1f9 100644 --- a/components/VendorDataView.tsx +++ b/components/VendorDataView.tsx @@ -502,6 +502,7 @@ const VendorDataView: React.FC = ({ vendorStockMap={vendorStockMap} mode={top50Mode} avgWeeklySales={velocityMap?.get(productInfo.asin.trim().toUpperCase())} + internalStock={stockMap?.get(productInfo.sku?.replace(/(DE|EN)$/i, ''))} /> diff --git a/components/VendorStockBadge.tsx b/components/VendorStockBadge.tsx index 3988b51..4a351b3 100644 --- a/components/VendorStockBadge.tsx +++ b/components/VendorStockBadge.tsx @@ -6,9 +6,10 @@ interface VendorStockBadgeProps { vendorStockMap?: Map; mode: 'eu' | 'uk'; avgWeeklySales?: number; + internalStock?: number; } -export const VendorStockBadge: React.FC = ({ asin, vendorStockMap, mode, avgWeeklySales }) => { +export const VendorStockBadge: React.FC = ({ asin, vendorStockMap, mode, avgWeeklySales, internalStock }) => { if (!asin) return null; const normalizedAsin = asin.trim().toUpperCase(); @@ -27,7 +28,8 @@ export const VendorStockBadge: React.FC = ({ asin, vendor ); } - const stock = mode === 'uk' ? stockData.uk : stockData.eu; + const amazonStock = mode === 'uk' ? stockData.uk : stockData.eu; + const totalStock = amazonStock + (internalStock || 0); // Calculate Weeks of Coverage (WOC) // If sales are 0 but store has stock -> Infinite coverage (>52 weeks) -> Green @@ -37,8 +39,8 @@ export const VendorStockBadge: React.FC = ({ asin, vendor const velocity = avgWeeklySales || 0; if (velocity > 0) { - woc = stock / velocity; - } else if (stock > 0) { + woc = totalStock / velocity; + } else if (totalStock > 0) { woc = 999; } else { woc = 0; @@ -53,17 +55,17 @@ export const VendorStockBadge: React.FC = ({ asin, vendor
Vendor - {stock.toLocaleString('de-DE')} + {amazonStock.toLocaleString('de-DE')}
{wocText} diff --git a/components/WeeklyGrid.tsx b/components/WeeklyGrid.tsx index d56a1b3..86e148c 100644 --- a/components/WeeklyGrid.tsx +++ b/components/WeeklyGrid.tsx @@ -692,15 +692,6 @@ const WeeklyGrid: React.FC = ({
- {/* COVERAGE Header Column */} - -
- Coverage - (WOC) -
- {weeks.map(week => ( = React.memo(({ {stockMap && ( )} + {(() => { if (asin && top50Ranking) { if (top50Mode === 'eu') { @@ -141,17 +148,6 @@ export const WeeklyRow: React.FC = React.memo(({ {row.line} - {/* Coverage Column */} - -
- -
- {weeks.map((week, idx) => { const val = row.unitsByWeek[week] || 0; const prevVal = row.unitsByWeek[weeks[idx + 1]] || 0; diff --git a/components/mkt/MasterTable.tsx b/components/mkt/MasterTable.tsx index 6d7a009..0af933d 100644 --- a/components/mkt/MasterTable.tsx +++ b/components/mkt/MasterTable.tsx @@ -217,6 +217,7 @@ export const MasterTable: React.FC = ({ vendorStockMap={vendorStockMap} mode={top50Mode} avgWeeklySales={velocityMap?.get(product.asin.trim().toUpperCase())} + internalStock={stockMap?.get(product.sku?.replace(/(DE|EN)$/i, ''))} />