summaryrefslogtreecommitdiff
path: root/frontend/src/components/AddRobotForm.tsx
diff options
context:
space:
mode:
authorArne Rief <riearn@proton.me>2025-12-22 21:20:39 +0100
committerArne Rief <riearn@proton.me>2025-12-22 21:20:39 +0100
commite836e7dd4ed5e9fa60e949d159100040b22a8f48 (patch)
treea11954c06e55e8ef53fcb634fa5954dfcb42ffc3 /frontend/src/components/AddRobotForm.tsx
parentd1b64ddd78d8b8dc3eca76038a75071ab2a575d9 (diff)
Movement simulator for all and single robot, project v1 ready
Diffstat (limited to 'frontend/src/components/AddRobotForm.tsx')
-rw-r--r--frontend/src/components/AddRobotForm.tsx11
1 files changed, 9 insertions, 2 deletions
diff --git a/frontend/src/components/AddRobotForm.tsx b/frontend/src/components/AddRobotForm.tsx
index c178657..0d2a00f 100644
--- a/frontend/src/components/AddRobotForm.tsx
+++ b/frontend/src/components/AddRobotForm.tsx
@@ -5,22 +5,26 @@ import {
type SetStateAction,
} from "react";
import type { ErrorResponse } from "../types/error";
-import type { CreateRobotResponse } from "../types/robot";
+import type { CreateRobotResponse, Robot } from "../types/robot";
type Props = {
apiUrl: string;
errorMessage: string;
+ robots: Robot[];
token: string | null;
setErrorMessage: Dispatch<SetStateAction<string>>;
setIsAddingRobot: Dispatch<SetStateAction<boolean>>;
+ setRobots: Dispatch<SetStateAction<Robot[]>>;
};
function AddRobotForm({
apiUrl,
errorMessage,
+ robots,
token,
setErrorMessage,
setIsAddingRobot,
+ setRobots,
}: Props) {
const [isSubmitting, setIsSubmitting] = useState<boolean>(false);
const [newRobotName, setNewRobotName] = useState<string>("");
@@ -69,7 +73,10 @@ function AddRobotForm({
}
const data: CreateRobotResponse = await response.json();
- console.log("Robot created successfully: ", data);
+ console.log(data.message, data.robot);
+
+ const newRobotList = [...robots, data.robot];
+ setRobots(newRobotList);
// Reset form and close input field
setNewRobotName("");