feat: Add bulk AI product analysis component with progress tracking, concurrency, and benchmark calculations, along with a component for displaying individual AI insights.

This commit is contained in:
Michael committed 2026-02-22 23:58:19 +01:00
1 parent 960045dc53
commit 673cab4454
2 files changed
+9

No files matched your search

@@ -5,17 +5,24 @@ import { useAiCopilotStore } from "@/features/ai-copilot/store/use-ai-copilot-st
import type { ProductRow } from "@/types/grid"; import type { ProductRow } from "@/types/grid";
import { cn } from "@/lib/utils"; import { cn } from "@/lib/utils";
import { useGridStore } from "@/features/grid/store/use-grid-store";
interface AiInsightBlockProps { interface AiInsightBlockProps {
row: ProductRow; row: ProductRow;
} }
export function AiInsightBlock({ row }: AiInsightBlockProps) { export function AiInsightBlock({ row }: AiInsightBlockProps) {
const { insights, analyzeProduct } = useAiCopilotStore(); const { insights, analyzeProduct } = useAiCopilotStore();
const setDraftGamme = useGridStore(state => state.setDraftGamme);
const insight = insights[row.codein]; const insight = insights[row.codein];
const status = insight?.status ?? "idle"; const status = insight?.status ?? "idle";
const handleAnalyze = () => { const handleAnalyze = () => {
if (status === "loading") return; if (status === "loading") return;
// Vider la recommandation actuelle avant de relancer l'IA
setDraftGamme(row.codein, "Aucune");
analyzeProduct({ analyzeProduct({
codein: row.codein, codein: row.codein,
libelle1: row.libelle1, libelle1: row.libelle1,
@@ -103,6 +103,8 @@ export function BulkAiAnalyzer() {
// Marquer temporairement comme loading dans le store pour le feedback visuel individuel // Marquer temporairement comme loading dans le store pour le feedback visuel individuel
setInsight(payload.codein, "", false); 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". // Note: setInsight dans le store actuel met le status à "done".
// Pour bien faire, il faudrait une action setStatusLoading dans le store. // Pour bien faire, il faudrait une action setStatusLoading dans le store.
// Ici, on va au moins vider l'insight pour montrer que ça bouge. // Ici, on va au moins vider l'insight pour montrer que ça bouge.