feat: Add AI Copilot Zustand store for managing and persisting product insights.

This commit is contained in:
Michael committed 2026-03-23 13:34:36 +01:00
1 parent 86df5d6f29
commit 99954fb001
2 files changed
+26 -10

No files matched your search

@@ -13,6 +13,7 @@ interface AiInsight {
interface AiCopilotState {
insights: Record<string, AiInsight>;
setInsight: (codein: string, insight: string, isDuplicate?: boolean) => void;
batchSetInsights: (entries: { codein: string; insight: string }[]) => void;
setLoading: (codein: string) => void;
batchSetLoading: (codeins: string[]) => void;
setError: (codein: string, error: string) => void;
@@ -76,6 +77,16 @@ export const useAiCopilotStore = create<AiCopilotState>()(
}));
},
batchSetInsights: (entries) => {
set((s) => {
const nextInsights = { ...s.insights };
entries.forEach(({ codein, insight }) => {
nextInsights[codein] = { codein, insight, status: "done" };
});
return { insights: nextInsights };
});
},
setLoading: (codein) => {
set((s) => ({
insights: {