feat(client): init store for nodes
This commit is contained in:
25
client/src/store/nodeStore.ts
Normal file
25
client/src/store/nodeStore.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { Edge, Node } from "@xyflow/react";
|
||||
import { create } from "zustand";
|
||||
import { devtools } from "zustand/middleware";
|
||||
|
||||
type NodeStoreState = {
|
||||
node: Node;
|
||||
edge: Edge;
|
||||
loading: boolean;
|
||||
};
|
||||
|
||||
type NodeStoreActions = {
|
||||
addNode: (node: Node) => void;
|
||||
addEdge: (edge: Edge) => void;
|
||||
removeNode: (nodeId: string) => void;
|
||||
removeEdge: (edgeId: string) => void;
|
||||
};
|
||||
|
||||
type NodeStore = NodeStoreState & NodeStoreActions;
|
||||
|
||||
export const useNodeStore = create<NodeStore>()(
|
||||
devtools((set) => ({
|
||||
nodes: [],
|
||||
edges: [],
|
||||
}))
|
||||
);
|
Reference in New Issue
Block a user