From c6ff9094ed2dc8ff460a910da37c6e5ab3cd0e15 Mon Sep 17 00:00:00 2001 From: MayaTheShy Date: Fri, 20 Feb 2026 03:41:21 -0500 Subject: [PATCH] style: Refactor TurtleDetails to use direct command functions and remove legacy command handling --- client/src/components/ControlPanel.jsx | 107 ++++++------------------- 1 file changed, 25 insertions(+), 82 deletions(-) diff --git a/client/src/components/ControlPanel.jsx b/client/src/components/ControlPanel.jsx index 16019a2..d09f00c 100644 --- a/client/src/components/ControlPanel.jsx +++ b/client/src/components/ControlPanel.jsx @@ -77,7 +77,6 @@ function TurtleCard({ turtle, isSelected, onSelect }) { } function TurtleDetails({ turtle }) { - const sendCommand = useTurtleStore((state) => state.sendCommand); const setTurtleState = useTurtleStore((state) => state.setTurtleState); const renameTurtle = useTurtleStore((state) => state.renameTurtle); const equipLeft = useTurtleStore((state) => state.equipLeft); @@ -90,6 +89,16 @@ function TurtleDetails({ turtle }) { const updateTurtleConfig = useTurtleStore((state) => state.updateTurtleConfig); const exploreTurtle = useTurtleStore((state) => state.exploreTurtle); const gpsLocateTurtle = useTurtleStore((state) => state.gpsLocateTurtle); + const moveForward = useTurtleStore((state) => state.moveForward); + const moveBack = useTurtleStore((state) => state.moveBack); + const moveUp = useTurtleStore((state) => state.moveUp); + const moveDown = useTurtleStore((state) => state.moveDown); + const turnLeft = useTurtleStore((state) => state.turnLeft); + const turnRight = useTurtleStore((state) => state.turnRight); + const digBlock = useTurtleStore((state) => state.digBlock); + const digBlockUp = useTurtleStore((state) => state.digBlockUp); + const digBlockDown = useTurtleStore((state) => state.digBlockDown); + const placeBlock = useTurtleStore((state) => state.placeBlock); const [renameValue, setRenameValue] = useState(''); const [showConfig, setShowConfig] = useState(false); @@ -103,10 +112,6 @@ function TurtleDetails({ turtle }) { ); } - const handleCommand = (command, param = null) => { - sendCommand(turtle.turtleID, command, param); - }; - const handleStateChange = (stateName, data = {}) => { setTurtleState(turtle.turtleID, stateName, data); }; @@ -244,7 +249,7 @@ function TurtleDetails({ turtle }) {
-
-

Legacy Commands

-
- - - - - - - - -
-
-

Movement

- +
- - - + + +
- - + +
@@ -458,28 +401,28 @@ function TurtleDetails({ turtle }) {