import { useQuery } from '@tanstack/react-query'; import { rommApiClient } from '../api/client'; import { useInputMode } from '../context/InputModeContext'; export const TopNav = () => { const { mode } = useInputMode(); const { data: stats } = useQuery({ queryKey: ['stats'], queryFn: () => rommApiClient.fetchStats(), staleTime: 60000, // 1 minute caching }); const formatBytes = (bytes?: number) => { if (!bytes) return '--'; const gb = bytes / (1024 * 1024 * 1024); if (gb >= 1024) return `${(gb / 1024).toFixed(1)} TB`; return `${Math.round(gb)} GB`; }; return (
search
account_tree {stats?.PLATFORMS ?? '--'} Platforms
sports_esports {stats?.ROMS?.toLocaleString() ?? '--'} Games
hard_drive {formatBytes(stats?.TOTAL_FILESIZE_BYTES)}
save {stats?.SAVES?.toLocaleString() ?? '--'} Saves
history {stats?.STATES?.toLocaleString() ?? '--'} States
photo_library {stats?.SCREENSHOTS?.toLocaleString() ?? '--'} Screens
{/* Active Hardware Indicator */}
{mode === 'gamepad' ? 'sports_esports' : 'mouse'}
); };