import React, { useState } from 'react'; import { motion, AnimatePresence } from 'framer-motion'; import { Opportunity } from '../types'; import { HelpCircle, TrendingUp, Zap, DollarSign, X, Target } from 'lucide-react'; interface OpportunityMatrixEnhancedProps { data: Opportunity[]; } const OpportunityMatrixEnhanced: React.FC = ({ data }) => { const [selectedOpportunity, setSelectedOpportunity] = useState(null); const [hoveredOpportunity, setHoveredOpportunity] = useState(null); const maxSavings = Math.max(...data.map(d => d.savings), 1); const getQuadrantLabel = (impact: number, feasibility: number): string => { if (impact >= 5 && feasibility >= 5) return 'Quick Wins'; if (impact >= 5 && feasibility < 5) return 'Proyectos Estratégicos'; if (impact < 5 && feasibility >= 5) return 'Estudiar'; return 'Descartar'; }; const getQuadrantColor = (impact: number, feasibility: number): string => { if (impact >= 5 && feasibility >= 5) return 'bg-green-500'; if (impact >= 5 && feasibility < 5) return 'bg-blue-500'; if (impact < 5 && feasibility >= 5) return 'bg-yellow-500'; return 'bg-slate-400'; }; return (

Opportunity Matrix

Prioriza iniciativas basadas en Impacto vs. Factibilidad. El tamaño de la burbuja representa el ahorro potencial. Click para ver detalles.
{/* Y-axis Label */}
Impacto
{/* X-axis Label */}
Factibilidad
{/* Quadrant Lines */}
{/* Quadrant Labels */}
Estudiar
Quick Wins ⭐
Descartar
Estratégicos
{/* Opportunities */} {data.map((opp, index) => { const size = 30 + (opp.savings / maxSavings) * 50; // Bubble size from 30px to 80px const isHovered = hoveredOpportunity === opp.id; const isSelected = selectedOpportunity?.id === opp.id; return ( setHoveredOpportunity(opp.id)} onMouseLeave={() => setHoveredOpportunity(null)} onClick={() => setSelectedOpportunity(opp)} >
{/* Hover Tooltip */} {isHovered && !selectedOpportunity && (

{opp.name}

Impacto: {opp.impact}/10
Factibilidad: {opp.feasibility}/10
Ahorro: €{opp.savings.toLocaleString('es-ES')}
)} ); })}
{/* Legend */}
Tamaño de burbuja:
Pequeño ahorro
Ahorro medio
Gran ahorro
Click en burbujas para ver detalles
{/* Detail Panel */} {selectedOpportunity && ( <> {/* Backdrop */} setSelectedOpportunity(null)} /> {/* Panel */}
{/* Header */}

Detalle de Oportunidad

{getQuadrantLabel(selectedOpportunity.impact, selectedOpportunity.feasibility)}
{/* Content */}

{selectedOpportunity.name}

{/* Metrics */}
Impacto
{selectedOpportunity.impact}/10
Factibilidad
{selectedOpportunity.feasibility}/10
{/* Savings */}
Ahorro Potencial Anual
€{selectedOpportunity.savings.toLocaleString('es-ES')}
{/* Recommendation */}
Recomendación

{selectedOpportunity.impact >= 7 && selectedOpportunity.feasibility >= 7 ? '🎯 Alta prioridad: Quick Win con gran impacto y fácil implementación. Recomendamos iniciar de inmediato.' : selectedOpportunity.impact >= 7 ? '🔵 Proyecto estratégico: Alto impacto pero requiere planificación. Incluir en roadmap a medio plazo.' : selectedOpportunity.feasibility >= 7 ? '🟡 Analizar más: Fácil de implementar pero impacto limitado. Evaluar coste-beneficio.' : '⚪ Baja prioridad: Considerar solo si hay recursos disponibles.'}

{/* Action Button */}
)}
); }; export default OpportunityMatrixEnhanced;