Enhance MachineMechanics and InputWithDropDown components; add connections to path interfaces

This commit is contained in:
2025-03-27 12:24:15 +05:30
parent 6b92b6c235
commit 2dfd34f27b
8 changed files with 32 additions and 25 deletions

View File

@@ -1,4 +1,4 @@
import React, { useRef, useState, useMemo } from "react";
import React, { useRef, useState, useMemo, useEffect } from "react";
import {
AddIcon,
InfoIcon,
@@ -325,10 +325,11 @@ const MachineMechanics: React.FC = () => {
}
};
const [selectedItem, setSelectedItem] = useState<{
type: "action" | "trigger";
item: any;
} | null>(null);
const [selectedItem, setSelectedItem] = useState<{ type: "action" | "trigger"; item: any; } | null>(null);
useEffect(() => {
setSelectedItem(null); // Reset selectedItem when selectedActionSphere changes
}, [selectedActionSphere]);
return (
<div className="machine-mechanics-container">
@@ -479,18 +480,14 @@ const MachineMechanics: React.FC = () => {
{selectedItem.item.type === 'Spawn' && (
<InputWithDropDown
label="Spawn Interval"
value={selectedItem.item.spawnInterval === 'Inherit'
? undefined
: selectedItem.item.spawnInterval}
min={0}
defaultValue={selectedItem.item.spawnInterval === "Inherit" ? "" : selectedItem.item.spawnInterval.toString()}
value={selectedItem.item.spawnInterval === "Inherit" ? "" : selectedItem.item.spawnInterval.toString()}
onChange={(value) => {
const numValue = parseInt(value);
handleSpawnIntervalChange(
selectedItem.item.uuid,
!value ? 'Inherit' : numValue
);
handleSpawnIntervalChange(selectedItem.item.uuid, (value === "") ? "Inherit" : parseInt(value));
}}
/>
)}
</>
)}