// src/components/FusionPanel.jsx import React from 'react' import { RadarChart, PolarGrid, PolarAngleAxis, Radar, ResponsiveContainer } from 'recharts' import { EMOTION_COLORS } from '../lib/api' const EMOTION_ORDER = ['Happy', 'Angry', 'Fear', 'Sad', 'Neutral', 'Surprised', 'Disgust'] const RISK_CONFIG = { low: { label: 'LOW RISK', color: '#30d988', bg: 'rgba(48,217,136,0.08)', bar: '#30d988' }, medium: { label: 'MEDIUM RISK', color: '#f5a623', bg: 'rgba(245,166,35,0.08)', bar: '#f5a623' }, high: { label: 'HIGH RISK', color: '#ff4d6a', bg: 'rgba(255,77,106,0.08)', bar: '#ff4d6a' }, } export default function FusionPanel({ result }) { const emotion = result?.fused_emotion || '—' const probs = result?.fused_probs || {} const conf = result?.confidence ?? null const valence = result?.valence ?? null const arousal = result?.arousal ?? null const risk = result?.risk_level || 'low' const weights = result?.modal_weights || { visual: 0.5, text: 0.5 } const rec = result?.recommendation || '' const ms = result?.inference_ms ?? null const riskCfg = RISK_CONFIG[risk] const radarData = EMOTION_ORDER.map(name => ({ name, value: Math.round((probs[name] ?? 0) * 100), })) const emoColor = EMOTION_COLORS[emotion] || '#5e82aa' return (
{rec}
)}