chore: Update project dependencies.
Some checks failed
Build and Deploy / build-push (push) Has been cancelled
Some checks failed
Build and Deploy / build-push (push) Has been cancelled
This commit is contained in:
34
frontend/src/store/useProjectStore.ts
Normal file
34
frontend/src/store/useProjectStore.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { create } from 'zustand';
|
||||
|
||||
interface Project {
|
||||
id: string;
|
||||
name: string;
|
||||
path: string;
|
||||
parentId: string | null;
|
||||
children?: Project[];
|
||||
}
|
||||
|
||||
interface ProjectState {
|
||||
projects: Project[];
|
||||
expandedKeys: string[];
|
||||
selectedKey: string | null;
|
||||
setProjects: (projects: Project[]) => void;
|
||||
setExpandedKeys: (keys: string[]) => void;
|
||||
setSelectedKey: (key: string | null) => void;
|
||||
expandNode: (key: string) => void;
|
||||
}
|
||||
|
||||
export const useProjectStore = create<ProjectState>((set) => ({
|
||||
projects: [],
|
||||
expandedKeys: [],
|
||||
selectedKey: null,
|
||||
setProjects: (projects) => set({ projects }),
|
||||
setExpandedKeys: (expandedKeys) => set({ expandedKeys }),
|
||||
setSelectedKey: (selectedKey) => set({ selectedKey }),
|
||||
expandNode: (key) =>
|
||||
set((state) => ({
|
||||
expandedKeys: state.expandedKeys.includes(key)
|
||||
? state.expandedKeys
|
||||
: [...state.expandedKeys, key],
|
||||
})),
|
||||
}));
|
||||
Reference in New Issue
Block a user