feat: enhance product analysis results with additional fields and update handling logic

This commit is contained in:
Victor Noguera
2026-04-13 03:32:46 -04:00
parent 299ad7a1a6
commit 811fe9b10a
4 changed files with 83 additions and 7 deletions

View File

@@ -91,6 +91,8 @@ type ProductListItem = {
seller_count: number | null;
sales_rank: number | null;
current_price: number | null;
avg_price_90d: number | null;
reasoning: string | null;
fetched_at: string;
};
@@ -680,11 +682,16 @@ function ProductList({ verdict, onBack }: { verdict: VerdictFilter; onBack: () =
<th><button onClick={() => setSort(nextSort(sort, "sales_rank"))}>Sales Rank</button></th>
<th><button onClick={() => setSort(nextSort(sort, "current_price"))}>Current Price</button></th>
<th className="product-col"><button onClick={() => setSort(nextSort(sort, "product_name"))}>Product</button></th>
<th><button onClick={() => setSort(nextSort(sort, "brand"))}>Brand</button></th>
<th><button onClick={() => setSort(nextSort(sort, "category"))}>Category</button></th>
<th><button onClick={() => setSort(nextSort(sort, "avg_price_90d"))}>Avg 90d</button></th>
<th><button onClick={() => setSort(nextSort(sort, "confidence"))}>Confidence</button></th>
<th className="reason-col"><button onClick={() => setSort(nextSort(sort, "reasoning"))}>Reasoning</button></th>
</tr>
</thead>
<tbody>
{loading ? (
<tr><td colSpan={7}>Loading...</td></tr>
<tr><td colSpan={12}>Loading...</td></tr>
) : items?.items.length ? (
items.items.map((item) => (
<tr key={`${item.processType}-${item.runId}-${item.asin}-${item.fetched_at}`}>
@@ -694,11 +701,16 @@ function ProductList({ verdict, onBack }: { verdict: VerdictFilter; onBack: () =
<td>{formatNumber(item.seller_count)}</td>
<td>{formatNumber(item.sales_rank)}</td>
<td>{formatCurrency(item.current_price)}</td>
<td className="product-col" title={item.product_name || undefined}>{item.product_name || "-"}</td>
<td className="product-col" title={item.reasoning || undefined}>{item.product_name || "-"}</td>
<td>{item.brand || "-"}</td>
<td>{item.category || "-"}</td>
<td>{formatCurrency(item.avg_price_90d)}</td>
<td>{formatNumber(item.confidence)}</td>
<td className="reason-col" title={item.reasoning || undefined}>{item.reasoning || "-"}</td>
</tr>
))
) : (
<tr><td colSpan={7}>No products found</td></tr>
<tr><td colSpan={12}>No products found</td></tr>
)}
</tbody>
</table>