import { useState } from 'react'
import { motion } from 'framer-motion'
import { Activity, Zap, Wifi, Timer, TrendingUp, TrendingDown } from 'lucide-react'
import { useAnimatedNumber, useLiveData, useInterval } from '../hooks/useUtils.js'
function WaveChart({ values, max, color = 'primary', height = 80 }) {
const points = values.map((v, i) => {
const x = (i / (values.length - 1)) * 100
const y = 100 - (v / max) * 100
return `${x},${y}`
}).join(' ')
return (
)
}
export default function TransferMonitor() {
const [uploadHistory, setUploadHistory] = useState(Array.from({ length: 40 }, () => 1.5 + Math.random() * 1.5))
const [downloadHistory, setDownloadHistory] = useState(Array.from({ length: 40 }, () => 1.2 + Math.random() * 1.2))
const liveData = useLiveData({
uploadRate: 2.34,
downloadRate: 1.92,
connections: 128,
latency: 19,
}, 1500, 0.05)
useInterval(() => {
setUploadHistory(prev => [...prev.slice(1), liveData.uploadRate])
setDownloadHistory(prev => [...prev.slice(1), liveData.downloadRate])
}, 1500)
const animatedUpload = useAnimatedNumber(liveData.uploadRate, 500)
const animatedDownload = useAnimatedNumber(liveData.downloadRate, 500)
const animatedConn = useAnimatedNumber(liveData.connections, 500)
const animatedLat = useAnimatedNumber(liveData.latency, 500)
const uploadTrend = uploadHistory[uploadHistory.length - 1] > uploadHistory[uploadHistory.length - 5]
const downloadTrend = downloadHistory[downloadHistory.length - 1] > downloadHistory[downloadHistory.length - 5]
return (
{/* Live banner */}
Transfer Monitor
LIVE
Updates every 1.5s
{/* Upload wave */}
Upload Rate
{animatedUpload.toFixed(2)}GB/s
{/* Download wave */}
Download Rate
{animatedDownload.toFixed(2)}GB/s
{/* Stats row */}
Connections
{Math.round(animatedConn)}
Latency
{animatedLat.toFixed(0)}ms
Total
{(animatedUpload + animatedDownload).toFixed(2)}GB/s
{/* Active transfers list */}
)
}