From 673cab4454dd9015d1892354561ec4518477bed9 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 22 Feb 2026 23:58:19 +0100 Subject: [PATCH] feat: Add bulk AI product analysis component with progress tracking, concurrency, and benchmark calculations, along with a component for displaying individual AI insights. --- src/features/ai-copilot/components/ai-insight-block.tsx | 7 +++++++ src/features/grid/components/bulk-ai-analyzer.tsx | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/features/ai-copilot/components/ai-insight-block.tsx b/src/features/ai-copilot/components/ai-insight-block.tsx index cc88028..67eac04 100644 --- a/src/features/ai-copilot/components/ai-insight-block.tsx +++ b/src/features/ai-copilot/components/ai-insight-block.tsx @@ -5,17 +5,24 @@ import { useAiCopilotStore } from "@/features/ai-copilot/store/use-ai-copilot-st import type { ProductRow } from "@/types/grid"; import { cn } from "@/lib/utils"; +import { useGridStore } from "@/features/grid/store/use-grid-store"; + interface AiInsightBlockProps { row: ProductRow; } export function AiInsightBlock({ row }: AiInsightBlockProps) { const { insights, analyzeProduct } = useAiCopilotStore(); + const setDraftGamme = useGridStore(state => state.setDraftGamme); const insight = insights[row.codein]; const status = insight?.status ?? "idle"; const handleAnalyze = () => { if (status === "loading") return; + + // Vider la recommandation actuelle avant de relancer l'IA + setDraftGamme(row.codein, "Aucune"); + analyzeProduct({ codein: row.codein, libelle1: row.libelle1, diff --git a/src/features/grid/components/bulk-ai-analyzer.tsx b/src/features/grid/components/bulk-ai-analyzer.tsx index 9445f91..b82426a 100644 --- a/src/features/grid/components/bulk-ai-analyzer.tsx +++ b/src/features/grid/components/bulk-ai-analyzer.tsx @@ -103,6 +103,8 @@ export function BulkAiAnalyzer() { // Marquer temporairement comme loading dans le store pour le feedback visuel individuel setInsight(payload.codein, "", false); + // Vider aussi la recommandation (A, C, Z) pour montrer que c'est en cours de recalcul + setDraftGamme(payload.codein, "Aucune"); // Note: setInsight dans le store actuel met le status à "done". // Pour bien faire, il faudrait une action setStatusLoading dans le store. // Ici, on va au moins vider l'insight pour montrer que ça bouge.