From 7765f97a1ff1149d763e918ae8361c4cec154609 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 22 Feb 2026 13:24:59 +0100 Subject: [PATCH] feat: Add AI Copilot store for product analysis and a floating summary bar component with AI insight integration. --- .../ai-copilot/store/use-ai-copilot-store.ts | 5 ++++ .../grid/components/floating-summary-bar.tsx | 23 ++++++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/features/ai-copilot/store/use-ai-copilot-store.ts b/src/features/ai-copilot/store/use-ai-copilot-store.ts index cbb8091..0b65ce7 100644 --- a/src/features/ai-copilot/store/use-ai-copilot-store.ts +++ b/src/features/ai-copilot/store/use-ai-copilot-store.ts @@ -23,6 +23,7 @@ interface AiCopilotState { codeGamme: string | null; score?: number | null; }) => Promise; + resetInsights: () => void; } export const useAiCopilotStore = create()( @@ -39,6 +40,10 @@ export const useAiCopilotStore = create()( })); }, + resetInsights: () => { + set({ insights: {} }); + }, + analyzeProduct: async (payload) => { const { codein } = payload; diff --git a/src/features/grid/components/floating-summary-bar.tsx b/src/features/grid/components/floating-summary-bar.tsx index 0a5829f..9bcf919 100644 --- a/src/features/grid/components/floating-summary-bar.tsx +++ b/src/features/grid/components/floating-summary-bar.tsx @@ -1,10 +1,11 @@ "use client"; import { useGridStore } from "@/features/grid/store/use-grid-store"; +import { useAiCopilotStore } from "@/features/ai-copilot/store/use-ai-copilot-store"; import { BulkAiAnalyzer } from "./bulk-ai-analyzer"; import { useSaveDrafts } from "@/features/grid/hooks/use-save-drafts"; -import { Loader2, CheckCircle, AlertCircle } from "lucide-react"; +import { Loader2, CheckCircle, AlertCircle, RotateCcw } from "lucide-react"; import { useState, useTransition } from "react"; function Stat({ label, value, sub }: { label: string; value: string; sub?: string }) { @@ -20,7 +21,8 @@ function Stat({ label, value, sub }: { label: string; value: string; sub?: strin } export function FloatingSummaryBar() { - const { summary, draftChanges, rows, filters } = useGridStore(); + const { summary, resetDrafts, rows, filters } = useGridStore(); + const { resetInsights } = useAiCopilotStore(); const [isPending, startTransition] = useTransition(); const [saveStatus, setSaveStatus] = useState<"idle" | "success" | "error">("idle"); @@ -35,6 +37,13 @@ export function FloatingSummaryBar() { }); }; + const handleReset = () => { + if (window.confirm("Es-tu sûr de vouloir annuler tous les changements non enregistrés (gammes et analyses IA) ?")) { + resetDrafts(); + resetInsights(); + } + }; + return (
+ +
{hasDrafts && ( - + {count} modif. )}