diff --git a/space_flow/src/components/chatComponent/index.tsx b/space_flow/src/components/chatComponent/index.tsx index 1b3a90eda..9a29d5e81 100644 --- a/space_flow/src/components/chatComponent/index.tsx +++ b/space_flow/src/components/chatComponent/index.tsx @@ -4,15 +4,17 @@ import { PaperAirplaneIcon, XMarkIcon, } from "@heroicons/react/24/outline"; -import { useState } from "react"; +import { useContext, useState } from "react"; import { sendAll } from "../../controllers/NodesServices"; +import { alertContext } from "../../contexts/alertContext"; const _ = require("lodash"); -export default function Chat({ nodes, edges }) { +export default function Chat({ reactFlowInstance }) { const [open, setOpen] = useState(true); const [chatValue, setChatValue] = useState(""); const [chatHistory, setChatHistory] = useState([]); + const {setErrorData} = useContext(alertContext); const addChatHistory = (message, isSend) => { setChatHistory((old) => { let newChat = _.cloneDeep(old); @@ -20,6 +22,12 @@ export default function Chat({ nodes, edges }) { return newChat; }); }; + function validateNodes(){ + if(reactFlowInstance.getNodes().some((n) => (n.data.node && Object.keys(n.data.node.template).some((t: any) => (n.data.node.template[t].required && !reactFlowInstance.getEdges().some((e) => (e.sourceHandle.split('|')[1] === t && e.sourceHandle.split('|')[2] === n.id))))))){ + return false; + } + return true; + } return ( <>