mirror of
https://github.com/R0m1k3/CollectFlow.git
synced 2026-10-23 23:18:10 +02:00
feat: add AI Copilot Zustand store for managing product insights and analysis.
This commit is contained in:
1 parent
c23f74d32d
commit
8767b1cf1e
1 file changed
+11
-3
@@ -1,6 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
|
import { persist } from "zustand/middleware";
|
||||||
|
|
||||||
interface AiInsight {
|
interface AiInsight {
|
||||||
codein: string;
|
codein: string;
|
||||||
@@ -24,7 +25,9 @@ interface AiCopilotState {
|
|||||||
}) => Promise<void>;
|
}) => Promise<void>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useAiCopilotStore = create<AiCopilotState>((set) => ({
|
export const useAiCopilotStore = create<AiCopilotState>()(
|
||||||
|
persist(
|
||||||
|
(set, get) => ({
|
||||||
insights: {},
|
insights: {},
|
||||||
|
|
||||||
setInsight: (codein, insight, isDuplicate = false) => {
|
setInsight: (codein, insight, isDuplicate = false) => {
|
||||||
@@ -37,7 +40,7 @@ export const useAiCopilotStore = create<AiCopilotState>((set) => ({
|
|||||||
},
|
},
|
||||||
|
|
||||||
analyzeProduct: async (payload) => {
|
analyzeProduct: async (payload) => {
|
||||||
const { codein, score } = payload;
|
const { codein } = payload;
|
||||||
|
|
||||||
// Mark as loading
|
// Mark as loading
|
||||||
set((s) => ({
|
set((s) => ({
|
||||||
@@ -69,4 +72,9 @@ export const useAiCopilotStore = create<AiCopilotState>((set) => ({
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}));
|
}),
|
||||||
|
{
|
||||||
|
name: "collectflow-ai-storage",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
Reference in new issue
Block a user