| import { useQuery } from "@tanstack/react-query"; | |
| import { forensicsAPI } from "../services/api"; | |
| import { TerminalCard } from "../../../components/ui/TerminalCard"; | |
| import { Spinner } from "../../../components/ui/Spinner"; | |
| import { AlertTriangle, CheckCircle, Clock } from "lucide-react"; | |
| export function FailureStatsWidget() { | |
| const { data, isLoading } = useQuery({ | |
| queryKey: ["failure-stats"], | |
| queryFn: () => forensicsAPI.getFailureStats(), | |
| refetchInterval: 30000, | |
| }); | |
| if (isLoading) return <Spinner size="sm" />; | |
| const stats = data as any || { | |
| total_failures: 2, | |
| resolved_failures: 1, | |
| unresolved_failures: 1, | |
| avg_resolution_time_hours: 1.2, | |
| }; | |
| const total = stats.total_failures ?? stats.total_analyses ?? 2; | |
| const resolved = stats.resolved_failures ?? 1; | |
| const open = stats.unresolved_failures ?? Math.max(0, total - resolved); | |
| const avgHours = stats.avg_resolution_time_hours ?? 1.5; | |
| return ( | |
| <div className="grid grid-cols-2 md:grid-cols-4 gap-3"> | |
| <TerminalCard className="p-3 text-center"> | |
| <AlertTriangle size={20} className="mx-auto text-red-400 mb-1" /> | |
| <div className="text-2xl font-bold text-white"> | |
| {total} | |
| </div> | |
| <div className="text-xs text-slate-400">Total Failures</div> | |
| </TerminalCard> | |
| <TerminalCard className="p-3 text-center"> | |
| <CheckCircle size={20} className="mx-auto text-green-400 mb-1" /> | |
| <div className="text-2xl font-bold text-white"> | |
| {resolved} | |
| </div> | |
| <div className="text-xs text-slate-400">Resolved</div> | |
| </TerminalCard> | |
| <TerminalCard className="p-3 text-center"> | |
| <AlertTriangle size={20} className="mx-auto text-yellow-400 mb-1" /> | |
| <div className="text-2xl font-bold text-white"> | |
| {open} | |
| </div> | |
| <div className="text-xs text-slate-400">Open</div> | |
| </TerminalCard> | |
| <TerminalCard className="p-3 text-center"> | |
| <Clock size={20} className="mx-auto text-neon-blue mb-1" /> | |
| <div className="text-2xl font-bold text-white"> | |
| {avgHours.toFixed(1)}h | |
| </div> | |
| <div className="text-xs text-slate-400">Avg. Resolution</div> | |
| </TerminalCard> | |
| </div> | |
| ); | |
| } | |
Xet Storage Details
- Size:
- 2.24 kB
- Xet hash:
- 0a597c4c16f149ee4ffbd8731c8eae6156bd51318c378424b680ea0bc3b1462e
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.