'use client'; import React, { useEffect, useState } from 'react'; import { Card, CardContent, Typography, Grid, CircularProgress, Box } from '@mui/material'; import api from '@/lib/axios'; interface Stats { total: number; missing_title: number; missing_severity: number; missing_cvss_score: number; missing_cvss_vector: number; missing_references: number; missing_published_date: number; missing_description: number; missing_cwe: number; missing_cisa_kev: number; missing_cert_notes: number; missing_cert_alerts: number; } export default function CVEStatisticsPage() { const [stats, setStats] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { const fetchStats = async () => { try { const response = await api.get('/admin/statistics'); setStats(response.data); } catch (error) { console.error('Failed to fetch CVE stats:', error); } finally { setLoading(false); } }; fetchStats(); }, []); if (loading) { return ( Fetching CVE statistics... ); } if (!stats) { return No data available; } const { total, missing_title, missing_severity, missing_cvss_score, missing_cvss_vector, missing_references, missing_published_date, missing_description, missing_cwe, missing_cisa_kev, missing_cert_notes, missing_cert_alerts, } = stats; const complete = (value: number) => (total > 0 ? (((total - value) / total) * 100).toFixed(2) : '0'); return (
CVE Enrichment Statistics Completion Rates
); } interface StatCardProps { label: string; value: number; isPercentage?: boolean; } function StatCard({ label, value, isPercentage = false }: StatCardProps) { let color: 'error' | 'warning' | 'success' | 'textPrimary' = 'textPrimary'; if (isPercentage) { if (value >= 90) color = 'success'; else if (value >= 70) color = 'warning'; else color = 'error'; } return ( {label} {isPercentage ? `${value.toFixed(2)}%` : value.toLocaleString()} ); }