/* * @Author: ZhaoYing * @Date: 2026-02-03 18:33:01 * @Last Modified by: ZhaoYing * @Last Modified time: 2026-03-16 14:58:25 */ import { type FC, useEffect, useState } from 'react' import { useTranslation } from 'react-i18next' import { useParams } from 'react-router-dom' import { Flex } from 'antd' import ReactEcharts from 'echarts-for-react' import Empty from '@/components/Empty' import RbCard from '@/components/RbCard/Card' import { getEmotionHealth } from '@/api/memory' /** * Health data structure * @property {number} health_score - Overall health score * @property {string} level - Health level * @property {Object} dimensions - Health dimensions (positivity, stability, resilience) * @property {Object} emotion_distribution - Distribution of emotions * @property {string} time_range - Time range for analysis */ interface Health { health_score: number; level: string; dimensions: { positivity_rate: { score: number; positive_count: number; negative_count: number; neutral_count: number; }; stability: { score: number; std_deviation: number; }; resilience: { score: number; recovery_rate: number; }; }; emotion_distribution: { joy: number; sadness: number; anger: number; fear: number; surprise: number; neutral: number; }; time_range: string; } /** * Health Component * Displays emotional health score with radar chart and dimension breakdowns * Shows positivity rate, stability, and resilience metrics */ const Health: FC = () => { const { t } = useTranslation() const { id } = useParams() const [health, setHealth] = useState(null) useEffect(() => { getWordCloudData() }, [id]) const getWordCloudData = () => { if (!id) { return } getEmotionHealth(id) .then((res) => { setHealth(res as Health) }) } return ( {health?.health_score && health?.health_score > 0 ? {health.dimensions && {['positivity_rate', 'stability', 'resilience'].map(key => (
{health.dimensions[key as keyof typeof health.dimensions].score}%
{t(`statementDetail.${key}`)}
))}
}
: }
) } export default Health