import React from 'react'; import { DimensionAnalysis } from '../types'; import { motion } from 'framer-motion'; import { AlertCircle, AlertTriangle, TrendingUp, CheckCircle, Zap } from 'lucide-react'; import BadgePill from './BadgePill'; interface HealthStatus { level: 'critical' | 'low' | 'medium' | 'good' | 'excellent'; label: string; color: string; textColor: string; bgColor: string; icon: React.ReactNode; description: string; } const getHealthStatus = (score: number): HealthStatus => { if (score >= 86) { return { level: 'excellent', label: 'EXCELENTE', color: 'text-cyan-700', textColor: 'text-cyan-700', bgColor: 'bg-cyan-50', icon: , description: 'Top quartile, modelo a seguir' }; } if (score >= 71) { return { level: 'good', label: 'BUENO', color: 'text-emerald-700', textColor: 'text-emerald-700', bgColor: 'bg-emerald-50', icon: , description: 'Por encima de benchmarks, desempeño sólido' }; } if (score >= 51) { return { level: 'medium', label: 'MEDIO', color: 'text-amber-700', textColor: 'text-amber-700', bgColor: 'bg-amber-50', icon: , description: 'Oportunidad de mejora identificada' }; } if (score >= 31) { return { level: 'low', label: 'BAJO', color: 'text-orange-700', textColor: 'text-orange-700', bgColor: 'bg-orange-50', icon: , description: 'Requiere mejora, por debajo de benchmarks' }; } return { level: 'critical', label: 'CRÍTICO', color: 'text-red-700', textColor: 'text-red-700', bgColor: 'bg-red-50', icon: , description: 'Requiere acción inmediata' }; }; const getProgressBarColor = (score: number): string => { if (score >= 86) return 'bg-cyan-500'; if (score >= 71) return 'bg-emerald-500'; if (score >= 51) return 'bg-amber-500'; if (score >= 31) return 'bg-orange-500'; return 'bg-red-500'; }; const ScoreIndicator: React.FC<{ score: number; benchmark?: number }> = ({ score, benchmark }) => { const healthStatus = getHealthStatus(score); return (
{/* Main Score Display */}
{score} /100
{/* Progress Bar with Scale Reference */}
{/* Scale Reference */}
0 25 50 75 100
{/* Benchmark Comparison */} {benchmark !== undefined && (
Benchmark Industria (P50) {benchmark}/100
{score > benchmark ? ( ↑ {score - benchmark} puntos por encima del promedio ) : score === benchmark ? ( = Alineado con promedio de industria ) : ( ↓ {benchmark - score} puntos por debajo del promedio )}
)} {/* Health Status Description */}
{healthStatus.icon}

{healthStatus.description}

); }; const DimensionCard: React.FC<{ dimension: DimensionAnalysis }> = ({ dimension }) => { const healthStatus = getHealthStatus(dimension.score); return ( {/* Header */}

{dimension.title}

{dimension.name}

{dimension.score >= 86 && ( )}
{/* Score Indicator */}
{/* Summary Description */}

{dimension.summary}

{/* KPI Display */} {dimension.kpi && (

{dimension.kpi.label}

{dimension.kpi.value}

{dimension.kpi.change && ( {dimension.kpi.change} )}
)} {/* Action Button */} = 71} > {dimension.score < 51 ? 'Ver Acciones Críticas' : dimension.score < 71 ? 'Explorar Mejoras' : 'En buen estado'}
); }; export default DimensionCard;