import React, { useRef, useState } from "react"; import { AddIcon, InfoIcon, RemoveIcon, ResizeHeightIcon, } from "../../../icons/ExportCommonIcons"; import RenameInput from "../../../ui/inputs/RenameInput"; import InputWithDropDown from "../../../ui/inputs/InputWithDropDown"; import LabledDropdown from "../../../ui/inputs/LabledDropdown"; import RegularDropDown from "../../../ui/inputs/RegularDropDown"; import { handleResize } from "../../../../functions/handleResizePannel"; import EyeDropInput from "../../../ui/inputs/EyeDropInput"; import { useSelectedActionSphere } from "../../../../store/store"; const MachineMechanics: React.FC = () => { const { selectedActionSphere } = useSelectedActionSphere(); console.log("selectedActionSphere: ", selectedActionSphere); const [actionList, setActionList] = useState([]); const [triggerList, setTriggerList] = useState([]); const [selectedItem, setSelectedItem] = useState<{ type: "action" | "trigger"; name: string; } | null>(null); const actionsContainerRef = useRef(null); const triggersContainerRef = useRef(null); const handleAddAction = () => { setActionList([...actionList, `Action ${actionList.length + 1}`]); }; const handleAddTrigger = () => { setTriggerList([...triggerList, `Trigger ${triggerList.length + 1}`]); }; const handleRemoveAction = (index: number) => { setActionList(actionList.filter((_, i) => i !== index)); if ( selectedItem?.type === "action" && selectedItem.name === actionList[index] ) { setSelectedItem(null); } }; const handleRemoveTrigger = (index: number) => { setTriggerList(triggerList.filter((_, i) => i !== index)); if ( selectedItem?.type === "trigger" && selectedItem.name === triggerList[index] ) { setSelectedItem(null); } }; const handleSelectItem = (type: "action" | "trigger", name: string) => { setSelectedItem({ type, name }); }; const [processes, setProcesses] = useState([]); const [activeProcess, setActiveProcesses] = useState(); const handleSelect = (option: string) => { setActiveProcesses(option); // Update the active option state }; const handleAddProcess = () => { const newProcess = `Process ${processes.length + 1}`; // Generate new process name dynamically setProcesses((prevProcesses) => [...prevProcesses, newProcess]); // Update the state with the new process }; return (
{selectedActionSphere?.path?.modelName || "path name not found"}
{/*
Process:
"} options={processes} onSelect={handleSelect} />
*/}
Actions
Add
{actionList.map((action, index) => (
handleSelectItem("action", action)} >
handleRemoveAction(index)} >
))}
handleResize(e, actionsContainerRef)} >
Triggers
Add
{triggerList.map((trigger, index) => (
handleSelectItem("trigger", trigger)} >
handleRemoveTrigger(index)} >
))}
handleResize(e, triggersContainerRef)} >
{selectedItem && ( <>
{selectedItem.name}
{}} /> )}
By Selecting Path, you can create Object Triggers.
); }; export default MachineMechanics;