import React, { useState } from 'react'; import { useNavigate, useLocation } from 'react-router-dom'; import { Activity, Settings, Move, Camera, Layers, Cpu, Target, Lightbulb, Printer, XCircle, Package, BookOpen } from 'lucide-react'; import { VisionMenu } from '../VisionMenu'; import { FunctionMenu } from '../FunctionMenu'; import { comms } from '../../communication'; import { useAlert } from '../../contexts/AlertContext'; interface HeaderProps { currentTime: Date; onTabChange: (tab: 'recipe' | 'motion' | 'camera' | 'setting' | 'initialize' | null) => void; activeTab: 'recipe' | 'motion' | 'camera' | 'setting' | 'initialize' | null; } export const Header: React.FC = ({ currentTime, onTabChange, activeTab }) => { const navigate = useNavigate(); const location = useLocation(); const [showVisionMenu, setShowVisionMenu] = useState(false); const [showFunctionMenu, setShowFunctionMenu] = useState(false); const { showAlert } = useAlert(); const isWebView = typeof window !== 'undefined' && !!window.chrome?.webview; const isIOPage = location.pathname === '/io-monitor'; const handleCommand = async (commandFn: () => Promise<{ success: boolean; message: string }>, actionName: string) => { try { const result = await commandFn(); if (result.success) { console.log(`[Header] ${actionName}: ${result.message}`); // Show success message if needed } else { console.error(`[Header] ${actionName} failed: ${result.message}`); showAlert({ type: 'error', title: `${actionName} Failed`, message: result.message }); } } catch (error: any) { console.error(`[Header] ${actionName} error:`, error); showAlert({ type: 'error', title: `${actionName} Error`, message: error.message || 'Unknown error' }); } }; return ( <> setShowVisionMenu(false)} /> setShowFunctionMenu(false)} />
{ navigate('/'); onTabChange(null); }} >

EQUI-HANDLER PRO

SYS.VER 4.2.0 | LINK: {isWebView ? "NATIVE" : "SIMULATION"}
{/* Top Navigation */}
{/* Quick Action Buttons */}
{/* Main Navigation */}
{[ { id: 'recipe', icon: Layers, label: 'RECIPE', path: '/' }, { id: 'io', icon: Activity, label: 'I/O MONITOR', path: '/io-monitor' }, { id: 'motion', icon: Move, label: 'MOTION', path: '/' }, { id: 'camera', icon: Camera, label: 'VISION', path: '/' }, { id: 'function', icon: Package, label: 'FUNCTION', path: '/' }, { id: 'setting', icon: Settings, label: 'CONFIG', path: '/' }, { id: 'initialize', icon: Target, label: 'INITIALIZE', path: '/' } ].map(item => { const isActive = item.id === 'io' ? location.pathname === '/io-monitor' : activeTab === item.id; return ( ); })}
{currentTime.toLocaleTimeString('en-GB')}
{currentTime.toLocaleDateString().toUpperCase()}
); };