diff --git a/src/pages/MonitoringPage/Components.tsx b/src/pages/MonitoringPage/Components.tsx new file mode 100644 index 0000000..5dc05f6 --- /dev/null +++ b/src/pages/MonitoringPage/Components.tsx @@ -0,0 +1,149 @@ +import React, { useState } from 'react'; +import styles from './MonitoringPage.module.css'; + +/** + * HELPER: Unified sender function + * In a real app, you might move this to a /services or /hooks folder + */ +const sendUserInterrupt = async (type: string, context: string) => { + try { + const response = await fetch("http://localhost:8000/button_pressed", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify({ type, context }), + }); + if (!response.ok) throw new Error("Backend response error"); + console.log(`Interrupt Sent - Type: ${type}, Context: ${context}`); + } catch (err) { + console.error(`Failed to send interrupt:`, err); + } +}; + +// --- GESTURE COMPONENT --- +export const GestureControls: React.FC = () => { + const [selectedGesture, setSelectedGesture] = useState("animations/Stand/BodyTalk/Speaking/BodyTalk_1"); + + const gestures = [ + { label: "Body Talk 1", value: "animations/Stand/BodyTalk/Speaking/BodyTalk_1" }, + { label: "Thinking 8", value: "animations/Stand/Gestures/Thinking_8" }, + { label: "Thinking 1", value: "animations/Stand/Gestures/Thinking_1" }, + { label: "Happy", value: "animations/Stand/Emotions/Positive/Happy_1" }, + ]; + + return ( +
+

Gestures

+
+ + +
+
+ ); +}; + +// --- PRESET SPEECH COMPONENT --- +export const SpeechPresets: React.FC = () => { + const phrases = [ + { label: "Hello, I'm Pepper", text: "Hello, I'm Pepper" }, + { label: "Repeat please", text: "Could you repeat that please" }, + { label: "About yourself", text: "Tell me something about yourself" }, + ]; + + return ( +
+

Speech Presets

+ +
+ ); +}; + +// --- DIRECT SPEECH (INPUT) COMPONENT --- +export const DirectSpeechInput: React.FC = () => { + const [text, setText] = useState(""); + + const handleSend = () => { + if (!text.trim()) return; + sendUserInterrupt("speech", text); + setText(""); // Clear after sending + }; + + return ( +
+

Direct Pepper Speech

+
+ setText(e.target.value)} + placeholder="Type message..." + onKeyDown={(e) => e.key === 'Enter' && handleSend()} + /> + +
+
+ ); +}; + +// --- interface for goals/triggers/norms/conditional norms --- +interface StatusListProps { + title: string; + items: any[]; + type: 'goal' | 'trigger' | 'norm'| 'cond_norm'; +} + +// --- STATUS LIST COMPONENT --- +export const StatusList: React.FC = ({ title, items, type }) => { + return ( +
+

{title}

+ +
+ ); +}; \ No newline at end of file diff --git a/src/pages/MonitoringPage/MonitoringPage.tsx b/src/pages/MonitoringPage/MonitoringPage.tsx index d19dbae..6d985a1 100644 --- a/src/pages/MonitoringPage/MonitoringPage.tsx +++ b/src/pages/MonitoringPage/MonitoringPage.tsx @@ -1,6 +1,7 @@ import React from 'react'; import styles from './MonitoringPage.module.css'; import useProgramStore from "../../utils/programStore.ts"; +import { GestureControls, SpeechPresets, DirectSpeechInput, StatusList } from './Components'; import { nextPhase } from ".//MonitoringPageAPI.ts" type Goal = { id?: string | number; description?: string; achieved?: boolean }; @@ -88,57 +89,14 @@ const MonitoringPage: React.FC = () => {

Phase Overview

-
-

Goals

- -
- -
-

Triggers

- -
- -
-

Norms

- -
- -
-

Conditional Norms

- -
+ + + + {/* LOGS */} @@ -155,38 +113,9 @@ const MonitoringPage: React.FC = () => { {/* FOOTER */} );