import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { useDatabaseHealthCheck } from '@/hooks/useDatabaseHealthCheck'; import { AlertCircle, AlertTriangle, Info, CheckCircle2 } from 'lucide-react'; import { Progress } from '@/components/ui/progress'; import { HealthIssueCard } from './HealthIssueCard'; import { Accordion } from '@/components/ui/accordion'; export function DatabaseHealthDashboard() { const { data, isLoading } = useDatabaseHealthCheck(); if (isLoading || !data) { return ( Database Health Loading health checks... ); } const { overall_score, critical_issues, warning_issues, info_issues, issues } = data; const getScoreColor = (score: number) => { if (score >= 80) return 'text-green-600'; if (score >= 60) return 'text-yellow-600'; if (score >= 40) return 'text-orange-600'; return 'text-red-600'; }; const getScoreBackground = (score: number) => { if (score >= 80) return 'bg-green-600'; if (score >= 60) return 'bg-yellow-600'; if (score >= 40) return 'bg-orange-600'; return 'bg-red-600'; }; const criticalIssues = issues.filter(i => i.severity === 'critical'); const warningIssues = issues.filter(i => i.severity === 'warning'); const infoIssues = issues.filter(i => i.severity === 'info'); return ( Database Health Automated health checks and data quality issues {/* Overall Health Score */} Overall Health Score {overall_score} Out of 100 Critical Issues: {critical_issues} Warnings: {warning_issues} Info: {info_issues} {/* Progress Bar */} Database Health {overall_score}% {/* Issues List */} {issues.length === 0 ? ( All Systems Healthy! No database health issues detected at this time. ) : ( {/* Critical Issues */} {criticalIssues.length > 0 && ( Critical Issues ({criticalIssues.length}) {criticalIssues.map((issue, index) => ( ))} )} {/* Warnings */} {warningIssues.length > 0 && ( Warnings ({warningIssues.length}) {warningIssues.map((issue, index) => ( ))} )} {/* Info */} {infoIssues.length > 0 && ( Information ({infoIssues.length}) {infoIssues.map((issue, index) => ( ))} )} )} ); }
Out of 100
No database health issues detected at this time.