/* * @Author: ZhaoYing * @Date: 2026-02-03 18:33:06 * @Last Modified by: ZhaoYing * @Last Modified time: 2026-03-27 11:18:47 */ import { useEffect, useState, forwardRef, useImperativeHandle } from 'react' import { useTranslation } from 'react-i18next' import { useParams } from 'react-router-dom' import { Skeleton, Space, Progress, Tooltip, Flex } from 'antd'; import RbCard from '@/components/RbCard/Card' import Empty from '@/components/Empty' import { getImplicitHabits, } from '@/api/memory' import styles from '../pages/index.module.css' /** * Habits item data structure * @property {string} habit_description - Description of the habit * @property {string} frequency_pattern - Frequency pattern * @property {string} time_context - Time context * @property {number} confidence_level - Confidence level percentage * @property {string[]} supporting_summaries - Supporting summaries * @property {string} first_observed - First observation date * @property {string} last_observed - Last observation date * @property {boolean} is_current - Whether habit is current * @property {string[]} specific_examples - Specific examples */ interface HabitsItem { habit_description: string; frequency_pattern: string; time_context: string; confidence_level: number; supporting_summaries: string[]; first_observed: string; last_observed: string; is_current: boolean; specific_examples: string[]; } /** * Habits Component * Displays user habits with confidence levels and specific examples * Shows habit descriptions, time context, and supporting evidence */ const Habits = forwardRef<{ handleRefresh: () => void; }>((_props, ref) => { const { t } = useTranslation() const { id } = useParams() const [loading, setLoading] = useState(false) const [data, setData] = useState([]) useEffect(() => { if (!id) return getData() }, [id]) const getData = () => { if (!id) return setLoading(true) getImplicitHabits(id).then((res) => { const response = res as HabitsItem[] setData(response) setLoading(false) }) .finally(() => { setLoading(false) }) } useImperativeHandle(ref, () => ({ handleRefresh: getData })); return ( ( {t('implicitDetail.habits')}
)} headerType="borderless" headerClassName="rb:min-h-[54px]! rb:font-[MiSans-Bold] rb:font-bold" bodyClassName="rb:p-3! rb:pt-0! rb:h-[calc(100%-54px)] rb:overflow-y-auto!" className="rb:h-full!" > {loading ? : data.length === 0 ? : {data.map((vo, voIdx) => (
{vo.habit_description}
{vo.time_context}
{vo.specific_examples.length > 0 &&
{t('implicitDetail.specific_examples')}
    {vo.specific_examples.map((item, index) => (
  • {item}
  • ))}
}
))}
}
) }) export default Habits