From 9c0d794dd1159e26545fefea0ea0bee748142d00 Mon Sep 17 00:00:00 2001 From: anovazzi1 Date: Thu, 18 Jan 2024 18:18:54 -0300 Subject: [PATCH] Add checkInputandOutput function to flowStore.ts --- src/frontend/src/stores/flowStore.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/frontend/src/stores/flowStore.ts b/src/frontend/src/stores/flowStore.ts index c030a8344..485ac01fd 100644 --- a/src/frontend/src/stores/flowStore.ts +++ b/src/frontend/src/stores/flowStore.ts @@ -20,6 +20,8 @@ import { cleanEdges, getHandleId, getNodeId, + isInputNode, + isOutputNode, scapeJSONParse, scapedJSONStringfy, } from "../utils/reactflowUtils"; @@ -153,6 +155,21 @@ const useFlowStore = create((set, get) => ({ }) ); }, + checkInputandOutput: () => { + let has_input = false; + let has_output = false; + const nodes = get().nodes; + nodes.forEach((node) => { + const nodeData: NodeDataType = node.data as NodeDataType; + if (isInputNode(nodeData)) { + has_input = true; + } + if (isOutputNode(nodeData)) { + has_output = true; + } + }); + return has_input && has_output; + }, getNode: (id: string) => { return get().nodes.find((node) => node.id === id); },