import React, { useEffect, useState } from 'react'; import { motion } from 'framer-motion'; import { TrendingUp, TrendingDown, Minus } from 'lucide-react'; import CountUp from 'react-countup'; interface HealthScoreGaugeEnhancedProps { score: number; previousScore?: number; industryAverage?: number; animated?: boolean; } const HealthScoreGaugeEnhanced: React.FC = ({ score, previousScore, industryAverage = 65, animated = true, }) => { const [isVisible, setIsVisible] = useState(false); useEffect(() => { setIsVisible(true); }, []); const getScoreColor = (value: number): string => { if (value >= 80) return '#10b981'; // green if (value >= 60) return '#f59e0b'; // amber return '#ef4444'; // red }; const getScoreLabel = (value: number): string => { if (value >= 80) return 'Excelente'; if (value >= 60) return 'Bueno'; if (value >= 40) return 'Regular'; return 'Crítico'; }; const scoreColor = getScoreColor(score); const scoreLabel = getScoreLabel(score); const trend = previousScore ? score - previousScore : 0; const trendPercentage = previousScore ? ((trend / previousScore) * 100).toFixed(1) : '0'; const vsIndustry = score - industryAverage; const vsIndustryPercentage = ((vsIndustry / industryAverage) * 100).toFixed(1); // Calculate SVG path for gauge const radius = 80; const circumference = 2 * Math.PI * radius; const strokeDashoffset = circumference - (score / 100) * circumference; return (

Health Score General

{/* Gauge SVG */}
{/* Background circle */} {/* Animated progress circle */} {/* Center content */}
{animated ? ( ) : ( score )}
{scoreLabel}
{/* Stats Grid */}
{/* Trend vs Previous */} {previousScore && (
{trend > 0 ? ( ) : trend < 0 ? ( ) : ( )} vs Anterior
0 ? 'text-green-600' : trend < 0 ? 'text-red-600' : 'text-slate-600'}`}> {trend > 0 ? '+' : ''}{trend}
{trend > 0 ? '+' : ''}{trendPercentage}%
)} {/* Vs Industry Average */}
{vsIndustry > 0 ? ( ) : vsIndustry < 0 ? ( ) : ( )} vs Industria
0 ? 'text-green-600' : vsIndustry < 0 ? 'text-red-600' : 'text-slate-600'}`}> {vsIndustry > 0 ? '+' : ''}{vsIndustry}
{vsIndustry > 0 ? '+' : ''}{vsIndustryPercentage}%
{/* Industry Average Reference */}
Promedio Industria {industryAverage}
); }; export default HealthScoreGaugeEnhanced;