"use client" import { useEffect, useState } from "react" import Link from "next/link" import { motion } from "motion/react" import { Gamepad2Icon, TrendingUpIcon, DatabaseIcon, ArrowRightIcon, Loader2 } from "lucide-react" interface DeviceStats { slug: string name: string deviceType: string sortOrder: number totalBenchmarks: number avgFps: number | null gameCount: number verifiedCount: number bestGame: { id: string title: string headerImage: string | null fpsAvg: number } | null } const deviceTypeLabel: Record = { handheld: "Handheld", console: "Console", } export function DevicesPageClient() { const [devices, setDevices] = useState([]) const [loading, setLoading] = useState(true) const [error, setError] = useState(null) useEffect(() => { async function fetchDevices() { try { const res = await fetch("/api/hardware/stats") if (!res.ok) throw new Error(`HTTP ${res.status}`) const data = await res.json() setDevices(data) } catch (err) { setError("Failed to load devices") console.error(err) } finally { setLoading(false) } } fetchDevices() }, []) if (loading) { return (
) } if (error) { return (

{error}

) } if (devices.length === 0) { return (

No devices found

Benchmark data will appear as devices are added

) } return (
{/* Header */}

Devices

Browse benchmark data for handheld and console devices

{/* Device Grid */}
{devices.map((device, i) => ( {/* Header */}

{device.name}

{deviceTypeLabel[device.deviceType] || device.deviceType}
{/* Stats */}
{device.totalBenchmarks} Benchmarks
{device.avgFps !== null ? device.avgFps : "—"} Avg FPS
{device.gameCount} Games
{/* Best game */} {device.bestGame && (
Top: {device.bestGame.title} · {device.bestGame.fpsAvg} FPS
)}
))}
) }