feat: modified DnD sidebar to provide different node types

Modified the drag and drop sidebar to create a node of the correct type instead of creating only default nodes, regardless of specified node types for a respective option.

ref: N25B-114
This commit is contained in:
JGerla
2025-10-01 13:45:20 +02:00
parent 9df46c90a3
commit affdc0c3cd

View File

@@ -72,14 +72,41 @@ export function Sidebar() {
if (isInFlow) {
const position = screenToFlowPosition(screenPosition);
const newNode = {
id: getId(),
type: nodeType,
position,
data: { label: `${nodeType} node` },
};
const newNode = () => {
switch (nodeType) {
case "phase":
return {
id: getId(),
type: nodeType,
position,
data: {label: `"new"`, number: (-1)},
};
case "start":
return {
id: getId(),
type: nodeType,
position,
data: {label: `new start node`},
};
case "end":
return {
id: getId(),
type: nodeType,
position,
data: {label: `new end node`},
};
default: {
return {
id: getId(),
type: nodeType,
position,
data: {label: `new default node`},
};
}
}
}
setNodes((nds) => nds.concat(newNode));
setNodes((nds) => nds.concat(newNode()));
}
},
[setNodes, screenToFlowPosition],