From 2814d68716d19128242c9f52e68036ee685a8d53 Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Tue, 3 Mar 2026 11:21:14 +0100 Subject: [PATCH] feat: mostrar detalles del producto en Vendor tab cuando hay un solo ASIN MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Agregar tarjeta con SKU, ASIN y título al inicio de los gráficos - Incluir Buy Box Warning Badge si el producto tiene issues - Solo se muestra cuando hay un único ASIN seleccionado Co-authored-by: Qwen-Coder --- App.tsx | 2 +- components/VendorDataView.tsx | 59 +++++++++++++++++++++++++++++++++-- 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/App.tsx b/App.tsx index 093239c..9b09742 100644 --- a/App.tsx +++ b/App.tsx @@ -924,7 +924,7 @@ const App: React.FC = () => { }>
- +
diff --git a/components/VendorDataView.tsx b/components/VendorDataView.tsx index 20ffda5..5a2e924 100644 --- a/components/VendorDataView.tsx +++ b/components/VendorDataView.tsx @@ -1,6 +1,7 @@ -import React, { useMemo } from 'react'; +import React, { useMemo, useState } from 'react'; import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer } from 'recharts'; import { BSRRecord } from '../types'; +import { BuyBoxWarningBadge } from './BuyBoxWarningBadge'; const MARKET_COLORS: Record = { DE: '#3b82f6', @@ -12,6 +13,8 @@ const MARKET_COLORS: Record = { interface VendorDataViewProps { bsrData: BSRRecord[]; + asinMetadata?: Map; + buyBoxLostMap?: Map }>; } interface ChartPoint { @@ -20,7 +23,7 @@ interface ChartPoint { [key: string]: number | string | null; } -const VendorDataView: React.FC = ({ bsrData = [] }) => { +const VendorDataView: React.FC = ({ bsrData = [], asinMetadata, buyBoxLostMap }) => { // Determine active markets in filtered data for series generation const activeMarkets = useMemo(() => { const m = new Set(bsrData.map(r => r.market)); @@ -33,6 +36,26 @@ const VendorDataView: React.FC = ({ bsrData = [] }) => { return withDate > bsrData.length / 2; }, [bsrData]); + // Get unique ASINs in filtered data + const uniqueAsins = useMemo(() => { + const asinSet = new Set(bsrData.map(r => r.asin.trim().toUpperCase())); + return Array.from(asinSet); + }, [bsrData]); + + // Get product info when single ASIN is selected + const productInfo = useMemo(() => { + if (uniqueAsins.length !== 1) return null; + const asin = uniqueAsins[0]; + const metadata = asinMetadata?.get(asin); + if (!metadata) return null; + return { + asin, + sku: metadata.sku, + title: metadata.title, + line: metadata.line, + }; + }, [uniqueAsins, asinMetadata]); + // Aggregate Data for Charts — daily if dates available, else weekly const { topBsrChartData, detailBsrChartData, ratingChartData } = useMemo(() => { // Group by date string (YYYY-MM-DD) or by week number @@ -121,6 +144,38 @@ const VendorDataView: React.FC = ({ bsrData = [] }) => { {bsrData.length.toLocaleString()} records filtered + {/* Product Info Card - Only shown when single ASIN is selected */} + {productInfo && ( +
+
+
+
+ + Product Details + +
+
+
+ SKU: + {productInfo.sku} +
+
+ ASIN: + {productInfo.asin} +
+
+ Title: + {productInfo.title} +
+
+
+
+ +
+
+
+ )} + {/* Top Level BSR Trend Chart */}

Top Level BSR Trend ({resolutionLabel})