import React, { useContext, useEffect, useRef, useState } from 'react'; import { LogContext } from './LogContext'; import './LogPanel.css'; const LogPanel = () => { const { logs } = useContext(LogContext); const panelRef = useRef(null); const [isMinimized, setIsMinimized] = useState(false); // Auto-scroll to the bottom when new logs arrive useEffect(() => { if (panelRef.current && !isMinimized) { panelRef.current.scrollTop = panelRef.current.scrollHeight; } }, [logs, isMinimized]); const getLogLevelClass = (level) => { switch (level) { case 'ERROR': return 'log-error'; case 'SUCCESS': return 'log-success'; case 'WARN': return 'log-warn'; default: return 'log-info'; } }; const toggleMinimize = () => { setIsMinimized(!isMinimized); }; return (