"use client"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/Card"; import { DataTable, Column } from "@/components/ui/DataTable"; import { DeviceDetailModal } from "@/components/ui/DeviceDetailModal"; import { useState, useEffect } from "react"; import { useDevices, DeviceStat } from "@/lib/api"; import { fmtBytes } from "@/lib/utils"; import { Loader2, ChevronRight } from "lucide-react"; export default function DevicesPage() { const [mounted, setMounted] = useState(false); const devices = useDevices(100); const [selectedDevice, setSelectedDevice] = useState(null); useEffect(() => { setMounted(true); }, []); if (!mounted) return null; const columns: Column[] = [ { header: "#", accessor: (row, i) => i + 1 }, { header: "IP Address", accessor: (row) => ( ), }, { header: "MAC Address", accessor: (row) => row.mac_address ? ( {row.mac_address} ) : ( "-" ), }, { header: "Type", accessor: (row) => row.device_type || "-" }, { header: "OS", accessor: (row) => row.os_label || "-" }, { header: "Manufacturer", accessor: (row) => row.manufacturer || "-" }, { header: "Download", accessor: (row) => {fmtBytes(row.download)}, className: "text-right", }, { header: "Upload", accessor: (row) => {fmtBytes(row.upload)}, className: "text-right", }, ]; return (

Devices {devices.isLoading && }

Monitor and manage connected network devices.{" "} Click an IP to see app usage & flows.

Active Devices {devices.data ? `(${devices.data.length})` : ""} { const q = query.toLowerCase(); return ( (row.ip_address || "").toLowerCase().includes(q) || (row.mac_address || "").toLowerCase().includes(q) || (row.os_label || "").toLowerCase().includes(q) || (row.device_type || "").toLowerCase().includes(q) ); }} /> {/* Device Detail Modal */} {selectedDevice && ( setSelectedDevice(null)} /> )}
); }