diff --git a/src/frontend/src/CustomNodes/GenericNode/index.tsx b/src/frontend/src/CustomNodes/GenericNode/index.tsx index d7e8a71bb..990fd458b 100644 --- a/src/frontend/src/CustomNodes/GenericNode/index.tsx +++ b/src/frontend/src/CustomNodes/GenericNode/index.tsx @@ -1,94 +1,119 @@ +import { TrashIcon } from "@heroicons/react/24/outline"; import { - TrashIcon, -} from "@heroicons/react/24/outline"; -import { - classNames, - nodeColors, - nodeIcons, - snakeToNormalCase, + classNames, + nodeColors, + nodeIcons, + snakeToNormalCase, } from "../../utils"; import ParameterComponent from "./components/parameterComponent"; import { typesContext } from "../../contexts/typesContext"; -import { useContext } from "react"; -import { NodeDataType} from "../../types/flow"; +import { useContext, useRef } from "react"; +import { NodeDataType } from "../../types/flow"; +import { alertContext } from "../../contexts/alertContext"; -export default function GenericNode({ data, selected}:{data:NodeDataType,selected:boolean}) { - const {types, deleteNode} = useContext(typesContext); - const Icon = nodeIcons[types[data.type]]; - if(!Icon){ - return - } +export default function GenericNode({ + data, + selected, +}: { + data: NodeDataType; + selected: boolean; +}) { + const { setErrorData } = useContext(alertContext); + const showError = useRef(true) + const { types, deleteNode } = useContext(typesContext); + const Icon = nodeIcons[types[data.type]]; + if (!Icon) { + console.log(data); + if(showError.current){ + setErrorData({ + title: data.type?`The ${data.type} node could not be rendered, please review your json file`: + "There was a node that can't be rendered, please review your json file", + }); + showError.current=false + } + return; + } - return ( -