"use client"; import { useState, useEffect } from "react"; import { useFlows } from "@/lib/api"; import { DataTable, Column } from "@/components/ui/DataTable"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/Card"; import { Loader2 } from "lucide-react"; import { fmtBytes } from "@/lib/utils"; export default function FlowsPage() { const [mounted, setMounted] = useState(false); const { data, isLoading } = useFlows(100); // fetch 100 flows useEffect(() => { setMounted(true); }, []); if (!mounted) return null; const columns: Column[] = [ { header: "#", accessor: (row, i) => i + 1 }, { header: "Flow ID", accessor: (row) => row.flow_id }, { header: "Src IP", accessor: (row) => {row.src_ip} }, { header: "Dst IP", accessor: (row) => {row.dst_ip} }, { header: "Dst Port", accessor: (row) => row.dst_port }, { header: "Protocol", accessor: (row) => row.protocol }, { header: "App / Domain", accessor: (row) => row.app_label || row.domain || "-" }, { header: "Download", accessor: (row) => {fmtBytes(row.bytes_download)} }, { header: "Upload", accessor: (row) => {fmtBytes(row.bytes_upload)} } ]; return (

Active Flows {isLoading && }

Active Flows ({data.length}) { const q = query.toLowerCase(); return ( (row.src_ip || "").toLowerCase().includes(q) || (row.dst_ip || "").toLowerCase().includes(q) || (row.app_label || "").toLowerCase().includes(q) || (row.domain || "").toLowerCase().includes(q) || (row.protocol || "").toLowerCase().includes(q) ); }} />
); }