import React, { useEffect, useRef } from 'react'; import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from 'recharts'; import { Camera, MicOff } from 'lucide-react'; interface MetricsPanelProps { activeTab: 'SENSORS' | 'MOTORS'; setActiveTab: (tab: 'SENSORS' | 'MOTORS') => void; sensorData: any[]; motorData: any[]; hasPermissions: boolean; streamRef: React.RefObject; isVoiceActive: boolean; micLevel: number; } const MetricsPanel: React.FC = ({ activeTab, setActiveTab, sensorData, motorData, hasPermissions, streamRef, isVoiceActive, micLevel, }) => { const sensorVideoRef = useRef(null); useEffect(() => { if (activeTab === 'SENSORS' && hasPermissions && sensorVideoRef.current && streamRef.current) { if (sensorVideoRef.current.srcObject !== streamRef.current) { sensorVideoRef.current.srcObject = streamRef.current; } } }, [activeTab, hasPermissions, streamRef]); return (
{/* Tab Headers */}
{/* Chart Content */}
{activeTab === 'SENSORS' && (
{/* Webcam Feed */}

Live Camera Feed

{hasPermissions ? (
) : (

Camera permission not granted.

)}
{/* Mic Detection & Other Sensors */}

Voice Activity

{hasPermissions ? (
{[...Array(15)].map((_, i) => { const barIsActive = isVoiceActive && i < (micLevel / 120 * 15); return (
); })}

{isVoiceActive ? "Voice commands active" : "Voice commands muted"}

) : (

Microphone permission not granted.

)}
{/* Sensor Charts */} {['sensor3', 'sensor4'].map((sensor, index) => (

Sensor {index + 3}

))}
)} {activeTab === 'MOTORS' && (
{['motor1', 'motor2', 'motor3', 'motor4', 'motor5', 'motor6'].map((motor, index) => (

Motor {index + 1}

))}
)}
); }; export default MetricsPanel;