import { forwardRef, useImperativeHandle, useRef } from 'react' import { useTranslation } from 'react-i18next' import { Row, Col } from 'antd' import { useParams } from 'react-router-dom' import Preferences from '../components/Preferences' import Portrait from '../components/Portrait' import InterestAreas from '../components/InterestAreas' import Habits from '../components/Habits' import { generateProfile, } from '@/api/memory' const ImplicitDetail = forwardRef<{ handleRefresh: () => void; }>((_props, ref) => { const { t } = useTranslation() const { id } = useParams() const preferencesRef = useRef<{ handleRefresh: () => void; }>(null) const portraitRef = useRef<{ handleRefresh: () => void; }>(null) const interestAreasRef = useRef<{ handleRefresh: () => void; }>(null) const habitsRef = useRef<{ handleRefresh: () => void; }>(null) const handleRefresh = () => { if (!id) { return Promise.resolve() } return new Promise((resolve, reject) => { generateProfile(id) .then(() => { preferencesRef.current?.handleRefresh() portraitRef.current?.handleRefresh() interestAreasRef.current?.handleRefresh() habitsRef.current?.handleRefresh() resolve(true) }) .catch((error) => { reject(error) }) }) } useImperativeHandle(ref, () => ({ handleRefresh })); return (