import { useState, useEffect } from 'react'; interface ServiceInfo { name: string; url: string; api: string; status: string; capabilities: string[]; version: string; role?: string; // "leader", "follower", or undefined (for non-meta-core services) } interface ServicesResponse { services: ServiceInfo[]; current: string; } const serviceIcons: Record = { 'meta-sort': '📁', 'meta-fuse': '🗂️', 'meta-stremio': '🎬', 'meta-orbit': '🌐', 'default': '📦' }; function formatServiceName(name: string): string { return name.split('-').map(word => word.charAt(0).toUpperCase() + word.slice(1) ).join(' '); } function ServiceNav() { const [services, setServices] = useState([]); const [loading, setLoading] = useState(true); const currentService = 'meta-sort'; useEffect(() => { const fetchServices = async () => { try { const response = await fetch('/api/services'); if (response.ok) { const data: ServicesResponse = await response.json(); setServices(data.services || []); } } catch (error) { console.error('Failed to fetch services:', error); } finally { setLoading(false); } }; fetchServices(); const interval = setInterval(fetchServices, 30000); return () => clearInterval(interval); }, []); if (loading) return null; // Filter out follower meta-core instances (only show leader) const filteredServices = services.filter( s => s.name !== 'meta-core' || s.role === 'leader' ); const sortedServices = [...filteredServices].sort((a, b) => a.name.localeCompare(b.name)); if (sortedServices.length === 0) return null; return ( ); } export default ServiceNav;