+
Output
diff --git a/space_flow/src/CustomNodes/GenericNode/index.tsx b/space_flow/src/CustomNodes/GenericNode/index.tsx
index 09a4315f8..29db60ef1 100644
--- a/space_flow/src/CustomNodes/GenericNode/index.tsx
+++ b/space_flow/src/CustomNodes/GenericNode/index.tsx
@@ -8,11 +8,11 @@ import {
} from "../../utils";
import ParameterComponent from "./components/parameterComponent";
import { typesContext } from "../../contexts/typesContext";
-import { useContext } from "react";
+import { useContext, useEffect } from "react";
export default function GenericNode({ data }) {
- const Icon = nodeIcons[data.type];
const {types} = useContext(typesContext);
+ const Icon = nodeIcons[types[data.type]];
return (
@@ -20,9 +20,9 @@ export default function GenericNode({ data }) {
-
{data.name}
+
{data.type}
);
diff --git a/space_flow/src/pages/FlowPage/components/extraSidebarComponent/index.tsx b/space_flow/src/pages/FlowPage/components/extraSidebarComponent/index.tsx
index 3d558d6e2..7d0d651dd 100644
--- a/space_flow/src/pages/FlowPage/components/extraSidebarComponent/index.tsx
+++ b/space_flow/src/pages/FlowPage/components/extraSidebarComponent/index.tsx
@@ -17,18 +17,12 @@ export default function ExtraSidebar() {
useEffect(() => {
getAll().then((d) => {
setData(d.data);
- // console.log(d.data);
- });
- }, []);
-
- useEffect(() => {
- if(data){
setTypes(
- Object.keys(data).reduce(
+ Object.keys(d.data).reduce(
(acc, curr) => {
- Object.keys(data[curr]).forEach((c) => {
+ Object.keys(d.data[curr]).forEach((c) => {
acc[c] = curr;
- data[curr][c].base_classes?.forEach((b) => {
+ d.data[curr][c].base_classes?.forEach((b) => {
acc[b] = curr;
});
});
@@ -43,8 +37,8 @@ export default function ExtraSidebar() {
}
)
);
- }
- }, [data, setTypes])
+ });
+ }, []);
function onDragStart(event: React.DragEvent
, data) {
event.dataTransfer.effectAllowed = "move";
@@ -67,8 +61,7 @@ export default function ExtraSidebar() {
style={{ borderLeftColor: nodeColors[d] }}
onDragStart={(event) =>
onDragStart(event, {
- type: d,
- name: t,
+ type: t,
node: data[d][t],
})
}
@@ -94,8 +87,8 @@ export default function ExtraSidebar() {
style={{ borderLeftColor: nodeColors["chat"] }}
onDragStart={(event) =>
onDragStart(event, {
- type: "chat",
- name: "chatInput",
+ type: "chatInput",
+ node: {},
})
}
>
@@ -112,8 +105,8 @@ export default function ExtraSidebar() {
style={{ borderLeftColor: nodeColors["chat"] }}
onDragStart={(event) =>
onDragStart(event, {
- type: "chat",
- name: "chatOutput",
+ type: "chatOutput",
+ node: {},
})
}
>
@@ -136,8 +129,8 @@ export default function ExtraSidebar() {
style={{ borderLeftColor: nodeColors["advanced"] }}
onDragStart={(event) =>
onDragStart(event, {
- type: "advanced",
- name: "str",
+ type: "str",
+ node: {},
})
}
>
@@ -154,8 +147,8 @@ export default function ExtraSidebar() {
style={{ borderLeftColor: nodeColors["advanced"] }}
onDragStart={(event) =>
onDragStart(event, {
- type: "advanced",
- name: "bool",
+ type: "bool",
+ node: {},
})
}
>
diff --git a/space_flow/src/pages/FlowPage/index.tsx b/space_flow/src/pages/FlowPage/index.tsx
index 622c66995..10009d942 100644
--- a/space_flow/src/pages/FlowPage/index.tsx
+++ b/space_flow/src/pages/FlowPage/index.tsx
@@ -80,8 +80,8 @@ export default function FlowPage() {
const reactflowBounds = reactFlowWrapper.current.getBoundingClientRect();
let data = JSON.parse(event.dataTransfer.getData("json"));
if (
- data.name !== "chatInput" ||
- (data.name === "chatInput" &&
+ data.type !== "chatInput" ||
+ (data.type === "chatInput" &&
!reactFlowInstance.getNodes().some((n) => n.type === "chatInputNode"))
) {
const position = reactFlowInstance.project({
@@ -89,24 +89,24 @@ export default function FlowPage() {
y: event.clientY - reactflowBounds.top,
});
let newId = getId();
+
const newNode = {
id: newId,
type:
- data.name === "str"
+ (data.type === "str"
? "inputNode"
- : data.name === "chatInput"
+ : (data.type === "chatInput"
? "chatInputNode"
- : data.name === "chatOutput"
+ : (data.type === "chatOutput"
? "chatOutputNode"
- : data.name === "bool"
+ : (data.type === "bool"
? "booleanNode"
- : "genericNode",
+ : "genericNode")))),
position,
data: {
...data,
id: newId,
- input: "",
- enabled: false,
+ value: null,
reactFlowInstance,
onDelete: () => {
setNodes(