feat: gesturepage with gesture button

ref: N25B-345
This commit is contained in:
Tuurminator69
2025-12-09 11:19:46 +01:00
parent 80aa1fca2b
commit aa3a403d2d
3 changed files with 54 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
import { useState } from 'react'
/**
*
* @returns A JSX element representing the apps gesture page.
*/
export default function GesturePage() {
const [tags, setTags] = useState([])
function getTags(){
fetch(
"http://localhost:8000/robot/get_available_gesture_tags",
{
method: "GET"
}
).then((res) => {
if (!res.ok) throw new Error("Failed communicating with the backend.")
res.json().then((jsonRes) => setTags(jsonRes["tags"]))
}).catch(() => console.log("Failed to send program to the backend."));
}
const gesture = {endpoint: "actuate/gesture/tag", data: "happy"}
function doGesture(){
fetch(
"http://localhost:8000/robot/command",
{
method: "POST",
headers: {"Content-Type": "application/json"},
body: JSON.stringify(gesture),
}
).then((res) => {
if (!res.ok) throw new Error("Failed communicating with the backend.")
console.log("Successfully sent the gesture command to the backend.");
}).catch(() => console.log("Failed to send gesture command to the backend."));
}
return (
<div className="card">
<button onClick={getTags}>
Get Tags
</button>
<button onClick={doGesture}>
Do Gesture
</button>
</div>
)
}